kindeditor 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +65 -0
- data/Rakefile +20 -0
- data/VERSION +1 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/kindeditor.gemspec +234 -0
- data/lib/generators/USAGE +8 -0
- data/lib/generators/kindeditor/install_generator.rb +56 -0
- data/lib/generators/kindeditor/templates/README +20 -0
- data/lib/generators/kindeditor/templates/app/controllers/kindeditor_controller.rb +39 -0
- data/lib/generators/kindeditor/templates/app/models/kindeditor_image.rb +13 -0
- data/lib/generators/kindeditor/templates/create_kindeditor_images.rb +15 -0
- data/lib/generators/kindeditor/templates/kindeditor/kindeditor-min.js +168 -0
- data/lib/generators/kindeditor/templates/kindeditor/kindeditor.js +4442 -0
- data/lib/generators/kindeditor/templates/kindeditor/kindeditor_config.js +5 -0
- data/lib/generators/kindeditor/templates/kindeditor/license.txt +1 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/about.html +53 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/advtable/advtable.html +233 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/0.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/1.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/10.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/100.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/101.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/102.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/103.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/104.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/105.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/106.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/107.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/108.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/109.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/11.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/110.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/111.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/112.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/113.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/114.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/115.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/116.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/117.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/118.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/119.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/12.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/120.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/121.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/122.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/123.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/124.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/125.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/126.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/127.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/128.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/129.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/13.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/130.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/131.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/132.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/133.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/134.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/14.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/15.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/16.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/17.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/18.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/19.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/2.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/20.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/21.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/22.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/23.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/24.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/25.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/26.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/27.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/28.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/29.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/3.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/30.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/31.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/32.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/33.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/34.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/35.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/36.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/37.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/38.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/39.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/4.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/40.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/41.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/42.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/43.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/44.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/45.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/46.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/47.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/48.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/49.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/5.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/50.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/51.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/52.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/53.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/54.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/55.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/56.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/57.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/58.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/59.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/6.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/60.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/61.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/62.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/63.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/64.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/65.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/66.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/67.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/68.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/69.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/7.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/70.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/71.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/72.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/73.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/74.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/75.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/76.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/77.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/78.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/79.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/8.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/80.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/81.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/82.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/83.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/84.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/85.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/86.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/87.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/88.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/89.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/9.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/90.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/91.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/92.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/93.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/94.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/95.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/96.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/97.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/98.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/99.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/emoticons/qq.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/file_manager.css +64 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/file_manager.html +29 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/file_manager.js +220 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/images/file-16.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/images/file-64.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/images/folder-16.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/images/folder-64.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/file_manager/images/go-up.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/flash.html +72 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/image/image.html +268 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/image/images/align_left.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/image/images/align_right.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/image/images/align_top.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/image/images/refresh.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/link/link.html +86 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/media.html +76 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/plainpaste.html +43 -0
- data/lib/generators/kindeditor/templates/kindeditor/plugins/wordpaste.html +50 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/blank.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/editor.css +47 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/flash.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/loading.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/media.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/common/rm.gif +0 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/default.css +918 -0
- data/lib/generators/kindeditor/templates/kindeditor/skins/default/default.gif +0 -0
- data/lib/generators/kindeditor/templates/mongoid/kindeditor_image.rb +21 -0
- data/lib/kindeditor.rb +9 -0
- data/pkg/kindeditor-0.0.1.gem +0 -0
- data/pkg/kinkdeditor-0.0.1.gem +0 -0
- data/spec/generators/install_generaor_spec.rb +9 -0
- data/spec/kindeditor_spec.rb +7 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- data/uninstall.rb +1 -0
- metadata +269 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
class KindeditorImage < ActiveRecord::Base
|
2
|
+
before_create :randomize_file_name
|
3
|
+
has_attached_file :data
|
4
|
+
|
5
|
+
private
|
6
|
+
def randomize_file_name
|
7
|
+
|
8
|
+
unless data_file_name.nil?
|
9
|
+
extension = File.extname(data_file_name).downcase
|
10
|
+
self.data.instance_write(:file_name, "#{ActiveSupport::SecureRandom.hex(16)}#{extension}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateKindeditorImages < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :kindeditor_images do |t|
|
4
|
+
t.string :data_file_name
|
5
|
+
t.string :data_content_type
|
6
|
+
t.integer :data_file_size
|
7
|
+
t.datetime :data_updated_at
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
drop_table :kindeditor_images
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
(function(f){var d={};d.version="3.5.1 (2010-07-18)";d.scriptPath=function(){for(var a=document.getElementsByTagName("script"),b=0,c=a.length;b<c;b++)if(a[b].src&&a[b].src.match(/kindeditor[\w\-\.]*\.js/))return a[b].src.substring(0,a[b].src.lastIndexOf("/")+1);return""}();d.browser=function(){var a=navigator.userAgent.toLowerCase();return{VERSION:a.match(/(msie|firefox|webkit|opera)[\/:\s](\d+)/)?RegExp.$2:"0",IE:a.indexOf("msie")>-1&&a.indexOf("opera")==-1,GECKO:a.indexOf("gecko")>-1&&a.indexOf("khtml")==
|
2
|
+
-1,WEBKIT:a.indexOf("applewebkit")>-1,OPERA:a.indexOf("opera")>-1}}();d.setting={wyswygMode:true,loadStyleMode:true,resizeMode:2,filterMode:false,autoSetDataMode:true,shadowMode:true,urlType:"",skinType:"default",newlineTag:"p",dialogAlignType:"page",cssPath:"",skinsPath:d.scriptPath===""?"":d.scriptPath+"skins/",pluginsPath:d.scriptPath===""?"":d.scriptPath+"plugins/",minWidth:200,minHeight:100,minChangeSize:5,toolbarLineHeight:24,statusbarHeight:11,items:["source","|","fullscreen","undo","redo",
|
3
|
+
"print","cut","copy","paste","plainpaste","wordpaste","|","justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist","indent","outdent","subscript","superscript","|","selectall","-","title","fontname","fontsize","|","textcolor","bgcolor","bold","italic","underline","strikethrough","removeformat","|","image","flash","media","advtable","hr","emoticons","link","unlink","|","about"],colorTable:[["#E53333","#E56600","#FF9900","#64451D","#DFC5A4","#FFE500"],["#009900",
|
4
|
+
"#006600","#99BB00","#B8D100","#60D978","#00D5FF"],["#337FE5","#003399","#4C33E5","#9933E5","#CC33E5","#EE33EE"],["#FFFFFF","#CCCCCC","#999999","#666666","#333333","#000000"]],noEndTags:["br","hr","img","area","col","embed","input","param"],inlineTags:["b","del","em","font","i","span","strike","strong","sub","sup","u"],endlineTags:["br","hr","table","tbody","td","tr","th","div","p","ol","ul","li","blockquote","h1","h2","h3","h4","h5","h6","script","style","marquee"],htmlTags:{font:["color","size",
|
5
|
+
"face",".background-color"],span:[".color",".background-color",".font-size",".font-family",".background",".font-weight",".font-style",".text-decoration",".vertical-align"],div:["align",".border",".margin",".padding",".text-align",".color",".background-color",".font-size",".font-family",".font-weight",".background",".font-style",".text-decoration",".vertical-align",".margin-left"],table:["border","cellspacing","cellpadding","width","height","align","bordercolor",".padding",".margin",".border","bgcolor",
|
6
|
+
".text-align",".color",".background-color",".font-size",".font-family",".font-weight",".font-style",".text-decoration",".background",".width",".height"],"td,th":["align","valign","width","height","colspan","rowspan","bgcolor",".text-align",".color",".background-color",".font-size",".font-family",".font-weight",".font-style",".text-decoration",".vertical-align",".background"],a:["href","target","name"],embed:["src","width","height","type","loop","autostart","quality",".width",".height","align","allowscriptaccess",
|
7
|
+
"/"],img:["src","width","height","border","alt","title",".width",".height","/"],hr:["/"],br:["/"],"p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6":["align",".text-align",".color",".background-color",".font-size",".font-family",".background",".font-weight",".font-style",".text-decoration",".vertical-align",".text-indent",".margin-left"],"tbody,tr,strong,b,sub,sup,em,i,u,strike":[]},mediaTypes:{rm:"audio/x-pn-realaudio-plugin",flash:"application/x-shockwave-flash",media:"video/x-ms-asf-plugin"}};d.g={};d.plugin=
|
8
|
+
{};d.$=function(a,b){return(b||document).getElementById(a)};d.$$=function(a,b){return(b||document).createElement(a)};d.event={add:function(a,b,c,e){if(a.addEventListener)a.addEventListener(b,c,false);else a.attachEvent&&a.attachEvent("on"+b,c);e!==f&&d.g[e].eventStack.push({el:a,type:b,fn:c})},remove:function(a,b,c,e){if(a.removeEventListener)a.removeEventListener(b,c,false);else a.detachEvent&&a.detachEvent("on"+b,c);if(e!==f){e=d.g[e].eventStack;for(var g=0,h=e.length;g<h;g++){var i=e[g];i&&a===
|
9
|
+
i.el&&b===i.type&&c===i.fn&&delete e[g]}}},stop:function(a){a.preventDefault&&a.preventDefault();a.stopPropagation&&a.stopPropagation();if(a.cancelBubble!==f)a.cancelBubble=true;if(a.returnValue!==f)a.returnValue=false},bind:function(a,b,c,e){this.add(a,b,function(g){c(g);d.event.stop(g);return false},e)},input:function(a,b,c){function e(g){window.setTimeout(function(){b(g)},1)}this.add(a,"keyup",function(g){if(!g.ctrlKey&&!g.altKey&&(g.keyCode<16||g.keyCode>18)&&g.keyCode!=116){b(g);d.event.stop(g);
|
10
|
+
return false}},c);a=a.nodeName=="#document"?a.body:a;this.add(a,"paste",e,c);this.add(a,"cut",e,c)},ctrl:function(a,b,c,e){b=b.toString().match(/^\d{2,}$/)?b:b.toUpperCase().charCodeAt(0);this.add(a,"keydown",function(g){if(g.ctrlKey&&g.keyCode==b&&!g.shiftKey&&!g.altKey){c(g);d.event.stop(g);return false}},e)},ready:function(a,b,c,e){b=b||window;c=c||document;var g=false,h=function(){if(!g){g=true;a()}};if(c.addEventListener)this.add(c,"DOMContentLoaded",h,e);else if(c.attachEvent){this.add(c,"readystatechange",
|
11
|
+
function(){c.readyState=="complete"&&h()},e);if(c.documentElement.doScroll&&typeof b.frameElement==="undefined"){var i=function(){if(!g){try{c.documentElement.doScroll("left")}catch(j){window.setTimeout(i,0);return}h()}};i()}}this.add(b,"load",h,e)}};d.each=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(c,a[c])};d.eachNode=function(a,b){var c=function(e){if(d.util.getNodeType(e)!=1)return true;for(e=e.firstChild;e;){var g=e.nextSibling;if(!b(e))return false;if(!c(e))return false;e=g}return true};
|
12
|
+
c(a)};d.selection=function(a){this.keRange=this.range=this.sel=null;this.isControl=false;var b=a.parentWindow||a.defaultView;this.init=function(){var c=b.getSelection?b.getSelection():a.selection,e;try{e=c.rangeCount>0?c.getRangeAt(0):c.createRange()}catch(g){}e||(e=d.util.createRange(a));this.sel=c;this.range=e;var h,i,j;if(d.browser.IE)if(e.item){this.isControl=true;c=i=e.item(0);h=j=0}else{this.isControl=false;c=function(l){var m=e.duplicate();m.collapse(l);var p=m.parentElement(),o=p.childNodes;
|
13
|
+
if(o.length==0)return{node:p,pos:0};var q,r=0,u=false,n=e.duplicate();d.util.moveToElementText(n,p);for(var v=0,t=o.length;v<t;v++){l=o[v];var x=n.compareEndPoints("StartToStart",m);if(x>0)u=true;else if(x==0)if(l.nodeType==1){m=new d.range(a);m.selectTextNode(l);return{node:m.startNode,pos:0}}else return{node:l,pos:0};if(l.nodeType==1){x=e.duplicate();d.util.moveToElementText(x,l);n.setEndPoint("StartToEnd",x);if(u)r+=x.text.length;else r=0}else if(l.nodeType==3){n.moveStart("character",l.nodeValue.length);
|
14
|
+
r+=l.nodeValue.length}u||(q=l)}if(!u&&q.nodeType==1){q=p.lastChild;return{node:q,pos:q.nodeType==1?1:q.nodeValue.length}}n=e.duplicate();d.util.moveToElementText(n,p);n.setEndPoint("StartToEnd",m);r-=n.text.replace(/\r\n|\n|\r/g,"").length;return{node:q,pos:r}};h=c(true);j=c(false);c=h.node;h=h.pos;i=j.node;j=j.pos}else{c=e.startContainer;h=e.startOffset;i=e.endContainer;j=e.endOffset;if(c.nodeType==1&&typeof c.childNodes[h]!="undefined"){c=c.childNodes[h];h=0}if(i.nodeType==1){j=j==0?1:j;if(typeof i.childNodes[j-
|
15
|
+
1]!="undefined"){i=i.childNodes[j-1];j=i.nodeType==1?0:i.nodeValue.length}}this.isControl=c.nodeType==1&&c===i&&e.startOffset+1==e.endOffset;if(c.nodeType==1&&i.nodeType==3&&j==0&&i.previousSibling)for(var k=i.previousSibling;k;){if(k===c){i=c;break}if(k.childNodes.length!=1)break;k=k.childNodes[0]}if(e.collapsed){k=new d.range(a);k.setTextStart(c,h);i=k.startNode;j=k.startPos}}k=new d.range(a);k.setTextStart(c,h);k.setTextEnd(i,j);this.keRange=k};this.init();this.addRange=function(c){if(!(d.browser.GECKO&&
|
16
|
+
d.browser.VERSION<3)){this.keRange=c;if(d.browser.IE){var e=function(j){var k=d.util.createRange(a),l=j?c.startNode:c.endNode;if(l.nodeType==1){d.util.moveToElementText(k,l);k.collapse(j)}else if(l.nodeType==3){k=d.util.getNodeStartRange(a,l);k.moveStart("character",j?c.startPos:c.endPos)}return k};if(!this.range.item){var g=c.startNode;if(g==c.endNode&&d.util.getNodeType(g)==1&&d.util.getNodeTextLength(g)==0){e=a.createTextNode(" ");g.appendChild(e);d.util.moveToElementText(this.range,g);this.range.collapse(false);
|
17
|
+
this.range.select();g.removeChild(e)}else{if(g.nodeType==3&&c.collapsed()){this.range=e(true);this.range.collapse(true)}else{this.range.setEndPoint("StartToStart",e(true));this.range.setEndPoint("EndToStart",e(false))}this.range.select()}}}else{g=function(j){for(var k=0;j;){j=j.previousSibling;k++}return--k};e=new d.range(a);e.setTextStart(c.startNode,c.startPos);e.setTextEnd(c.endNode,c.endPos);var h=e.startNode,i=e.endNode;d.util.getNodeType(h)==88?this.range.setStart(h.parentNode,g(e.startNode)):
|
18
|
+
this.range.setStart(h,e.startPos);d.util.getNodeType(i)==88?this.range.setEnd(i.parentNode,g(e.endNode)+1):this.range.setEnd(i,e.endPos);this.sel.removeAllRanges();this.sel.addRange(this.range)}}};this.focus=function(){d.browser.IE&&this.range!=null&&this.range.select()}};d.range=function(a){this.endPos=this.endNode=this.startPos=this.startNode=null;this.getParentElement=function(){var b=function(g,h){for(;g&&(!g.tagName||g.tagName.toLowerCase()!="body");){g=g.parentNode;if(h(g))return}},c=[];b(this.startNode,
|
19
|
+
function(g){c.push(g)});var e;b(this.endNode,function(g){if(d.util.inArray(g,c)){e=g;return true}});return e?e:a.body};this.getNodeList=function(){var b=this,c=this.getParentElement(),e=[],g=false;if(c==b.startNode)g=true;g&&e.push(c);d.eachNode(c,function(h){if(h==b.startNode)g=true;var i=new d.range(a);i.selectTextNode(h);var j=i.comparePoints("START_TO_END",b);if(j>0)return false;else if(j==0)if(i.startNode!==i.endNode||i.startPos!==i.endPos)return false;g&&e.push(h);return true});return e};this.comparePoints=
|
20
|
+
function(b,c){var e=function(g,h,i,j){if(d.browser.IE){var k=function(m,p,o){var q=d.util.createRange(a),r=d.util.getNodeType(m);if(r==1){d.util.moveToElementText(q,m);q.collapse(o)}else if(r==3){q=d.util.getNodeStartRange(a,m);q.moveStart("character",p);q.collapse(true)}return q},l;l=b=="START_TO_START"||b=="START_TO_END"?k(g,h,true):k(g,h,false);g=b=="START_TO_START"||b=="END_TO_START"?k(i,j,true):k(i,j,false);return l.compareEndPoints("StartToStart",g)}else{l=d.util.createRange(a);l.selectNode(g);
|
21
|
+
b=="START_TO_START"||b=="START_TO_END"?l.collapse(true):l.collapse(false);g=d.util.createRange(a);g.selectNode(i);b=="START_TO_START"||b=="END_TO_START"?g.collapse(true):g.collapse(false);h=l.compareBoundaryPoints(Range.START_TO_START,g)>0?1:l.compareBoundaryPoints(Range.START_TO_START,g)==0?h>j?1:h==j?0:-1:-1}return h};if(b=="START_TO_START")return e(this.startNode,this.startPos,c.startNode,c.startPos);if(b=="START_TO_END")return e(this.startNode,this.startPos,c.endNode,c.endPos);if(b=="END_TO_START")return e(this.endNode,
|
22
|
+
this.endPos,c.startNode,c.startPos);if(b=="END_TO_END")return e(this.endNode,this.endPos,c.endNode,c.endPos)};this.collapsed=function(){return this.startNode===this.endNode&&this.startPos===this.endPos};this.collapse=function(b){b?this.setEnd(this.startNode,this.startPos):this.setStart(this.endNode,this.endPos)};this.setTextStart=function(b,c){var e=b;d.eachNode(b,function(g){if(d.util.getNodeType(g)==3&&g.nodeValue.length>0||d.util.getNodeType(g)==88){e=g;c=0;return false}return true});this.setStart(e,
|
23
|
+
c)};this.setStart=function(b,c){this.startNode=b;this.startPos=c;if(this.endNode===null){this.endNode=b;this.endPos=c}};this.setTextEnd=function(b,c){var e=b;d.eachNode(b,function(g){if(d.util.getNodeType(g)==3&&g.nodeValue.length>0||d.util.getNodeType(g)==88){e=g;c=d.util.getNodeType(g)==3?g.nodeValue.length:0}return true});this.setEnd(e,c)};this.setEnd=function(b,c){this.endNode=b;this.endPos=c;if(this.startNode===null){this.startNode=b;this.startPos=c}};this.selectNode=function(b){this.setStart(b,
|
24
|
+
0);this.setEnd(b,b.nodeType==1?0:b.nodeValue.length)};this.selectTextNode=function(b){this.setTextStart(b,0);this.setTextEnd(b,b.nodeType==1?0:b.nodeValue.length)};this.extractContents=function(b){b=b===f?true:b;var c=this,e=this.startNode,g=this.startPos,h=this.endNode,i=this.endPos,j=function(r,u,n){var v=r.nodeValue.length,t=r.cloneNode(true).splitText(u);t.splitText(n-u);if(b){var x=r;if(u>0)x=r.splitText(u);n<v&&x.splitText(n-u);x.parentNode.removeChild(x)}return t},k=d.util.arrayToHash(d.setting.noEndTags),
|
25
|
+
l=false,m=false,p=function(r,u){if(d.util.getNodeType(r)!=1)return true;for(var n=r.firstChild;n;){if(n==e)l=true;if(n==h)m=true;var v=n.nextSibling,t=n.nodeType;if(t==1){t=new d.range(a);t.selectNode(n);t=t.comparePoints("END_TO_END",c);if(l&&(t<0||t==0&&k[n.nodeName.toLowerCase()]!==f)){t=n.cloneNode(true);u.appendChild(t);b&&n.parentNode.removeChild(n)}else{t=n.cloneNode(false);if(k[t.nodeName.toLowerCase()]===f){u.appendChild(t);if(!p(n,t))return false}}}else if(t==3)if(l)if(n==e&&n==h){n=j(n,
|
26
|
+
g,i);u.appendChild(n);return false}else if(n==e){n=j(n,g,n.nodeValue.length);u.appendChild(n)}else if(n==h){n=j(n,0,i);u.appendChild(n);return false}else{n=j(n,0,n.nodeValue.length);u.appendChild(n)}n=v;if(m)return false}u.innerHTML.replace(/<.*?>/g,"")===""&&u.parentNode&&u.parentNode.removeChild(u);return true},o=this.getParentElement(),q=o.cloneNode(false);p(o,q);return q};this.cloneContents=function(){return this.extractContents(false)};this.getText=function(){return this.cloneContents().innerHTML.replace(/<.*?>/g,
|
27
|
+
"")}};d.cmd=function(a){this.doc=d.g[a].iframeDoc;this.keSel=d.g[a].keSel;this.keRange=d.g[a].keRange;this.mergeAttributes=function(b,c){for(var e=0,g=c.length;e<g;e++)d.each(c[e],function(h,i){if(h.charAt(0)=="."){var j=d.util.getJsKey(h.substr(1));b.style[j]=i}else{if(d.browser.IE&&d.browser.VERSION<8&&h=="class")h="className";b.setAttribute(h,i)}});return b};this.wrapTextNode=function(b,c,e,g,h){var i=b.nodeValue.length,j=c==0&&e==i,k=new d.range(this.doc);k.selectTextNode(b.parentNode);if(j&&
|
28
|
+
b.parentNode.tagName==g.tagName&&k.comparePoints("END_TO_END",this.keRange)<=0&&k.comparePoints("START_TO_START",this.keRange)>=0){this.mergeAttributes(b.parentNode,h);return b}else{g=g.cloneNode(true);if(j){c=b.cloneNode(true);g.appendChild(c);b.parentNode.replaceChild(g,b);return c}else{j=b;if(c<e){if(c>0)j=b.splitText(c);e<i&&j.splitText(e-c);c=j.cloneNode(true);g.appendChild(c);j.parentNode.replaceChild(g,j);return c}else{if(c<i){j=b.splitText(c);j.parentNode.insertBefore(g,j)}else j.nextSibling?
|
29
|
+
j.parentNode.insertBefore(g,j.nextSibling):j.parentNode.appendChild(g);return g}}}};this.wrap=function(b,c){c=c||[];var e=this;this.keSel.focus();var g=d.$$(b,this.doc);this.mergeAttributes(g,c);var h=this.keRange,i=h.startNode,j=h.startPos,k=h.endNode,l=h.endPos,m=h.getParentElement();if(!d.util.inMarquee(m)){var p=false;d.eachNode(m,function(o){if(o==i)p=true;if(o.nodeType==1)if(o==i&&o==k){if(d.util.inArray(o.tagName.toLowerCase(),d.g[a].noEndTags))j>0?o.parentNode.appendChild(g):o.parentNode.insertBefore(g,
|
30
|
+
o);else o.appendChild(g);h.selectNode(g);return false}else if(o==i)h.setStart(o,0);else{if(o==k){h.setEnd(o,0);return false}}else if(o.nodeType==3)if(p)if(o==i&&o==k){o=e.wrapTextNode(o,j,l,g,c);h.selectNode(o);return false}else if(o==i){o=e.wrapTextNode(o,j,o.nodeValue.length,g,c);h.setStart(o,0)}else if(o==k){o=e.wrapTextNode(o,0,l,g,c);h.setEnd(o,o.nodeType==1?0:o.nodeValue.length);return false}else e.wrapTextNode(o,0,o.nodeValue.length,g,c);return true});this.keSel.addRange(h)}};this.getTopParent=
|
31
|
+
function(b,c){for(var e=null;c;){c=c.parentNode;if(d.util.inArray(c.tagName.toLowerCase(),b))e=c;else break}return e};this.splitNodeParent=function(b,c,e){var g=new d.range(this.doc);g.selectNode(b.firstChild);g.setEnd(c,e);c=g.extractContents();b.parentNode.insertBefore(c,b);return{left:c,right:b}};this.remove=function(b){var c=this.keRange,e=c.startNode,g=c.startPos,h=c.endNode,i=c.endPos;this.keSel.focus();if(!d.util.inMarquee(c.getParentElement())){var j=c.getText().replace(/\s+/g,"")==="";if(!(j&&
|
32
|
+
!d.browser.IE)){var k=[];d.each(b,function(r){r!="*"&&k.push(r)});var l=this.getTopParent(k,e),m=this.getTopParent(k,h);if(l){var p=this.splitNodeParent(l,e,g);c.setStart(p.right,0);if(e==h&&d.util.getNodeTextLength(p.right)>0){c.selectNode(p.right);e=new d.range(this.doc);e.selectTextNode(p.left);if(g>0)i-=e.endNode.nodeValue.length;e.selectTextNode(p.right);h=e.startNode}}if(j){l=c.startNode;if(l.nodeType==1){if(l.nodeName.toLowerCase()=="br")return;c.selectNode(l)}else return}else if(m){g=this.splitNodeParent(m,
|
33
|
+
h,i);c.setEnd(g.left,0);l==m&&c.setStart(g.left,0)}m=function(r,u){if(u.charAt(0)=="."){var n=d.util.getJsKey(u.substr(1));r.style[n]=""}else{if(d.browser.IE&&d.browser.VERSION<8&&u=="class")u="className";r.removeAttribute(u)}};g=c.getNodeList();c.setTextStart(c.startNode,c.startPos);c.setTextEnd(c.endNode,c.endPos);i=0;for(j=g.length;i<j;i++){l=g[i];if(l.nodeType==1){p=l.tagName.toLowerCase();if(b[p]){p=b[p];e=0;for(h=p.length;e<h;e++)if(p[e]=="*"){d.util.removeParent(l);break}else{m(l,p[e]);var o=
|
34
|
+
[];if(l.outerHTML){attrHash=d.util.getAttrList(l.outerHTML);d.each(attrHash,function(r,u){o.push({name:r,value:u})})}else o=l.attributes;if(o.length==0){d.util.removeParent(l);break}else if(o[0].name=="style"&&o[0].value===""){d.util.removeParent(l);break}}}if(b["*"]){p=b["*"];e=0;for(h=p.length;e<h;e++)m(l,p[e])}}}try{this.keSel.addRange(c)}catch(q){}}}}};d.format={getUrl:function(a,b,c,e){if(!b)return a;b=b.toLowerCase();if(!d.util.inArray(b,["absolute","relative","domain"]))return a;c=c||location.protocol+
|
35
|
+
"//"+location.host;if(e===f){var g=location.pathname.match(/^(\/.*)\//);e=g?g[1]:""}if(g=a.match(/^(\w+:\/\/[^\/]*)/)){if(g[1]!==c)return a}else if(a.match(/^\w+:/))return a;g=function(i){i=i.split("/");paths=[];for(var j=0,k=i.length;j<k;j++){var l=i[j];if(l=="..")paths.length>0&&paths.pop();else l!==""&&l!="."&&paths.push(l)}return"/"+paths.join("/")};if(a.match(/^\//))a=c+g(a.substr(1));else a.match(/^\w+:\/\//)||(a=c+g(e+"/"+a));if(b=="relative"){var h=function(i,j){if(a.substr(0,i.length)===
|
36
|
+
i){for(var k=[],l=0;l<j;l++)k.push("..");l=".";if(k.length>0)l+="/"+k.join("/");if(e=="/")l+="/";return l+a.substr(i.length)}else if(k=i.match(/^(.*)\//))return h(k[1],++j)};a=h(c+e,0).substr(2)}else if(b=="absolute")if(a.substr(0,c.length)===c)a=a.substr(c.length);return a},getHtml:function(a,b,c){var e=b?true:false;a=a.replace(/(<pre[^>]*>)([\s\S]*?)(<\/pre>)/ig,function(m,p,o,q){return p+o.replace(/<br[^>]*>/ig,"\n")+q});var g={},h=["xx-small","x-small","small","medium","large","x-large","xx-large"];
|
37
|
+
e&&d.each(b,function(m,p){for(var o=m.split(","),q=0,r=o.length;q<r;q++)g[o[q]]=d.util.arrayToHash(p)});var i=d.util.arrayToHash(d.setting.noEndTags);d.util.arrayToHash(d.setting.inlineTags);var j=d.util.arrayToHash(d.setting.endlineTags);a=a.replace(/((?:\r\n|\n|\r)*)<(\/)?([\w-:]+)((?:\s+|(?:\s+[\w-:]+)|(?:\s+[\w-:]+=[^\s"'<>]+)|(?:\s+[\w-:]+="[^"]*")|(?:\s+[\w-:]+='[^']*'))*)(\/)?>((?:\r\n|\n|\r)*)/g,function(m,p,o,q,r,u,n){m=p||"";o=o||"";var v=q.toLowerCase();q=r||"";u=u?" "+u:"";n=n||"";if(e&&
|
38
|
+
typeof g[v]=="undefined")return"";if(u===""&&typeof i[v]!="undefined")u=" /";if(v in j){if(o||u)n="\n"}else if(n)n=" ";if(v!=="script"&&v!=="style")m="";if(v==="font"){var t={},x="";q=q.replace(/\s*([\w-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g,function(w,y,s){y=y.toLowerCase();s=s||"";s=s.replace(/^["']|["']$/g,"");if(y==="color"){t.color=s;return" "}if(y==="size"){t["font-size"]=h[parseInt(s)-1]||"";return" "}if(y==="face"){t["font-family"]=s;return" "}if(y==="style"){x=s;return" "}return w});if(x&&!/;$/.test(x))x+=
|
39
|
+
";";d.each(t,function(w,y){if(y!==""){if(/\s/.test(y))y="'"+y+"'";x+=w+":"+y+";"}});if(x)q+=' style="'+x+'"';v="span"}if(q!==""){q=q.replace(/\s*([\w-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g,function(w,y,s){w=y.toLowerCase();s=s||"";if(e)if(w.charAt(0)==="."||w!=="style"&&typeof g[v][w]=="undefined")return" ";if(s==="")s='""';else{if(w==="style"){s=s.substr(1,s.length-2);s=s.replace(/\s*([^\s]+?)\s*:(.*?)(;|$)/g,function(z,A,B){z=A.toLowerCase();if(e)if(typeof g[v].style=="undefined"&&typeof g[v]["."+
|
40
|
+
z]=="undefined")return"";B=d.util.trim(B);B=d.util.rgbToHex(B);return z+":"+B+";"});s=d.util.trim(s);if(s==="")return"";s='"'+s+'"'}if(d.util.inArray(w,["src","href"])){if(s.charAt(0)==='"')s=s.substr(1,s.length-2);s=d.format.getUrl(s,c)}if(s.charAt(0)!=='"')s='"'+s+'"'}return" "+w+"="+s+" "});q=q.replace(/\s+(checked|selected|disabled|readonly)(\s+|$)/ig,function(w,y){var s=y.toLowerCase();if(e)if(s.charAt(0)==="."||typeof g[v][s]=="undefined")return" ";return" "+s+'="'+s+'" '});q=d.util.trim(q);
|
41
|
+
if(q=q.replace(/\s+/g," "))q=" "+q;return m+"<"+o+v+q+u+">"+n}else return m+"<"+o+v+u+">"+n});if(!d.browser.IE){a=a.replace(/<p><br\s+\/>\n<\/p>/ig,"<p> </p>");a=a.replace(/<br\s+\/>\n<\/p>/ig,"</p>")}var k=d.setting.inlineTags.join("|"),l=function(m){var p=m.replace(new RegExp("<("+k+")[^>]*><\\/("+k+")>","ig"),function(o,q,r){return q==r?"":o});if(m!==p)p=l(p);return p};return d.util.trim(l(a))}};d.addClass=function(a,b){if(typeof a=="object"){var c=a.className;if(c){if((" "+c+" ").indexOf(" "+
|
42
|
+
b+" ")<0)a.className=c+" "+b}else a.className=b}else if(typeof a=="string")a=/\s+class\s*=/.test(a)?a.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/,function(e,g,h,i){return(" "+h+" ").indexOf(" "+b+" ")<0?h===""?g+b+i:g+h+" "+b+i:e}):a.substr(0,a.length-1)+' class="'+b+'">';return a};d.removeClass=function(a,b){var c=a.className||"";c=" "+c+" ";b=" "+b+" ";if(c.indexOf(b)>=0){c=d.util.trim(c.replace(new RegExp(b,"ig"),""));if(c===""){c=a.getAttribute("class")?"class":"className";a.removeAttribute(c)}else a.className=
|
43
|
+
c}return a};d.getComputedStyle=function(a,b){var c=a.ownerDocument,e=c.parentWindow||c.defaultView;c=d.util.getJsKey(b);var g="";if(e.getComputedStyle){e=e.getComputedStyle(a,null);g=e[c]||e.getPropertyValue(b)||a.style[c]}else if(a.currentStyle)g=a.currentStyle[c]||a.style[c];return g};d.getCommonAncestor=function(a,b){function c(i){for(;i;){if(i.nodeType==1)if(i.tagName.toLowerCase()===b)return i;i=i.parentNode}return null}var e=a.range,g=a.keRange,h=g.startNode;g=g.endNode;if(d.util.inArray(b,
|
44
|
+
["table","td","tr"]))if(d.browser.IE)if(e.item){if(e.item(0).nodeName.toLowerCase()===b)h=g=e.item(0)}else{h=e.duplicate();h.collapse(true);e=e.duplicate();e.collapse(false);h=h.parentElement();g=e.parentElement()}else{h=e.cloneRange();h.collapse(true);e=e.cloneRange();e.collapse(false);h=h.startContainer;g=e.startContainer}e=c(h);h=c(g);if(e&&h&&e===h)return e;return null};d.queryCommandValue=function(a,b){function c(){var i=a.queryCommandValue(b);if(typeof i!=="string")i="";return i}b=b.toLowerCase();
|
45
|
+
var e="";if(b==="fontname"){e=c();e=e.replace(/['"]/g,"")}else if(b==="formatblock"){e=c();if(e===""){var g=new d.selection(a),h=d.getCommonAncestor(g,"h1");h||(h=d.getCommonAncestor(g,"h2"));h||(h=d.getCommonAncestor(g,"h3"));h||(h=d.getCommonAncestor(g,"h4"));h||(h=d.getCommonAncestor(g,"p"));if(h)e=h.nodeName}if(e==="Normal")e="p"}else if(b==="fontsize"){g=new d.selection(a);if(h=d.getCommonAncestor(g,"span"))e=d.getComputedStyle(h,"font-size")}else if(b==="textcolor"){g=new d.selection(a);if(h=
|
46
|
+
d.getCommonAncestor(g,"span"))e=d.getComputedStyle(h,"color");e=d.util.rgbToHex(e);if(e==="")e="default"}else if(b==="bgcolor"){g=new d.selection(a);if(h=d.getCommonAncestor(g,"span"))e=d.getComputedStyle(h,"background-color");e=d.util.rgbToHex(e);if(e==="")e="default"}return e.toLowerCase()};d.util={getDocumentElement:function(a){a=a||document;return a.compatMode!="CSS1Compat"?a.body:a.documentElement},getDocumentHeight:function(a){a=this.getDocumentElement(a);return Math.max(a.scrollHeight,a.clientHeight)},
|
47
|
+
getDocumentWidth:function(a){a=this.getDocumentElement(a);return Math.max(a.scrollWidth,a.clientWidth)},createTable:function(a){a=d.$$("table",a);a.cellPadding=0;a.cellSpacing=0;a.border=0;return{table:a,cell:a.insertRow(0).insertCell(0)}},loadStyle:function(a){var b=d.$$("link");b.setAttribute("type","text/css");b.setAttribute("rel","stylesheet");b.setAttribute("href",a);document.getElementsByTagName("head")[0].appendChild(b)},getAttrList:function(a){for(var b=/\s+(?:([\w-:]+)|(?:([\w-:]+)=([\w-:]+))|(?:([\w-:]+)="([^"]*)")|(?:([\w-:]+)='([^']*)'))(?=(?:\s|\/|>)+)/g,
|
48
|
+
c,e,g={};c=b.exec(a);){e=c[1]||c[2]||c[4]||c[6];c=c[1]||(c[2]?c[3]:c[4]?c[5]:c[7]);g[e]=c}return g},inArray:function(a,b){for(var c=0;c<b.length;c++)if(a==b[c])return true;return false},trim:function(a){return a.replace(/^\s+|\s+$/g,"")},getJsKey:function(a){var b=a.split("-");a="";for(var c=0,e=b.length;c<e;c++)a+=c>0?b[c].charAt(0).toUpperCase()+b[c].substr(1):b[c];return a},arrayToHash:function(a){for(var b={},c=0,e=a.length;c<e;c++)b[a[c]]=1;return b},escape:function(a){a=a.replace(/&/g,"&");
|
49
|
+
a=a.replace(/</g,"<");a=a.replace(/>/g,">");return a=a.replace(/"/g,""")},unescape:function(a){a=a.replace(/</g,"<");a=a.replace(/>/g,">");a=a.replace(/"/g,'"');return a=a.replace(/&/g,"&")},getScrollPos:function(){var a,b;if(d.browser.IE||d.browser.OPERA){b=this.getDocumentElement();a=b.scrollLeft;b=b.scrollTop}else{a=window.scrollX;b=window.scrollY}return{x:a,y:b}},getElementPos:function(a){var b=0,c=0;if(a.getBoundingClientRect){c=a.getBoundingClientRect();a=this.getScrollPos();
|
50
|
+
b=c.left+a.x;c=c.top+a.y}else{b=a.offsetLeft;c=a.offsetTop;for(a=a.offsetParent;a;){b+=a.offsetLeft;c+=a.offsetTop;a=a.offsetParent}}return{x:b,y:c}},getCoords:function(a){a=a||window.event;return{x:a.clientX,y:a.clientY}},setOpacity:function(a,b){if(typeof a.style.opacity=="undefined")a.style.filter=b==100?"":"alpha(opacity="+b+")";else a.style.opacity=b==100?"":"0."+b.toString()},getIframeDoc:function(a){return a.contentDocument||a.contentWindow.document},rgbToHex:function(a){function b(c){c=parseInt(c).toString(16);
|
51
|
+
return c.length>1?c:"0"+c}return a.replace(/rgb\s*?\(\s*?(\d+)\s*?,\s*?(\d+)\s*?,\s*?(\d+)\s*?\)/ig,function(c,e,g,h){return"#"+b(e)+b(g)+b(h)})},parseJson:function(a){var b=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;b.lastIndex=0;if(b.test(a))a=a.replace(b,function(c){return"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
|
52
|
+
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return eval("("+a+")");throw"JSON parse error";},createRange:function(a){return a.createRange?a.createRange():a.body.createTextRange()},getNodeType:function(a){return a.nodeType==1&&d.util.inArray(a.tagName.toLowerCase(),d.setting.noEndTags)?88:a.nodeType},inMarquee:function(a){for(a=a;a;){if(a.nodeName.toLowerCase()==="marquee")return true;a=a.parentNode}return false},moveToElementText:function(a,b){this.inMarquee(b)||a.moveToElementText(b)},getNodeTextLength:function(a){var b=
|
53
|
+
d.util.getNodeType(a);if(b==1)return a.innerHTML.replace(/<.*?>/ig,"").length;else if(b==3)return a.nodeValue.length},getNodeStartRange:function(a,b){var c=d.util.createRange(a),e=b.nodeType;if(e==1){d.util.moveToElementText(c,b);return c}else if(e==3){e=0;for(var g=b.previousSibling;g;){if(g.nodeType==1){var h=d.util.createRange(a);d.util.moveToElementText(h,g);c.setEndPoint("StartToEnd",h);c.moveStart("character",e);return c}else if(g.nodeType==3)e+=g.nodeValue.length;g=g.previousSibling}d.util.moveToElementText(c,
|
54
|
+
b.parentNode);c.moveStart("character",e);return c}},removeParent:function(a){if(a.hasChildNodes)for(var b=a.firstChild;b;){var c=b.nextSibling;a.parentNode.insertBefore(b,a);b=c}a.parentNode.removeChild(a)},pluginLang:function(a,b){d.each(d.lang.plugins[a],function(c,e){var g=d.$("lang."+c,b);if(g){g.parentNode.insertBefore(b.createTextNode(e),g);g.parentNode.removeChild(g)}})},drag:function(a,b,c,e){var g=d.g[a];b.onmousedown=function(h){function i(s){if(x){var z=d.util.getCoords(s),A=d.util.getScrollPos();
|
55
|
+
s=parseInt(z.y-u-v+A.y);z=parseInt(z.x-n-t+A.x);e(p,o,q,r,s,z)}}function j(s){if(x){var z=d.util.getCoords(s,g.iframeDoc);s=parseInt(w.y+z.y-u-v);z=parseInt(w.x+z.x-n-t);e(p,o,q,r,s,z)}}function k(s){x=false;l.releaseCapture&&l.releaseCapture();d.event.remove(document,"mousemove",i);d.event.remove(document,"mouseup",k);d.event.remove(g.iframeDoc,"mousemove",j);d.event.remove(g.iframeDoc,"mouseup",k);d.event.remove(document,"selectstart",y);d.event.stop(s);return false}var l=this;h=h||window.event;
|
56
|
+
var m=d.util.getCoords(h),p=parseInt(c.style.top),o=parseInt(c.style.left),q=c.style.width,r=c.style.height;if(q.match(/%$/))q=c.offsetWidth+"px";if(r.match(/%$/))r=c.offsetHeight+"px";q=parseInt(q);r=parseInt(r);var u=m.y,n=m.x;m=d.util.getScrollPos();var v=m.y,t=m.x,x=true,w=d.util.getElementPos(g.iframe),y=function(){return false};d.event.add(document,"mousemove",i);d.event.add(document,"mouseup",k);d.event.add(g.iframeDoc,"mousemove",j);d.event.add(g.iframeDoc,"mouseup",k);d.event.add(document,
|
57
|
+
"selectstart",y);l.setCapture&&l.setCapture();d.event.stop(h);return false}},resize:function(a,b,c,e,g){g=typeof g=="undefined"?true:g;a=d.g[a];if(a.container)if(!(e&&(parseInt(b)<=a.minWidth||parseInt(c)<=a.minHeight))){if(g)a.container.style.width=b;a.container.style.height=c;b=parseInt(c)-a.toolbarHeight-a.statusbarHeight;if(b>=0){a.iframe.style.height=b+"px";a.newTextarea.style.height=(d.browser.IE&&d.browser.VERSION<8||document.compatMode!="CSS1Compat"?b-2:b)+"px"}}},hideLoadingPage:function(a){a=
|
58
|
+
d.g[a].dialogStack;a=a[a.length-1];a.loading.style.display="none";a.iframe.style.display=""},showLoadingPage:function(a){a=d.g[a].dialogStack;a=a[a.length-1];a.loading.style.display="";a.iframe.style.display="none"},setDefaultPlugin:function(){for(var a=["selectall","justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist","indent","outdent","subscript","superscript","bold","italic","underline","strikethrough"],b={bold:"B",italic:"I",underline:"U"},c=0;c<
|
59
|
+
a.length;c++){var e=a[c],g={};if(e in b)g.init=function(h){return function(i){d.event.ctrl(d.g[i].iframeDoc,b[h],function(){d.plugin[h].click(i);d.util.focus(i)},i)}}(e);g.click=function(h){return function(i){d.util.execCommand(i,h,null)}}(e);d.plugin[e]=g}},getFullHtml:function(a){var b="<html>";b+="<head>";b+='<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';b+="<title>KindEditor</title>";b+='<link href="'+d.g[a].skinsPath+"common/editor.css?ver="+escape(d.version)+'" rel="stylesheet" type="text/css" />';
|
60
|
+
a=d.g[a].cssPath;if(typeof a=="string")a=[a];for(var c=0,e=a.length;c<e;c++)if(a[c]!=="")b+='<link href="'+a[c]+'" rel="stylesheet" type="text/css" />';b+="</head>";b+='<body class="ke-content"></body>';b+="</html>";return b},getMediaType:function(a){return a.match(/\.(rm|rmvb)(\?|$)/i)?"rm":a.match(/\.(swf|flv)(\?|$)/i)?"flash":"media"},getMediaImage:function(a,b,c){var e=c.width,g=c.height;b=b||this.getMediaType(c.src);c=this.getMediaEmbed(c);var h="";if(e>0)h+="width:"+e+"px;";if(g>0)h+="height:"+
|
61
|
+
g+"px;";a='<img class="'+("ke-"+b)+'" src="'+d.g[a].skinsPath+'common/blank.gif" ';if(h!=="")a+='style="'+h+'" ';a+='kesrctag="'+escape(c)+'" alt="" />';return a},getMediaEmbed:function(a){var b="<embed ";d.each(a,function(c,e){b+=c+'="'+e+'" '});b+="/>";return b},execGetHtmlHooks:function(a,b){for(var c=d.g[a].getHtmlHooks,e=0,g=c.length;e<g;e++)b=c[e](b);return b},execSetHtmlHooks:function(a,b){for(var c=d.g[a].setHtmlHooks,e=0,g=c.length;e<g;e++)b=c[e](b);return b},execOnchangeHandler:function(a){a=
|
62
|
+
d.g[a].onchangeHandlerStack;for(var b=0,c=a.length;b<c;b++)a[b]()},toData:function(a,b){var c=d.g[a],e=this.execGetHtmlHooks(a,b);e=e.replace(/^\s*<br[^>]*>\s*$/ig,"");e=e.replace(/^\s*<p>\s* \s*<\/p>\s*$/ig,"");return c.filterMode?d.format.getHtml(e,c.htmlTags,c.urlType):d.format.getHtml(e,null,c.urlType)},getData:function(a,b){var c=d.g[a];(b=b===f?c.wyswygMode:b)||this.innerHtml(c.iframeDoc.body,d.util.execSetHtmlHooks(a,c.newTextarea.value));return this.toData(a,c.iframeDoc.body.innerHTML)},
|
63
|
+
getSrcData:function(a){var b=d.g[a];b.wyswygMode||this.innerHtml(b.iframeDoc.body,d.util.execSetHtmlHooks(a,b.newTextarea.value));return b.iframeDoc.body.innerHTML},getPureData:function(a){return this.extractText(this.getData(a))},extractText:function(a){a=a.replace(/<(?!img|embed).*?>/ig,"");return a=a.replace(/ /ig," ")},isEmpty:function(a){return this.getPureData(a).replace(/\r\n|\n|\r/,"").replace(/^\s+|\s+$/,"")===""},setData:function(a){var b=d.g[a];if(b.srcTextarea)b.srcTextarea.value=
|
64
|
+
this.getData(a)},focus:function(a){a=d.g[a];a.wyswygMode?a.iframeWin.focus():a.newTextarea.focus()},click:function(a,b){this.focus(a);d.hideMenu(a);d.plugin[b].click(a)},selection:function(a){if(!d.browser.IE||!d.g[a].keRange)this.setSelection(a)},setSelection:function(a){a=d.g[a];var b=new d.selection(a.iframeDoc);if(!d.browser.IE||b.range.item||b.range.parentElement().ownerDocument===a.iframeDoc){a.keSel=b;a.keRange=a.keSel.keRange;a.sel=a.keSel.sel;a.range=a.keSel.range}},select:function(a){d.browser.IE&&
|
65
|
+
d.g[a].wyswygMode&&d.g[a].range&&d.g[a].range.select()},execCommand:function(a,b,c){d.util.focus(a);d.util.select(a);try{d.g[a].iframeDoc.execCommand(b,false,c)}catch(e){}d.toolbar.updateState(a);d.util.execOnchangeHandler(a)},innerHtml:function(a,b){if(d.browser.IE){a.innerHTML='<img id="__ke_temp_tag__" width="0" height="0" />'+b;var c=d.$("__ke_temp_tag__",a.ownerDocument);c&&c.parentNode.removeChild(c)}else a.innerHTML=b},pasteHtml:function(a,b,c){a=d.g[a];if(c)b='<img id="__ke_temp_tag__" width="0" height="0" />'+
|
66
|
+
b;else b+='<img id="__ke_temp_tag__" width="0" height="0" />';if(d.browser.IE)if(a.range.item)a.range.item(0).outerHTML=b;else a.range.pasteHTML(b);else{a.range.deleteContents();b=a.range.createContextualFragment(b);a.range.insertNode(b)}b=d.$("__ke_temp_tag__",a.iframeDoc);c=a.iframeDoc.createTextNode("");b.parentNode.replaceChild(c,b);a.keRange.selectNode(c);a.keSel.addRange(a.keRange)},insertHtml:function(a,b){if(b!==""){var c=d.g[a];if(c.wyswygMode)if(c.range){b=this.execSetHtmlHooks(a,b);if(d.browser.IE){this.select(a);
|
67
|
+
if(c.range.item)try{c.range.item(0).outerHTML=b}catch(e){c=c.range.item(0);var g=c.parentNode;g.removeChild(c);if(g.nodeName.toLowerCase()!="body")g=g.parentNode;this.innerHtml(g,b+g.innerHTML)}else c.range.pasteHTML(b)}else if(d.browser.GECKO&&d.browser.VERSION<3){this.execCommand(a,"inserthtml",b);return}else this.pasteHtml(a,b);d.util.execOnchangeHandler(a)}}},setFullHtml:function(a,b){var c=d.g[a];if(!d.browser.IE&&b==="")b="<br />";b=d.util.execSetHtmlHooks(a,b);this.innerHtml(c.iframeDoc.body,
|
68
|
+
b);if(!c.wyswygMode)c.newTextarea.value=d.util.getData(a,true);d.util.execOnchangeHandler(a)},selectImageWebkit:function(a,b,c){if(d.browser.WEBKIT){b=b.srcElement||b.target;if(b.tagName.toLowerCase()=="img"){c&&d.util.selection(a);c=d.g[a].keRange;c.selectNode(b);d.g[a].keSel.addRange(c)}}},addTabEvent:function(a){d.event.add(d.g[a].iframeDoc,"keydown",function(b){if(b.keyCode==9){d.util.setSelection(a);d.util.insertHtml(a," ");d.event.stop(b);return false}},a)},addContextmenuEvent:function(a){var b=
|
69
|
+
d.g[a];b.contextmenuItems.length!=0&&d.event.add(b.iframeDoc,"contextmenu",function(c){d.hideMenu(a);d.util.setSelection(a);d.util.selectImageWebkit(a,c,false);for(var e=0,g=[],h=0,i=b.contextmenuItems.length;h<i;h++){var j=b.contextmenuItems[h];if(j==="-")g.push(j);else if(j.cond&&j.cond(a)){g.push(j);if(j.options){var k=parseInt(j.options.width)||0;if(k>e)e=k}}j=j}for(;g.length>0&&g[0]==="-";)g.shift();for(;g.length>0&&g[g.length-1]==="-";)g.pop();j=null;h=0;for(i=g.length;h<i;h++){g[h]==="-"&&
|
70
|
+
j==="-"&&delete g[h];j=g[h]||null}if(g.length>0){var l=new d.menu({id:a,event:c,type:"contextmenu",width:e});h=0;for(i=g.length;h<i;h++)if(j=g[h])if(j==="-")h<i-1&&l.addSeparator();else l.add(j.text,function(m){return function(){m.click(a,l)}}(j),j.options);l.show();d.event.stop(c);return false}return true},a)},addNewlineEvent:function(a){var b=d.g[a];d.browser.IE&&b.newlineTag.toLowerCase()!="br"||d.browser.GECKO&&d.browser.VERSION<3&&b.newlineTag.toLowerCase()!="p"||d.browser.OPERA||d.event.add(b.iframeDoc,
|
71
|
+
"keydown",function(c){if(c.keyCode!=13||c.shiftKey||c.ctrlKey||c.altKey)return true;d.util.setSelection(a);var e=b.keRange.getParentElement();if(!d.util.inMarquee(e)){e=e.tagName.toLowerCase();if(b.newlineTag.toLowerCase()=="br"){if(!d.util.inArray(e,["h1","h2","h3","h4","h5","h6","li"])){d.util.pasteHtml(a,"<br />");e=b.keRange.startNode.nextSibling;if(d.browser.IE)e||d.util.pasteHtml(a,"<br />",true);else if(d.browser.WEBKIT)if(e){var g=new d.range(b.iframeDoc);g.selectNode(e.parentNode);g.setStart(e,
|
72
|
+
0);g.cloneContents().innerHTML.replace(/<(?!img|embed).*?>/ig,"")===""&&d.util.pasteHtml(a,"<br />",true)}else d.util.pasteHtml(a,"<br />",true);d.event.stop(c);return false}}else d.util.inArray(e,["p","h1","h2","h3","h4","h5","h6","pre","div","li"])||d.util.execCommand(a,"formatblock","<P>");return true}},a)}};d.layout={hide:function(a){var b=d.g[a];d.hideMenu(a);for(a=b.dialogStack;a.length>0;)a[a.length-1].hide();b.maskDiv.style.display="none"}};d.hideMenu=function(a){a=d.g[a];a.hideDiv.innerHTML=
|
73
|
+
"";a.hideDiv.style.display="none"};d.colorpicker=function(a){var b,c=a.x||0,e=a.y||0,g=a.z||0,h=a.colors||d.setting.colorTable,i=a.doc||document,j=a.onclick,k=(a.selectedColor||"").toLowerCase();b=d.$$("div");b.className="ke-colorpicker";b.style.top=e+"px";b.style.left=c+"px";b.style.zIndex=g;this.remove=function(){i.body.removeChild(b)};this.getElement=function(){function l(n,v,t){if(k===v.toLowerCase())t+=" ke-colorpicker-cell-selected";n.className=t;n.title=v||d.lang.noColor;n.onmouseover=function(){this.className=
|
74
|
+
t+" ke-colorpicker-cell-on"};n.onmouseout=function(){this.className=t};n.onclick=function(){j(v)};if(v){var x=d.$$("div");x.className="ke-colorpicker-cell-color";x.style.backgroundColor=v;n.appendChild(x)}else n.innerHTML=d.lang.noColor}var m=d.$$("table");m.className="ke-colorpicker-table";m.cellPadding=0;m.cellSpacing=0;m.border=0;var p=m.insertRow(0),o=p.insertCell(0);o.colSpan=h[0].length;l(o,"","ke-colorpicker-cell-top");for(var q=0;q<h.length;q++){p=m.insertRow(q+1);for(var r=0;r<h[q].length;r++){var u=
|
75
|
+
h[q][r];o=p.insertCell(r);l(o,u,"ke-colorpicker-cell")}}return m};this.create=function(){b.appendChild(this.getElement());d.event.bind(b,"click",function(){});d.event.bind(b,"mousedown",function(){});i.body.appendChild(b)}};d.menu=function(a){function b(c,e){var g=a.id,h=0,i=0;if(this.type=="menu"){g=d.g[g].toolbarIcon[a.cmd];i=d.util.getElementPos(g[0]);h=i.x;i=i.y+g[0].offsetHeight}else{i=d.util.getCoords(a.event);g=d.util.getElementPos(d.g[g].iframe);h=i.x+g.x;i=i.y+g.y+5}if(c>0||e>0){g=d.util.getScrollPos();
|
76
|
+
var j=d.util.getDocumentElement();g=g.x+j.clientWidth-c-2;if(h>g)h=g}return{x:h,y:i}}(function(){var c=a.width;this.type=a.type&&a.type=="contextmenu"?a.type:"menu";var e=d.$$("div");e.className="ke-"+this.type;e.setAttribute("name",a.cmd);var g=b.call(this,0,0);e.style.top=g.y+"px";e.style.left=g.x+"px";if(a.width)e.style.width=/^\d+$/.test(c)?c+"px":c;d.event.bind(e,"click",function(){},a.id);d.event.bind(e,"mousedown",function(){},a.id);this.div=e}).call(this);this.add=function(c,e,g){var h,i,
|
77
|
+
j=false;if(g!==f){h=g.height;i=g.iconHtml;j=g.checked}var k=this;g=d.$$("div");g.className="ke-"+k.type+"-item";if(h)g.style.height=h;var l=d.$$("div");l.className="ke-"+this.type+"-left";var m=d.$$("div");m.className="ke-"+k.type+"-center";if(h)m.style.height=h;var p=d.$$("div");p.className="ke-"+this.type+"-right";if(h)p.style.lineHeight=h;g.onmouseover=function(){this.className="ke-"+k.type+"-item ke-"+k.type+"-item-on";m.className="ke-"+k.type+"-center ke-"+k.type+"-center-on"};g.onmouseout=function(){this.className=
|
78
|
+
"ke-"+k.type+"-item";m.className="ke-"+k.type+"-center"};g.onclick=e;g.appendChild(l);g.appendChild(m);g.appendChild(p);if(j)d.util.innerHtml(l,'<span class="ke-common-icon ke-common-icon-url ke-icon-checked"></span>');else i&&d.util.innerHtml(l,i);d.util.innerHtml(p,c);this.append(g)};this.addSeparator=function(){var c=d.$$("div");c.className="ke-"+this.type+"-separator";this.append(c)};this.append=function(c){this.div.appendChild(c)};this.insert=function(c){d.util.innerHtml(this.div,c)};this.hide=
|
79
|
+
function(){d.hideMenu(a.id)};this.show=function(){this.hide();var c=a.id;d.g[c].hideDiv.style.display="";d.g[c].hideDiv.appendChild(this.div);c=b.call(this,this.div.clientWidth,this.div.clientHeight);this.div.style.top=c.y+"px";this.div.style.left=c.x+"px"};this.picker=function(c){this.append((new d.colorpicker({colors:d.g[a.id].colorTable,onclick:function(e){d.plugin[a.cmd].exec(a.id,e)},selectedColor:c})).getElement());this.show()}};d.dialog=function(a){function b(){d.util.getDocumentElement();
|
80
|
+
var h=d.util.getScrollPos();e=h.y;g=h.x}function c(){var h=this.width+this.widthMargin,i=this.height+this.heightMargin,j=a.id,k=d.g[j],l=0,m=0;if(k.dialogAlignType=="page"){k=d.util.getDocumentElement();j=d.util.getScrollPos();l=Math.round(j.x+(k.clientWidth-h)/2);m=Math.round(j.y+(k.clientHeight-i)/2)}else{j=d.util.getElementPos(d.g[j].container);k=k.container;l=Math.round(k.clientWidth/2)-Math.round(h/2);i=Math.round(k.clientHeight/2)-Math.round(i/2);l=l<0?j.x:j.x+l;m=i<0?j.y:j.y+i}return{x:l<0?
|
81
|
+
0:l,y:m<0?0:m}}this.widthMargin=30;this.heightMargin=100;this.zIndex=19811214;this.width=a.width;this.height=a.height;var e,g;this.beforeHide=a.beforeHide;this.afterHide=a.afterHide;this.beforeShow=a.beforeShow;this.afterShow=a.afterShow;this.ondrag=a.ondrag;this.resize=function(h,i){if(h)this.width=h;if(i)this.height=i;this.hide();this.show()};this.hide=function(){this.beforeHide&&this.beforeHide(h);var h=a.id,i=d.g[h].dialogStack;if(i[i.length-1]==this){var j=i.pop().iframe;j.src="javascript:false";
|
82
|
+
j.parentNode.removeChild(j);document.body.removeChild(this.div);if(i.length<1)d.g[h].maskDiv.style.display="none";d.event.remove(window,"resize",b);d.event.remove(window,"scroll",b);this.afterHide&&this.afterHide(h);d.util.focus(h)}};this.show=function(){this.beforeShow&&this.beforeShow(i);var h=this,i=a.id,j=d.$$("div");j.className="ke-dialog";d.event.bind(j,"click",function(){},i);d.event.bind(j,"mousedown",function(){},i);var k=d.g[i].dialogStack;if(k.length>0)this.zIndex=k[k.length-1].zIndex+
|
83
|
+
1;j.style.zIndex=this.zIndex;k=c.call(this);j.style.top=k.y+"px";j.style.left=k.x+"px";var l;if(d.g[i].shadowMode){k=d.$$("table");k.className="ke-dialog-table";k.cellPadding=0;k.cellSpacing=0;k.border=0;for(var m=["t","m","b"],p=["l","c","r"],o=0;o<3;o++)for(var q=k.insertRow(o),r=0;r<3;r++){var u=q.insertCell(r);u.className="ke-"+m[o]+p[r];if(o==1&&r==1)l=u;else u.innerHTML='<span class="ke-dialog-empty"></span>'}j.appendChild(k)}else{d.addClass(j,"ke-dialog-no-shadow");l=j}k=d.$$("div");k.className=
|
84
|
+
"ke-dialog-title";k.innerHTML=a.title;m=d.$$("span");m.className="ke-dialog-close";d.g[i].shadowMode?d.addClass(m,"ke-dialog-close-shadow"):d.addClass(m,"ke-dialog-close-no-shadow");m.alt=d.lang.close;m.title=d.lang.close;m.onclick=function(){h.hide();d.util.select(i)};k.appendChild(m);b();d.event.add(window,"resize",b);d.event.add(window,"scroll",b);d.util.drag(i,k,j,function(n,v,t,x,w,y){h.ondrag&&h.ondrag(i);b();w=n+w;y=v+y;if(w<e)w=e;if(y<g)y=g;j.style.top=w+"px";j.style.left=y+"px"});l.appendChild(k);
|
85
|
+
p=d.$$("div");p.className="ke-dialog-body";k=d.util.createTable();k.table.className="ke-loading-table";k.table.style.width=this.width+"px";k.table.style.height=this.height+"px";m=d.$$("span");m.className="ke-loading-img";k.cell.appendChild(m);m=d.g[i].dialogStack.length==0&&d.g[i].dialog?d.g[i].dialog:d.$$("iframe");m.className=a.useFrameCSS?"ke-dialog-iframe ke-dialog-iframe-border":"ke-dialog-iframe";m.setAttribute("frameBorder","0");m.style.width=this.width+"px";m.style.height=this.height+"px";
|
86
|
+
m.style.display="none";p.appendChild(m);p.appendChild(k.table);l.appendChild(p);r=d.$$("div");r.className="ke-dialog-bottom";q=o=p=null;if(a.previewButton){q=d.$$("input");q.className="ke-button ke-dialog-preview";q.type="button";q.name="previewButton";q.value=a.previewButton;q.onclick=function(){var n=d.g[i].dialogStack;n[n.length-1]==h&&d.plugin[a.cmd].preview(i)};r.appendChild(q)}if(a.yesButton){o=d.$$("input");o.className="ke-button ke-dialog-yes";o.type="button";o.name="yesButton";o.value=a.yesButton;
|
87
|
+
o.onclick=function(){var n=d.g[i].dialogStack;n[n.length-1]==h&&d.plugin[a.cmd].exec(i)};r.appendChild(o)}if(a.noButton){p=d.$$("input");p.className="ke-button ke-dialog-no";p.type="button";p.name="noButton";p.value=a.noButton;p.onclick=function(){h.hide();d.util.select(i)};r.appendChild(p)}if(a.yesButton||a.noButton||a.previewButton)l.appendChild(r);document.body.appendChild(j);window.focus();if(o)o.focus();else p&&p.focus();if(a.html!==f){l=d.util.getIframeDoc(m);r=d.util.getFullHtml(i);l.open();
|
88
|
+
l.write(r);l.close();d.util.innerHtml(l.body,a.html)}else if(a.url!==f)m.src=a.url;else{l="id="+escape(i)+"&ver="+escape(d.version);if(a.file===f)m.src=d.g[i].pluginsPath+a.cmd+".html?"+l;else{l=(/\?/.test(a.file)?"&":"?")+l;m.src=d.g[i].pluginsPath+a.file+l}}d.g[i].maskDiv.style.width=d.util.getDocumentWidth()+"px";d.g[i].maskDiv.style.height=d.util.getDocumentHeight()+"px";d.g[i].maskDiv.style.display="block";this.iframe=m;this.loading=k.table;this.noButton=p;this.yesButton=o;this.previewButton=
|
89
|
+
q;this.div=j;d.g[i].dialogStack.push(this);d.g[i].dialog=m;d.g[i].yesButton=o;d.g[i].noButton=p;d.g[i].previewButton=q;a.loadingMode||d.util.hideLoadingPage(i);this.afterShow&&this.afterShow(i);d.g[i].afterDialogCreate&&d.g[i].afterDialogCreate(i)}};d.toolbar={updateState:function(a){for(var b=["justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist","indent","outdent","subscript","superscript","bold","italic","underline","strikethrough"],c=0;c<b.length;c++){var e=
|
90
|
+
b[c],g=false;try{g=d.g[a].iframeDoc.queryCommandState(e)}catch(h){}g?d.toolbar.select(a,e):d.toolbar.unselect(a,e)}},isSelected:function(a,b){return d.plugin[b]&&d.plugin[b].isSelected?true:false},select:function(a,b){if(d.g[a].toolbarIcon[b]){var c=d.g[a].toolbarIcon[b][0];c.className="ke-icon ke-icon-selected";c.onmouseover=null;c.onmouseout=null}},unselect:function(a,b){if(d.g[a].toolbarIcon[b]){var c=d.g[a].toolbarIcon[b][0];c.className="ke-icon";c.onmouseover=function(){this.className="ke-icon ke-icon-on"};
|
91
|
+
c.onmouseout=function(){this.className="ke-icon"}}},_setAttr:function(a,b,c){b.className="ke-icon";b.href="javascript:;";b.onclick=function(e){e=e||window.event;var g=d.g[a].hideDiv.firstChild;g&&g.getAttribute("name")==c?d.hideMenu(a):d.util.click(a,c);e.preventDefault&&e.preventDefault();e.stopPropagation&&e.stopPropagation();if(e.cancelBubble!==f)e.cancelBubble=true;return false};b.onmouseover=function(){this.className="ke-icon ke-icon-on"};b.onmouseout=function(){this.className="ke-icon"};b.hidefocus=
|
92
|
+
true;b.title=d.lang[c]},able:function(a,b){var c=this;d.each(d.g[a].toolbarIcon,function(e,g){if(!d.util.inArray(e,b)){var h=g[1];c._setAttr(a,g[0],e);d.util.setOpacity(h,100)}})},disable:function(a,b){d.each(d.g[a].toolbarIcon,function(c,e){if(!d.util.inArray(c,b)){var g=e[0],h=e[1];g.className="ke-icon ke-icon-disabled";d.util.setOpacity(h,50);g.onclick=null;g.onmouseover=null;g.onmouseout=null}})},create:function(a){var b=d.util.arrayToHash(d.setting.items);d.g[a].toolbarIcon=[];var c=d.util.createTable(),
|
93
|
+
e=c.table;e.className="ke-toolbar";e.oncontextmenu=function(){return false};e.onmousedown=function(){return false};e.onmousemove=function(){return false};c=c.cell;var g=d.g[a].items.length,h=0,i;d.g[a].toolbarHeight=d.g[a].toolbarLineHeight;for(var j=0;j<g;j++){var k=d.g[a].items[j];if(j==0||k=="-"){var l=d.util.createTable().table;l.className="ke-toolbar-table";i=l.insertRow(0);h=0;c.appendChild(l);if(k=="-"){d.g[a].toolbarHeight+=d.g[a].toolbarLineHeight;continue}}l=i.insertCell(h);l.hideforcus=
|
94
|
+
true;h++;if(k=="|"){k=d.$$("div");k.className="ke-toolbar-separator";l.appendChild(k)}else{var m=d.$$("a");this._setAttr(a,m,k);var p=d.$$("span");p.className=typeof b[k]=="undefined"?"ke-common-icon ke-icon-"+k:"ke-common-icon ke-common-icon-url ke-icon-"+k;m.appendChild(p);l.appendChild(m);d.g[a].toolbarIcon[k]=[m,p];d.toolbar.isSelected(a,k)&&d.toolbar.select(a,k)}}return e}};d.history={addStackData:function(a,b){var c="";if(a.length>0)c=a[a.length-1];if(a.length==0||b!==c)a.push(b)},add:function(a,
|
95
|
+
b){var c=d.g[a],e=d.util.getSrcData(a);if(c.undoStack.length>0)if(Math.abs(e.length-c.undoStack[c.undoStack.length-1].length)<b)return;this.addStackData(c.undoStack,e)},undo:function(a){var b=d.g[a];if(b.undoStack.length!=0){var c=d.util.getSrcData(a);this.addStackData(b.redoStack,c);var e=b.undoStack.pop();if(c===e&&b.undoStack.length>0)e=b.undoStack.pop();e=d.util.toData(a,e);if(b.wyswygMode)d.util.innerHtml(b.iframeDoc.body,d.util.execSetHtmlHooks(a,e));else b.newTextarea.value=e}},redo:function(a){var b=
|
96
|
+
d.g[a];if(b.redoStack.length!=0){var c=d.util.getSrcData(a);this.addStackData(b.undoStack,c);c=b.redoStack.pop();c=d.util.toData(a,c);if(b.wyswygMode)d.util.innerHtml(b.iframeDoc.body,d.util.execSetHtmlHooks(a,c));else b.newTextarea.value=c}}};d.readonly=function(a,b){b=b==f?true:b;var c=d.g[a];if(d.browser.IE)c.iframeDoc.body.contentEditable=b?"false":"true";else c.iframeDoc.designMode=b?"off":"on"};d.focus=function(a,b){b=(b||"").toLowerCase();if(d.g[a].container){d.util.focus(a);if(b==="end"){d.util.setSelection(a);
|
97
|
+
if(d.g[a].sel){var c=d.g[a].keSel,e=d.g[a].keRange;e.selectTextNode(d.g[a].iframeDoc.body);e.collapse(false);c.addRange(e)}}}};d.html=function(a,b){if(b===f)return d.util.getData(a);else if(d.g[a].container){d.util.setFullHtml(a,b);d.focus(a,"end")}};d.text=function(a,b){if(b===f){b=d.html(a);b=b.replace(/<.*?>/ig,"");b=b.replace(/ /ig," ");return b=d.util.trim(b)}else d.html(a,d.util.escape(b))};d.insertHtml=function(a,b){if(d.g[a].container)if(d.g[a].range){d.focus(a);d.util.selection(a);d.util.insertHtml(a,
|
98
|
+
b)}else d.appendHtml(a,b)};d.appendHtml=function(a,b){d.html(a,d.html(a)+b);d.focus(a,"end")};d.isEmpty=function(a){return d.util.isEmpty(a)};d.selectedHtml=function(a){var b=d.g[a].range;if(!b)return"";var c="";if(d.browser.IE)c=b.item?b.item(0).outerHTML:b.htmlText;else{c=d.$$("div",d.g[a].iframeDoc);c.appendChild(b.cloneContents());c=c.innerHTML}return d.util.toData(a,c)};d.count=function(a,b){b=(b||"html").toLowerCase();if(b==="html")return d.html(a).length;else if(b==="text"){var c=d.util.getPureData(a);
|
99
|
+
c=c.replace(/<(?:img|embed).*?>/ig,"K");c=c.replace(/\r\n|\n|\r/g,"");c=d.util.trim(c);return c.length}return 0};d.remove=function(a,b){var c=d.g[a];if(!c.container)return false;b=typeof b=="undefined"?0:b;d.util.setData(a);for(var e=c.container,g=c.eventStack,h=0,i=g.length;h<i;h++){var j=g[h];j&&d.event.remove(j.el,j.type,j.fn,a)}c.iframeDoc.src="javascript:false";c.iframe.parentNode.removeChild(c.iframe);if(b==1)document.body.removeChild(e);else{g=c.srcTextarea;g.parentNode.removeChild(e);if(b==
|
100
|
+
0)g.style.display=""}document.body.removeChild(c.hideDiv);document.body.removeChild(c.maskDiv);c.container=null;c.dialogStack=[];c.contextmenuItems=[];c.getHtmlHooks=[];c.setHtmlHooks=[];c.onchangeHandlerStack=[];c.eventStack=[]};d.create=function(a,b){function c(){d.hideMenu(a)}function e(){d.toolbar.updateState(a)}function g(){d.util.setSelection(a)}d.g[a].beforeCreate&&d.g[a].beforeCreate(a);if(d.browser.IE&&d.browser.VERSION<7)try{document.execCommand("BackgroundImageCache",false,true)}catch(h){}var i=
|
101
|
+
d.$(a)||document.getElementsByName(a)[0];b=typeof b=="undefined"?0:b;if(!(b==0&&d.g[a].container)){var j=d.g[a].width||i.style.width||i.offsetWidth+"px",k=d.g[a].height||i.style.height||i.offsetHeight+"px",l=d.util.createTable(),m=l.table;m.className="ke-container";m.style.width=j;m.style.height=k;var p=l.cell;p.className="ke-toolbar-outer";var o=m.insertRow(1).insertCell(0);o.className="ke-textarea-outer";l=d.util.createTable();var q=l.table;q.className="ke-textarea-table";var r=l.cell;o.appendChild(q);
|
102
|
+
var u=m.insertRow(2).insertCell(0);u.className="ke-bottom-outer";i.style.display="none";b==1?document.body.appendChild(m):i.parentNode.insertBefore(m,i);o=d.toolbar.create(a);o.style.height=d.g[a].toolbarHeight+"px";p.appendChild(o);p=d.g[a].iframe||d.$$("iframe");p.className="ke-iframe";p.setAttribute("frameBorder","0");l=d.$$("textarea");l.className="ke-textarea";l.style.display="none";d.g[a].container=m;d.g[a].iframe=p;d.g[a].newTextarea=l;d.util.resize(a,j,k);r.appendChild(p);r.appendChild(l);
|
103
|
+
r=d.$$("table");r.className="ke-bottom";r.cellPadding=0;r.cellSpacing=0;r.border=0;r.style.height=d.g[a].statusbarHeight+"px";var n=r.insertRow(0),v=n.insertCell(0);v.className="ke-bottom-left";var t=d.$$("span");t.className="ke-bottom-left-img";if(d.g[a].config.resizeMode==0||b==1){v.style.cursor="default";t.style.visibility="hidden"}v.appendChild(t);n=n.insertCell(1);n.className="ke-bottom-right";t=d.$$("span");t.className="ke-bottom-right-img";if(d.g[a].config.resizeMode==0||b==1){n.style.cursor=
|
104
|
+
"default";t.style.visibility="hidden"}else if(d.g[a].config.resizeMode==1){n.style.cursor="s-resize";t.style.visibility="hidden"}n.appendChild(t);u.appendChild(r);u=d.$$("div");u.className="ke-reset";u.style.display="none";t=d.$$("div");t.className="ke-mask";d.util.setOpacity(t,50);d.event.bind(t,"click",function(){},a);d.event.bind(t,"mousedown",function(){},a);document.body.appendChild(u);document.body.appendChild(t);d.util.setDefaultPlugin(a);var x=p.contentWindow,w=d.util.getIframeDoc(p);if(!d.browser.IE||
|
105
|
+
d.browser.VERSION<8)w.designMode="on";var y=d.util.getFullHtml(a);w.open();w.write(y);w.close();if(!d.g[a].wyswygMode){l.value=d.util.execSetHtmlHooks(a,i.value);l.style.display="block";p.style.display="none";d.toolbar.disable(a,["source","fullscreen"]);d.toolbar.select(a,"source")}d.browser.WEBKIT&&d.event.add(w,"click",function(s){d.util.selectImageWebkit(a,s,true)},a);d.browser.IE&&d.event.add(w,"keydown",function(s){if(s.keyCode==8){s=d.g[a].range;if(s.item){s=s.item(0);s.parentNode.removeChild(s);
|
106
|
+
d.util.execOnchangeHandler(a);d.event.stop(a);return false}}},a);d.event.add(w,"click",c,a);d.event.add(w,"click",e,a);d.event.input(w,e,a);d.event.bind(l,"click",c,a);d.event.add(document,"click",c,a);d.g[a].toolbarTable=o;d.g[a].textareaTable=q;d.g[a].srcTextarea=i;d.g[a].bottom=r;d.g[a].hideDiv=u;d.g[a].maskDiv=t;d.g[a].iframeWin=x;d.g[a].iframeDoc=w;d.g[a].width=j;d.g[a].height=k;d.util.drag(a,n,m,function(s,z,A,B,C,D){if(d.g[a].resizeMode==2)d.util.resize(a,A+D+"px",B+C+"px",true);else d.g[a].resizeMode==
|
107
|
+
1&&d.util.resize(a,A+"px",B+C+"px",true,false)});d.util.drag(a,v,m,function(s,z,A,B,C){d.g[a].resizeMode>0&&d.util.resize(a,A+"px",B+C+"px",true,false)});d.each(d.plugin,function(s,z){z.init&&z.init(a)});d.g[a].getHtmlHooks.push(function(s){return s.replace(/(<[^>]*)kesrc="([^"]+)"([^>]*>)/ig,function(z,A,B){z=z.replace(/(\s+(?:href|src)=")[^"]+(")/i,"$1"+B+"$2");return z=z.replace(/\s+kesrc="[^"]+"/i,"")})});d.g[a].setHtmlHooks.push(function(s){return s.replace(/(<[^>]*)(href|src)="([^"]+)"([^>]*>)/ig,
|
108
|
+
function(z,A,B,C,D){if(z.match(/\skesrc="[^"]+"/i))return z;return A+B+'="'+C+'" kesrc="'+C+'"'+D})});d.util.addContextmenuEvent(a);d.util.addNewlineEvent(a);d.util.addTabEvent(a);d.event.input(w,g,a);d.event.add(w,"mouseup",g,a);d.event.add(document,"mousedown",g,a);d.onchange(a,function(s){if(d.g[s].autoSetDataMode){d.util.setData(s);d.g[s].afterSetData&&d.g[s].afterSetData(s)}d.history.add(s,d.g[s].minChangeSize)});d.browser.IE&&d.browser.VERSION>7&&d.readonly(a,false);d.util.setFullHtml(a,i.value);
|
109
|
+
d.history.add(a,0);b>0&&d.util.focus(a);d.g[a].afterCreate&&d.g[a].afterCreate(a)}};d.onchange=function(a,b){function c(){b(a)}var e=d.g[a];e.onchangeHandlerStack.push(c);d.event.input(e.iframeDoc,c,a);d.event.input(e.newTextarea,c,a);d.event.add(e.iframeDoc,"mouseup",function(){window.setTimeout(function(){b(a)},0)},a)};d.init=function(a){var b=d.g[a.id]=a;b.config={};b.undoStack=[];b.redoStack=[];b.dialogStack=[];b.contextmenuItems=[];b.getHtmlHooks=[];b.setHtmlHooks=[];b.onchangeHandlerStack=[];
|
110
|
+
b.eventStack=[];d.each(d.setting,function(c,e){b[c]=typeof a[c]=="undefined"?e:a[c];b.config[c]=b[c]});b.loadStyleMode&&d.util.loadStyle(b.skinsPath+b.skinType+".css")};d.show=function(a){d.init(a);d.event.ready(function(){d.create(a.id)})};if(window.KE===f)window.KE=d;window.KindEditor=d})();
|
111
|
+
(function(f){f.langType="zh_CN";f.lang={source:"HTML\u4ee3\u7801",undo:"\u540e\u9000(Ctrl+Z)",redo:"\u524d\u8fdb(Ctrl+Y)",cut:"\u526a\u5207(Ctrl+X)",copy:"\u590d\u5236(Ctrl+C)",paste:"\u7c98\u8d34(Ctrl+V)",plainpaste:"\u7c98\u8d34\u4e3a\u65e0\u683c\u5f0f\u6587\u672c",wordpaste:"\u4eceWord\u7c98\u8d34",selectall:"\u5168\u9009",justifyleft:"\u5de6\u5bf9\u9f50",justifycenter:"\u5c45\u4e2d",justifyright:"\u53f3\u5bf9\u9f50",justifyfull:"\u4e24\u7aef\u5bf9\u9f50",insertorderedlist:"\u7f16\u53f7",insertunorderedlist:"\u9879\u76ee\u7b26\u53f7",
|
112
|
+
indent:"\u589e\u52a0\u7f29\u8fdb",outdent:"\u51cf\u5c11\u7f29\u8fdb",subscript:"\u4e0b\u6807",superscript:"\u4e0a\u6807",title:"\u6807\u9898",fontname:"\u5b57\u4f53",fontsize:"\u6587\u5b57\u5927\u5c0f",textcolor:"\u6587\u5b57\u989c\u8272",bgcolor:"\u6587\u5b57\u80cc\u666f",bold:"\u7c97\u4f53(Ctrl+B)",italic:"\u659c\u4f53(Ctrl+I)",underline:"\u4e0b\u5212\u7ebf(Ctrl+U)",strikethrough:"\u5220\u9664\u7ebf",removeformat:"\u5220\u9664\u683c\u5f0f",image:"\u56fe\u7247",flash:"\u63d2\u5165Flash",media:"\u63d2\u5165\u591a\u5a92\u4f53",
|
113
|
+
table:"\u63d2\u5165\u8868\u683c",hr:"\u63d2\u5165\u6a2a\u7ebf",emoticons:"\u63d2\u5165\u8868\u60c5",link:"\u8d85\u7ea7\u94fe\u63a5",unlink:"\u53d6\u6d88\u8d85\u7ea7\u94fe\u63a5",fullscreen:"\u5168\u5c4f\u663e\u793a",about:"\u5173\u4e8e",print:"\u6253\u5370",fileManager:"\u6d4f\u89c8\u670d\u52a1\u5668",advtable:"\u8868\u683c",yes:"\u786e\u5b9a",no:"\u53d6\u6d88",close:"\u5173\u95ed",editImage:"\u56fe\u7247\u5c5e\u6027",deleteImage:"\u5220\u9664\u56fe\u7247",editLink:"\u8d85\u7ea7\u94fe\u63a5\u5c5e\u6027",
|
114
|
+
deleteLink:"\u53d6\u6d88\u8d85\u7ea7\u94fe\u63a5",tableprop:"\u8868\u683c\u5c5e\u6027",tableinsert:"\u63d2\u5165\u8868\u683c",tabledelete:"\u5220\u9664\u8868\u683c",tablecolinsertleft:"\u5de6\u4fa7\u63d2\u5165\u5217",tablecolinsertright:"\u53f3\u4fa7\u63d2\u5165\u5217",tablerowinsertabove:"\u4e0a\u65b9\u63d2\u5165\u884c",tablerowinsertbelow:"\u4e0b\u65b9\u63d2\u5165\u884c",tablecoldelete:"\u5220\u9664\u5217",tablerowdelete:"\u5220\u9664\u884c",noColor:"\u65e0\u989c\u8272",invalidImg:"\u8bf7\u8f93\u5165\u6709\u6548\u7684URL\u5730\u5740\u3002\n\u53ea\u5141\u8bb8jpg,gif,bmp,png\u683c\u5f0f\u3002",
|
115
|
+
invalidMedia:"\u8bf7\u8f93\u5165\u6709\u6548\u7684URL\u5730\u5740\u3002\n\u53ea\u5141\u8bb8swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb\u683c\u5f0f\u3002",invalidWidth:"\u5bbd\u5ea6\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",invalidHeight:"\u9ad8\u5ea6\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",invalidBorder:"\u8fb9\u6846\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",invalidUrl:"\u8bf7\u8f93\u5165\u6709\u6548\u7684URL\u5730\u5740\u3002",invalidRows:"\u884c\u6570\u4e3a\u5fc5\u9009\u9879\uff0c\u53ea\u5141\u8bb8\u8f93\u5165\u5927\u4e8e0\u7684\u6570\u5b57\u3002",
|
116
|
+
invalidCols:"\u5217\u6570\u4e3a\u5fc5\u9009\u9879\uff0c\u53ea\u5141\u8bb8\u8f93\u5165\u5927\u4e8e0\u7684\u6570\u5b57\u3002",invalidPadding:"\u8fb9\u8ddd\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",invalidSpacing:"\u95f4\u8ddd\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",invalidBorder:"\u8fb9\u6846\u5fc5\u987b\u4e3a\u6570\u5b57\u3002",pleaseInput:"\u8bf7\u8f93\u5165\u5185\u5bb9\u3002",invalidJson:"\u670d\u52a1\u5668\u53d1\u751f\u6545\u969c\u3002",cutError:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u526a\u5207\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u5feb\u6377\u952e(Ctrl+X)\u6765\u5b8c\u6210\u3002",
|
117
|
+
copyError:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u590d\u5236\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u5feb\u6377\u952e(Ctrl+C)\u6765\u5b8c\u6210\u3002",pasteError:"\u60a8\u7684\u6d4f\u89c8\u5668\u5b89\u5168\u8bbe\u7f6e\u4e0d\u5141\u8bb8\u4f7f\u7528\u7c98\u8d34\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528\u5feb\u6377\u952e(Ctrl+V)\u6765\u5b8c\u6210\u3002"};var d=f.lang.plugins={};d.about={version:f.version,title:"HTML\u53ef\u89c6\u5316\u7f16\u8f91\u5668"};d.plainpaste=
|
118
|
+
{comment:"\u8bf7\u4f7f\u7528\u5feb\u6377\u952e(Ctrl+V)\u628a\u5185\u5bb9\u7c98\u8d34\u5230\u4e0b\u9762\u7684\u65b9\u6846\u91cc\u3002"};d.wordpaste={comment:"\u8bf7\u4f7f\u7528\u5feb\u6377\u952e(Ctrl+V)\u628a\u5185\u5bb9\u7c98\u8d34\u5230\u4e0b\u9762\u7684\u65b9\u6846\u91cc\u3002"};d.link={url:"URL\u5730\u5740",linkType:"\u6253\u5f00\u7c7b\u578b",newWindow:"\u65b0\u7a97\u53e3",selfWindow:"\u5f53\u524d\u7a97\u53e3"};d.flash={url:"Flash\u5730\u5740",width:"\u5bbd\u5ea6",height:"\u9ad8\u5ea6"};d.media=
|
119
|
+
{url:"\u5a92\u4f53\u6587\u4ef6\u5730\u5740",width:"\u5bbd\u5ea6",height:"\u9ad8\u5ea6",autostart:"\u81ea\u52a8\u64ad\u653e"};d.image={remoteImage:"\u8fdc\u7a0b\u56fe\u7247",localImage:"\u672c\u5730\u4e0a\u4f20",remoteUrl:"\u56fe\u7247\u5730\u5740",localUrl:"\u56fe\u7247\u5730\u5740",size:"\u56fe\u7247\u5927\u5c0f",width:"\u5bbd",height:"\u9ad8",resetSize:"\u91cd\u7f6e\u5927\u5c0f",align:"\u5bf9\u9f50\u65b9\u5f0f",defaultAlign:"\u9ed8\u8ba4\u65b9\u5f0f",leftAlign:"\u5de6\u5bf9\u9f50",rightAlign:"\u53f3\u5bf9\u9f50",
|
120
|
+
imgTitle:"\u56fe\u7247\u8bf4\u660e",viewServer:"\u6d4f\u89c8..."};d.file_manager={emptyFolder:"\u7a7a\u6587\u4ef6\u5939",moveup:"\u79fb\u5230\u4e0a\u4e00\u7ea7\u6587\u4ef6\u5939",viewType:"\u663e\u793a\u65b9\u5f0f\uff1a",viewImage:"\u7f29\u7565\u56fe",listImage:"\u8be6\u7ec6\u4fe1\u606f",orderType:"\u6392\u5e8f\u65b9\u5f0f\uff1a",fileName:"\u540d\u79f0",fileSize:"\u5927\u5c0f",fileType:"\u7c7b\u578b"};d.advtable={cells:"\u5355\u5143\u683c\u6570",rows:"\u884c\u6570",cols:"\u5217\u6570",size:"\u8868\u683c\u5927\u5c0f",
|
121
|
+
width:"\u5bbd\u5ea6",height:"\u9ad8\u5ea6",percent:"%",px:"px",space:"\u8fb9\u8ddd\u95f4\u8ddd",padding:"\u8fb9\u8ddd",spacing:"\u95f4\u8ddd",align:"\u5bf9\u9f50\u65b9\u5f0f",alignDefault:"\u9ed8\u8ba4",alignLeft:"\u5de6\u5bf9\u9f50",alignCenter:"\u5c45\u4e2d",alignRight:"\u53f3\u5bf9\u9f50",border:"\u8868\u683c\u8fb9\u6846",borderWidth:"\u8fb9\u6846",borderColor:"\u989c\u8272",backgroundColor:"\u80cc\u666f\u989c\u8272"};d.title={h1:"\u6807\u9898 1",h2:"\u6807\u9898 2",h3:"\u6807\u9898 3",h4:"\u6807\u9898 4",
|
122
|
+
p:"\u6b63 \u6587"};d.fontname={fontName:{SimSun:"\u5b8b\u4f53",NSimSun:"\u65b0\u5b8b\u4f53",FangSong_GB2312:"\u4eff\u5b8b_GB2312",KaiTi_GB2312:"\u6977\u4f53_GB2312",SimHei:"\u9ed1\u4f53","Microsoft YaHei":"\u5fae\u8f6f\u96c5\u9ed1",Arial:"Arial","Arial Black":"Arial Black","Times New Roman":"Times New Roman","Courier New":"Courier New",Tahoma:"Tahoma",Verdana:"Verdana"}}})(KindEditor);
|
123
|
+
(function(f,d){f.plugin.about={click:function(a){f.util.selection(a);(new f.dialog({id:a,cmd:"about",file:"about.html",width:300,height:70,loadingMode:true,title:f.lang.about,noButton:f.lang.close})).show()}};f.plugin.undo={init:function(a){f.event.ctrl(f.g[a].iframeDoc,"Z",function(){f.plugin.undo.click(a);f.util.focus(a)},a);f.event.ctrl(f.g[a].newTextarea,"Z",function(){f.plugin.undo.click(a);f.util.focus(a)},a)},click:function(a){f.history.undo(a);f.util.execOnchangeHandler(a)}};f.plugin.redo=
|
124
|
+
{init:function(a){f.event.ctrl(f.g[a].iframeDoc,"Y",function(){f.plugin.redo.click(a);f.util.focus(a)},a);f.event.ctrl(f.g[a].newTextarea,"Y",function(){f.plugin.redo.click(a);f.util.focus(a)},a)},click:function(a){f.history.redo(a);f.util.execOnchangeHandler(a)}};f.plugin.cut={click:function(a){try{if(!f.g[a].iframeDoc.queryCommandSupported("cut"))throw"e";}catch(b){alert(f.lang.cutError);return}f.util.execCommand(a,"cut",null)}};f.plugin.copy={click:function(a){try{if(!f.g[a].iframeDoc.queryCommandSupported("copy"))throw"e";
|
125
|
+
}catch(b){alert(f.lang.copyError);return}f.util.execCommand(a,"copy",null)}};f.plugin.paste={click:function(a){try{if(!f.g[a].iframeDoc.queryCommandSupported("paste"))throw"e";}catch(b){alert(f.lang.pasteError);return}f.util.execCommand(a,"paste",null)}};f.plugin.plainpaste={click:function(a){f.util.selection(a);this.dialog=new f.dialog({id:a,cmd:"plainpaste",file:"plainpaste.html",width:450,height:300,loadingMode:true,title:f.lang.plainpaste,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},
|
126
|
+
exec:function(a){var b=f.util.getIframeDoc(this.dialog.iframe);b=f.$("textArea",b).value;b=f.util.escape(b);b=b.replace(/ /g," ");b=b.replace(/\r\n|\n|\r/g,"<br />$&");f.util.insertHtml(a,b);this.dialog.hide();f.util.focus(a)}};f.plugin.wordpaste={click:function(a){f.util.selection(a);this.dialog=new f.dialog({id:a,cmd:"wordpaste",file:"wordpaste.html",width:450,height:300,loadingMode:true,title:f.lang.wordpaste,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},exec:function(a){var b=
|
127
|
+
f.util.getIframeDoc(this.dialog.iframe);b=f.$("wordIframe",b);b=f.util.getIframeDoc(b).body.innerHTML;b=b.replace(/<meta(\n|.)*?>/ig,"");b=b.replace(/<!(\n|.)*?>/ig,"");b=b.replace(/<style[^>]*>(\n|.)*?<\/style>/ig,"");b=b.replace(/<script[^>]*>(\n|.)*?<\/script>/ig,"");b=b.replace(/<w:[^>]+>(\n|.)*?<\/w:[^>]+>/ig,"");b=b.replace(/<xml>(\n|.)*?<\/xml>/ig,"");b=b.replace(/\r\n|\n|\r/ig,"");b=f.util.execGetHtmlHooks(a,b);b=f.format.getHtml(b,f.g[a].htmlTags,f.g[a].urlType);f.util.insertHtml(a,b);this.dialog.hide();
|
128
|
+
f.util.focus(a)}};f.plugin.fullscreen={click:function(a){var b=f.g[a],c=this,e=function(){var k=f.util.getDocumentElement();b.width=k.clientWidth+"px";b.height=k.clientHeight+"px"},g="",h=function(){if(c.isSelected){var k=f.util.getDocumentElement();k=[k.clientWidth,k.clientHeight].join("");if(g!=k){g=k;e();f.util.resize(a,b.width,b.height)}}};if(this.isSelected){this.isSelected=false;f.util.setData(a);f.remove(a,1);b.width=this.width;b.height=this.height;f.create(a,2);document.body.parentNode.style.overflow=
|
129
|
+
"auto";f.event.remove(window,"resize",h);b.resizeMode=b.config.resizeMode;f.toolbar.unselect(a,"fullscreen")}else{this.isSelected=true;this.width=b.container.style.width;this.height=b.container.style.height;f.util.setData(a);f.remove(a,2);document.body.parentNode.style.overflow="hidden";e();f.create(a,1);var i=f.util.getScrollPos(),j=b.container;j.style.position="absolute";j.style.left=i.x+"px";j.style.top=i.y+"px";j.style.zIndex=19811211;f.event.add(window,"resize",h);b.resizeMode=0;f.toolbar.select(a,
|
130
|
+
"fullscreen")}}};f.plugin.bgcolor={click:function(a){f.util.selection(a);var b=f.queryCommandValue(f.g[a].iframeDoc,"bgcolor");this.menu=new f.menu({id:a,cmd:"bgcolor"});this.menu.picker(b)},exec:function(a,b){var c=new f.cmd(a);b==""?c.remove({span:[".background-color"]}):c.wrap("span",[{".background-color":b}]);f.util.execOnchangeHandler(a);this.menu.hide();f.util.focus(a)}};f.plugin.fontname={click:function(a){var b=f.lang.plugins.fontname.fontName;f.util.selection(a);var c=new f.menu({id:a,cmd:"fontname",
|
131
|
+
width:150}),e=f.queryCommandValue(f.g[a].iframeDoc,"fontname");f.each(b,function(g,h){c.add('<span class="ke-reset" style="font-family: '+g+';">'+h+"</span>",function(){f.plugin.fontname.exec(a,g)},{checked:e===g.toLowerCase()||e===h.toLowerCase()})});c.show();this.menu=c},exec:function(a,b){(new f.cmd(a)).wrap("span",[{".font-family":b}]);f.util.execOnchangeHandler(a);this.menu.hide();f.util.focus(a)}};f.plugin.fontsize={click:function(a){var b=["9px","10px","12px","14px","16px","18px","24px","32px"];
|
132
|
+
f.util.selection(a);for(var c=f.queryCommandValue(f.g[a].iframeDoc,"fontsize"),e=new f.menu({id:a,cmd:"fontsize",width:120}),g=0,h=b.length;g<h;g++){var i=b[g];e.add('<span class="ke-reset" style="font-size: '+i+';">'+i+"</span>",function(j){return function(){f.plugin.fontsize.exec(a,j)}}(i),{height:parseInt(i)+12+"px",checked:c===i})}e.show();this.menu=e},exec:function(a,b){(new f.cmd(a)).wrap("span",[{".font-size":b}]);f.util.execOnchangeHandler(a);this.menu.hide();f.util.focus(a)}};f.plugin.hr=
|
133
|
+
{click:function(a){f.util.selection(a);f.util.insertHtml(a,"<hr />");f.util.focus(a)}};f.plugin.print={click:function(a){f.util.selection(a);f.g[a].iframeWin.print()}};f.plugin.removeformat={click:function(a){f.util.selection(a);for(var b=new f.cmd(a),c={"*":["class","style"]},e=0,g=f.g[a].inlineTags.length;e<g;e++)c[f.g[a].inlineTags[e]]=["*"];b.remove(c);f.util.execOnchangeHandler(a);f.toolbar.updateState(a);f.util.focus(a)}};f.plugin.source={click:function(a){var b=f.g[a];if(b.wyswygMode){f.hideMenu(a);
|
134
|
+
b.newTextarea.value=f.util.getData(a);b.iframe.style.display="none";b.newTextarea.style.display="block";f.toolbar.disable(a,["source","fullscreen"]);b.wyswygMode=false;this.isSelected=true;f.toolbar.select(a,"source")}else{f.util.setFullHtml(a,b.newTextarea.value);b.iframe.style.display="block";b.newTextarea.style.display="none";f.toolbar.able(a,["source","fullscreen"]);b.wyswygMode=true;this.isSelected=false;f.toolbar.unselect(a,"source")}f.util.focus(a)}};f.plugin.textcolor={click:function(a){f.util.selection(a);
|
135
|
+
var b=f.queryCommandValue(f.g[a].iframeDoc,"textcolor");this.menu=new f.menu({id:a,cmd:"textcolor"});this.menu.picker(b)},exec:function(a,b){var c=new f.cmd(a);b==""?c.remove({span:[".color"],font:["color"]}):c.wrap("span",[{".color":b}]);f.util.execOnchangeHandler(a);this.menu.hide();f.util.focus(a)}};f.plugin.title={click:function(a){var b=f.lang.plugins.title;b={H1:b.h1,H2:b.h2,H3:b.h3,H4:b.h4,P:b.p};var c={H1:28,H2:24,H3:18,H4:14,P:12};f.util.selection(a);var e=f.queryCommandValue(f.g[a].iframeDoc,
|
136
|
+
"formatblock"),g=new f.menu({id:a,cmd:"title",width:f.langType=="en"?200:150});f.each(b,function(h,i){var j="font-size:"+c[h]+"px;";if(h!=="P")j+="font-weight:bold;";g.add('<span class="ke-reset" style="'+j+'">'+i+"</span>",function(){f.plugin.title.exec(a,"<"+h+">")},{height:c[h]+12+"px",checked:e===h.toLowerCase()||e===i.toLowerCase()})});g.show();this.menu=g},exec:function(a,b){f.util.select(a);f.util.execCommand(a,"formatblock",b);this.menu.hide();f.util.focus(a)}};f.plugin.emoticons={click:function(a){function b(v){var t=
|
137
|
+
f.$$("table");if(q){t.onmouseover=function(){q.style.display="block"};t.onmouseout=function(){q.style.display="none"}}t.className="ke-plugin-emoticons-table";t.cellPadding=0;t.cellSpacing=0;t.border=0;v=(v-1)*j+i;for(var x=0;x<g;x++)for(var w=t.insertRow(x),y=0;y<h;y++){var s=w.insertCell(y);s.className="ke-plugin-emoticons-cell";s.onmouseover=q?function(A,B){return function(){if(A>l){q.style.left=0;q.style.right=""}else{q.style.left="";q.style.right=0}r.src=p+B+".gif";this.className="ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on"}}(y,
|
138
|
+
v):function(){this.className="ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on"};s.onmouseout=function(){this.className="ke-plugin-emoticons-cell"};s.onclick=function(A){return function(){e.exec(a,A);return false}}(v);var z=f.$$("span");z.className="ke-plugin-emoticons-img";z.style.backgroundPosition="-"+24*v+"px 0px";s.appendChild(z);v++}return t}function c(v){for(var t=1;t<=k;t++){if(v!==t){var x=f.$$("a");x.href="javascript:;";x.innerHTML="["+t+"]";x.onclick=function(w){return function(){o.removeChild(u);
|
139
|
+
var y=b(w);o.insertBefore(y,n);u=y;n.innerHTML="";c(w);return false}}(t);n.appendChild(x)}else n.appendChild(document.createTextNode("["+t+"]"));n.appendChild(document.createTextNode(" "))}}var e=this,g=5,h=9,i=0,j=g*h,k=Math.ceil(135/j),l=Math.floor(h/2),m=f.g[a],p=m.pluginsPath+"emoticons/";m=m.allowPreviewEmoticons===d?true:m.allowPreviewEmoticons;f.util.selection(a);var o=f.$$("div");o.className="ke-plugin-emoticons-wrapper";var q,r;if(m){q=f.$$("div");q.className="ke-plugin-emoticons-preview";
|
140
|
+
q.style.right=0;r=f.$$("img");r.className="ke-reset";r.src=p+"0.gif";r.border=0;q.appendChild(r);o.appendChild(q)}var u=b(1);o.appendChild(u);var n=f.$$("div");n.className="ke-plugin-emoticons-page";o.appendChild(n);c(1);m=new f.menu({id:a,cmd:"emoticons"});m.append(o);m.show();this.menu=m},exec:function(a,b){var c=f.g[a].pluginsPath+"emoticons/"+b+".gif";f.util.insertHtml(a,'<img src="'+c+'" kesrc="'+c+'" border="0" alt="" />');this.menu.hide();f.util.focus(a)}};f.plugin.flash={init:function(a){f.g[a].getHtmlHooks.push(function(b){return b.replace(/<img[^>]*class="?ke-flash"?[^>]*>/ig,
|
141
|
+
function(c){var e=c.match(/style="[^"]*;?\s*width:\s*(\d+)/i)?RegExp.$1:0,g=c.match(/style="[^"]*;?\s*height:\s*(\d+)/i)?RegExp.$1:0;e=e||(c.match(/width="([^"]+)"/i)?RegExp.$1:0);g=g||(c.match(/height="([^"]+)"/i)?RegExp.$1:0);if(c.match(/kesrctag="([^"]+)"/i)){c=f.util.getAttrList(unescape(RegExp.$1));c.width=e||c.width||0;c.height=g||c.height||0;c.kesrc=c.src;return f.util.getMediaEmbed(c)}})});f.g[a].setHtmlHooks.push(function(b){return b.replace(/<embed[^>]*type="application\/x-shockwave-flash"[^>]*>(?:<\/embed>)?/ig,
|
142
|
+
function(c){var e=c.match(/\s+src="([^"]+)"/i)?RegExp.$1:"";if(c.match(/\s+kesrc="([^"]+)"/i))e=RegExp.$1;var g=c.match(/\s+width="([^"]+)"/i)?RegExp.$1:0,h=c.match(/\s+height="([^"]+)"/i)?RegExp.$1:0;c=f.util.getAttrList(c);c.src=e;c.width=g;c.height=h;return f.util.getMediaImage(a,"flash",c)})})},click:function(a){f.util.selection(a);this.dialog=new f.dialog({id:a,cmd:"flash",file:"flash.html",width:400,height:140,loadingMode:true,title:f.lang.flash,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},
|
143
|
+
check:function(a,b,c,e){a=f.util.getIframeDoc(this.dialog.iframe);if(!b.match(/^.{3,}$/)){alert(f.lang.invalidUrl);f.$("url",a).focus();return false}if(!c.match(/^\d*$/)){alert(f.lang.invalidWidth);f.$("width",a).focus();return false}if(!e.match(/^\d*$/)){alert(f.lang.invalidHeight);f.$("height",a).focus();return false}return true},exec:function(a){var b=f.util.getIframeDoc(this.dialog.iframe),c=f.$("url",b).value,e=f.$("width",b).value;b=f.$("height",b).value;if(!this.check(a,c,e,b))return false;
|
144
|
+
c=f.util.getMediaImage(a,"flash",{src:c,type:f.g[a].mediaTypes.flash,width:e,height:b,quality:"high"});f.util.insertHtml(a,c);this.dialog.hide();f.util.focus(a)}};f.plugin.image={getSelectedNode:function(a){a=f.g[a];var b=a.keRange.startNode,c=a.keRange.endNode;if(f.browser.WEBKIT||a.keSel.isControl)if(b.nodeType==1)if(b.tagName.toLowerCase()=="img")if(b==c)if(!b.className.match(/^ke-\w+/i))return b},init:function(a){var b=this;a=f.g[a];a.contextmenuItems.push({text:f.lang.editImage,click:function(c,
|
145
|
+
e){f.util.select(c);e.hide();b.click(c)},cond:function(c){return b.getSelectedNode(c)},options:{width:"150px",iconHtml:'<span class="ke-common-icon ke-common-icon-url ke-icon-image"></span>'}});a.contextmenuItems.push({text:f.lang.deleteImage,click:function(c,e){f.util.select(c);e.hide();var g=b.getSelectedNode(c);g.parentNode.removeChild(g);f.util.execOnchangeHandler(c)},cond:function(c){return b.getSelectedNode(c)},options:{width:"150px"}});a.contextmenuItems.push("-")},click:function(a){f.util.selection(a);
|
146
|
+
this.dialog=new f.dialog({id:a,cmd:"image",file:"image/image.html",width:400,height:220,loadingMode:true,title:f.lang.image,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},check:function(){var a=f.util.getIframeDoc(this.dialog.iframe),b=f.$("type",a).value,c=f.$("imgWidth",a).value,e=f.$("imgHeight",a).value;f.$("imgTitle",a);b=b==2?f.$("imgFile",a):f.$("url",a);if(!b.value.match(/\.(jpg|jpeg|gif|bmp|png)(\s|\?|$)/i)){alert(f.lang.invalidImg);b.focus();return false}if(!c.match(/^\d*$/)){alert(f.lang.invalidWidth);
|
147
|
+
f.$("imgWidth",a).focus();return false}if(!e.match(/^\d*$/)){alert(f.lang.invalidHeight);f.$("imgHeight",a).focus();return false}return true},exec:function(a){for(var b=this,c=f.util.getIframeDoc(this.dialog.iframe),e=f.$("type",c).value,g=f.$("imgWidth",c).value,h=f.$("imgHeight",c).value,i=f.$("imgTitle",c).value,j=c.getElementsByName("align"),k="",l=0,m=j.length;l<m;l++)if(j[l].checked){k=j[l].value;break}if(!this.check(a))return false;if(e==2){f.$("editorId",c).value=a;var p=f.$("uploadIframe",
|
148
|
+
c);f.util.showLoadingPage(a);var o=function(){f.event.remove(p,"load",o);f.util.hideLoadingPage(a);var q=f.util.getIframeDoc(p),r="";try{r=f.util.parseJson(q.body.innerHTML)}catch(u){alert(f.lang.invalidJson)}if(typeof r==="object"&&"error"in r)if(r.error===0)b.insert(a,r.url,i,g,h,0,k);else{alert(r.message);return false}};f.event.add(p,"load",o);c.uploadForm.submit()}else{c=f.$("url",c).value;this.insert(a,c,i,g,h,0,k)}},insert:function(a,b,c,e,g,h,i){b='<img src="'+b+'" kesrc="'+b+'" ';if(e>0)b+=
|
149
|
+
'width="'+e+'" ';if(g>0)b+='height="'+g+'" ';if(c)b+='title="'+c+'" ';if(i)b+='align="'+i+'" ';b+='alt="'+c+'" ';b+='border="'+h+'" />';f.util.insertHtml(a,b);this.dialog.hide();f.util.focus(a)}};f.plugin.link={getSelectedNode:function(a){return f.getCommonAncestor(f.g[a].keSel,"a")},init:function(a){var b=this;f.g[a].contextmenuItems.push({text:f.lang.editLink,click:function(c,e){f.util.select(c);e.hide();b.click(c)},cond:function(c){return b.getSelectedNode(c)},options:{width:"150px",iconHtml:'<span class="ke-common-icon ke-common-icon-url ke-icon-link"></span>'}})},
|
150
|
+
click:function(a){f.util.selection(a);this.dialog=new f.dialog({id:a,cmd:"link",file:"link/link.html",width:400,height:90,loadingMode:true,title:f.lang.link,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},exec:function(a){var b=f.g[a];f.util.select(a);var c=b.keRange,e=c.startNode,g=c.endNode,h=b.iframeDoc,i=f.util.getIframeDoc(this.dialog.iframe),j=f.$("hyperLink",i).value,k=f.$("linkType",i).value;if(!j.match(/.+/)||j.match(/^\w+:\/\/\/?$/)){alert(f.lang.invalidUrl);f.$("hyperLink",
|
151
|
+
i).focus();return false}for(i=c.getParentElement();i;){if(i.tagName.toLowerCase()=="a"||i.tagName.toLowerCase()=="body")break;i=i.parentNode}i=i.parentNode;g=f.browser.IE?!!b.range.item:e.nodeType==1&&e===g&&e.nodeName.toLowerCase()!="br";var l=!g;g||(l=f.browser.IE?b.range.text==="":b.range.toString()==="");if(l||f.util.isEmpty(a)){b='<a href="'+j+'"';if(k)b+=' target="'+k+'"';b+=">"+j+"</a>";f.util.insertHtml(a,b)}else{h.execCommand("createlink",false,"__ke_temp_url__");i=i.getElementsByTagName("a");
|
152
|
+
l=0;for(var m=i.length;l<m;l++)if(i[l].href.match(/\/?__ke_temp_url__$/)){i[l].href=j;i[l].setAttribute("kesrc",j);if(k)i[l].target=k;else i[l].removeAttribute("target")}if(f.browser.WEBKIT&&g&&e.tagName.toLowerCase()=="img"){g=e.parentNode;if(g.tagName.toLowerCase()!="a"){h=f.$$("a",h);g.insertBefore(h,e);h.appendChild(e);g=h}g.href=j;g.setAttribute("kesrc",j);if(k)g.target=k;else g.removeAttribute("target");b.keSel.addRange(c)}}f.util.execOnchangeHandler(a);this.dialog.hide();f.util.focus(a)}};
|
153
|
+
f.plugin.unlink={init:function(a){var b=this;f.g[a].contextmenuItems.push({text:f.lang.deleteLink,click:function(c,e){f.util.select(c);e.hide();b.click(c)},cond:function(c){return f.plugin.link.getSelectedNode(c)},options:{width:"150px",iconHtml:'<span class="ke-common-icon ke-common-icon-url ke-icon-unlink"></span>'}});f.g[a].contextmenuItems.push("-")},click:function(a){var b=f.g[a],c=b.iframeDoc;f.util.selection(a);var e=b.keRange,g=e.startNode;e=e.endNode;e=g.nodeType==1&&g===e;var h=!e;e||(h=
|
154
|
+
f.browser.IE?b.range.text==="":b.range.toString()==="");if(h){h=f.plugin.link.getSelectedNode(a);if(!h)return;e=b.keRange;e.selectTextNode(h);b.keSel.addRange(e);f.util.select(a);c.execCommand("unlink",false,null);if(f.browser.WEBKIT&&g.tagName.toLowerCase()=="img"){c=g.parentNode;if(c.tagName.toLowerCase()=="a"){f.util.removeParent(c);b.keSel.addRange(e)}}}else c.execCommand("unlink",false,null);f.util.execOnchangeHandler(a);f.toolbar.updateState(a);f.util.focus(a)}};f.plugin.media={init:function(a){var b=
|
155
|
+
{};f.each(f.g[a].mediaTypes,function(c,e){b[e]=c});f.g[a].getHtmlHooks.push(function(c){return c.replace(/<img[^>]*class="?ke-\w+"?[^>]*>/ig,function(e){var g=e.match(/style="[^"]*;?\s*width:\s*(\d+)/i)?RegExp.$1:0,h=e.match(/style="[^"]*;?\s*height:\s*(\d+)/i)?RegExp.$1:0;g=g||(e.match(/width="([^"]+)"/i)?RegExp.$1:0);h=h||(e.match(/height="([^"]+)"/i)?RegExp.$1:0);if(e.match(/\s+kesrctag="([^"]+)"/i)){e=f.util.getAttrList(unescape(RegExp.$1));e.width=g||e.width||0;e.height=h||e.height||0;e.kesrc=
|
156
|
+
e.src;return f.util.getMediaEmbed(e)}})});f.g[a].setHtmlHooks.push(function(c){return c.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig,function(e,g){if(typeof b[g]=="undefined")return e;var h=e.match(/\s+src="([^"]+)"/i)?RegExp.$1:"";if(e.match(/\s+kesrc="([^"]+)"/i))h=RegExp.$1;var i=e.match(/\s+width="([^"]+)"/i)?RegExp.$1:0,j=e.match(/\s+height="([^"]+)"/i)?RegExp.$1:0,k=f.util.getAttrList(e);k.src=h;k.width=i;k.height=j;return f.util.getMediaImage(a,"",k)})})},click:function(a){f.util.selection(a);
|
157
|
+
this.dialog=new f.dialog({id:a,cmd:"media",file:"media.html",width:400,height:170,loadingMode:true,title:f.lang.media,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},check:function(a,b,c,e){a=f.util.getIframeDoc(this.dialog.iframe);if(!b.match(/^.{3,}\.(swf|flv|mp3|wav|wma|wmv|mid|avi|mpg|mpeg|asf|rm|rmvb)(\?|$)/i)){alert(f.lang.invalidMedia);f.$("url",a).focus();return false}if(!c.match(/^\d*$/)){alert(f.lang.invalidWidth);f.$("width",a).focus();return false}if(!e.match(/^\d*$/)){alert(f.lang.invalidHeight);
|
158
|
+
f.$("height",a).focus();return false}return true},exec:function(a){var b=f.util.getIframeDoc(this.dialog.iframe),c=f.$("url",b).value,e=f.$("width",b).value,g=f.$("height",b).value;if(!this.check(a,c,e,g))return false;b=f.$("autostart",b).checked?"true":"false";c=f.util.getMediaImage(a,"",{src:c,type:f.g[a].mediaTypes[f.util.getMediaType(c)],width:e,height:g,autostart:b,loop:"true"});f.util.insertHtml(a,c);this.dialog.hide();f.util.focus(a)}};f.plugin.advtable={getSelectedTable:function(a){return f.getCommonAncestor(f.g[a].keSel,
|
159
|
+
"table")},getSelectedRow:function(a){return f.getCommonAncestor(f.g[a].keSel,"tr")},getSelectedCell:function(a){return f.getCommonAncestor(f.g[a].keSel,"td")},tableprop:function(a){this.click(a)},tableinsert:function(a){this.click(a,"insert")},tabledelete:function(a){a=this.getSelectedTable(a);a.parentNode.removeChild(a)},tablecolinsert:function(a,b){for(var c=this.getSelectedTable(a),e=this.getSelectedCell(a).cellIndex+b,g=0,h=c.rows.length;g<h;g++)c.rows[g].insertCell(e).innerHTML=" "},tablecolinsertleft:function(a){this.tablecolinsert(a,
|
160
|
+
0)},tablecolinsertright:function(a){this.tablecolinsert(a,1)},tablerowinsert:function(a,b){var c=this.getSelectedTable(a),e=this.getSelectedRow(a);c=c.insertRow(e.rowIndex+b);var g=0;for(e=e.cells.length;g<e;g++)c.insertCell(g).innerHTML=" "},tablerowinsertabove:function(a){this.tablerowinsert(a,0)},tablerowinsertbelow:function(a){this.tablerowinsert(a,1)},tablecoldelete:function(a){var b=this.getSelectedTable(a);a=this.getSelectedCell(a);for(var c=0,e=b.rows.length;c<e;c++)b.rows[c].deleteCell(a.cellIndex)},
|
161
|
+
tablerowdelete:function(a){var b=this.getSelectedTable(a);a=this.getSelectedRow(a);b.deleteRow(a.rowIndex)},init:function(a){for(var b=this,c="prop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,coldelete,rowdelete,insert,delete".split(","),e=0,g=c.length;e<g;e++){var h="table"+c[e];f.g[a].contextmenuItems.push({text:f.lang[h],click:function(i){return function(j,k){f.util.select(j);k.hide();b[i]!==d&&b[i](j);/prop/.test(i)||f.util.execOnchangeHandler(j)}}(h),cond:function(i){return f.util.inArray(i,
|
162
|
+
["tableprop","tabledelete"])?function(j){return b.getSelectedTable(j)}:function(j){return b.getSelectedCell(j)}}(h),options:{width:"170px",iconHtml:'<span class="ke-common-icon ke-common-icon-url ke-icon-'+h+'"></span>'}})}f.g[a].contextmenuItems.push("-");f.g[a].setHtmlHooks.push(function(i){return i.replace(/<table([^>]*)>/ig,function(j,k){if(k.match(/\s+border=["']?(\d*)["']?/ig)){var l=RegExp.$1;return k.indexOf("ke-zeroborder")<0&&(l===""||l==="0")?f.addClass(j,"ke-zeroborder"):j}else return f.addClass(j,
|
163
|
+
"ke-zeroborder")})})},click:function(a,b){b=b||"default";f.util.selection(a);this.dialog=new f.dialog({id:a,cmd:"advtable",file:"advtable/advtable.html?mode="+b,width:420,height:220,loadingMode:true,title:f.lang.advtable,yesButton:f.lang.yes,noButton:f.lang.no});this.dialog.show()},exec:function(a){var b=f.util.getIframeDoc(this.dialog.iframe),c=f.$("mode",b),e=f.$("rows",b),g=f.$("cols",b),h=f.$("width",b),i=f.$("height",b),j=f.$("widthType",b),k=f.$("heightType",b),l=f.$("padding",b),m=f.$("spacing",
|
164
|
+
b),p=f.$("align",b),o=f.$("border",b),q=f.$("borderColor",b),r=f.$("backgroundColor",b);b=e.value;var u=g.value,n=h.value,v=i.value;j=j.value;var t=k.value;k=l.value;var x=m.value;p=p.value;var w=o.value;q=q.innerHTML;r=r.innerHTML;if(b==""||b==0||!b.match(/^\d*$/)){alert(f.lang.invalidRows);e.focus();return false}if(u==""||u==0||!u.match(/^\d*$/)){alert(f.lang.invalidCols);g.focus();return false}if(!n.match(/^\d*$/)){alert(f.lang.invalidWidth);h.focus();return false}if(!v.match(/^\d*$/)){alert(f.lang.invalidHeight);
|
165
|
+
i.focus();return false}if(!k.match(/^\d*$/)){alert(f.lang.invalidPadding);l.focus();return false}if(!x.match(/^\d*$/)){alert(f.lang.invalidSpacing);m.focus();return false}if(!w.match(/^\d*$/)){alert(f.lang.invalidBorder);o.focus();return false}if(c.value==="update"){b=this.getSelectedTable(a);if(n!=="")b.style.width=n+j;else if(b.style.width)b.style.width="";b.width!==d&&b.removeAttribute("width");if(v!=="")b.style.height=v+t;else if(b.style.height)b.style.height="";b.height!==d&&b.removeAttribute("height");
|
166
|
+
if(r!=="")b.style.backgroundColor=r;else if(b.style.backgroundColor)b.style.backgroundColor="";b.bgColor!==d&&b.removeAttribute("bgColor");if(k!=="")b.cellPadding=k;else b.removeAttribute("cellPadding");if(x!=="")b.cellSpacing=x;else b.removeAttribute("cellSpacing");if(p!=="")b.align=p;else b.removeAttribute("align");w===""||w==="0"?f.addClass(b,"ke-zeroborder"):f.removeClass(b,"ke-zeroborder");w!==""?b.setAttribute("border",w):b.removeAttribute("border");q!==""?b.setAttribute("borderColor",q):b.removeAttribute("borderColor");
|
167
|
+
f.util.execOnchangeHandler(a)}else{c="";if(n!=="")c+="width:"+n+j+";";if(v!=="")c+="height:"+v+t+";";if(r!=="")c+="background-color:"+r+";";n="<table";if(c!=="")n+=' style="'+c+'"';if(k!=="")n+=' cellpadding="'+k+'"';if(x!=="")n+=' cellspacing="'+x+'"';if(p!=="")n+=' align="'+p+'"';if(w===""||w==="0")n+=' class="ke-zeroborder"';if(w!=="")n+=' border="'+w+'"';if(q!=="")n+=' bordercolor="'+q+'"';n+=">";for(v=0;v<b;v++){n+="<tr>";for(c=0;c<u;c++)n+="<td> </td>";n+="</tr>"}n+="</table>";f.util.insertHtml(a,
|
168
|
+
n)}this.dialog.hide();f.util.focus(a)}}})(KindEditor);
|
@@ -0,0 +1,4442 @@
|
|
1
|
+
/*******************************************************************************
|
2
|
+
* KindEditor - WYSIWYG HTML Editor for Internet
|
3
|
+
* Copyright (C) 2006-2010 Longhao Luo
|
4
|
+
*
|
5
|
+
* @author Roddy <luolonghao@gmail.com>
|
6
|
+
* @site http://www.kindsoft.net/
|
7
|
+
* @licence LGPL(http://www.opensource.org/licenses/lgpl-license.php)
|
8
|
+
* @version 3.5.1 (2010-07-18)
|
9
|
+
*******************************************************************************/
|
10
|
+
|
11
|
+
(function (undefined) {
|
12
|
+
|
13
|
+
var KE = {};
|
14
|
+
|
15
|
+
KE.version = '3.5.1 (2010-07-18)';
|
16
|
+
|
17
|
+
KE.scriptPath = (function() {
|
18
|
+
var elements = document.getElementsByTagName('script');
|
19
|
+
for (var i = 0, len = elements.length; i < len; i++) {
|
20
|
+
if (elements[i].src && elements[i].src.match(/kindeditor[\w\-\.]*\.js/)) {
|
21
|
+
return elements[i].src.substring(0, elements[i].src.lastIndexOf('/') + 1);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return '';
|
25
|
+
})();
|
26
|
+
|
27
|
+
KE.browser = (function() {
|
28
|
+
var ua = navigator.userAgent.toLowerCase();
|
29
|
+
return {
|
30
|
+
VERSION: ua.match(/(msie|firefox|webkit|opera)[\/:\s](\d+)/) ? RegExp.$2 : '0',
|
31
|
+
IE: (ua.indexOf('msie') > -1 && ua.indexOf('opera') == -1),
|
32
|
+
GECKO: (ua.indexOf('gecko') > -1 && ua.indexOf('khtml') == -1),
|
33
|
+
WEBKIT: (ua.indexOf('applewebkit') > -1),
|
34
|
+
OPERA: (ua.indexOf('opera') > -1)
|
35
|
+
};
|
36
|
+
})();
|
37
|
+
|
38
|
+
KE.setting = {
|
39
|
+
wyswygMode : true,
|
40
|
+
loadStyleMode : true,
|
41
|
+
resizeMode : 2,
|
42
|
+
filterMode : false,
|
43
|
+
autoSetDataMode : true,
|
44
|
+
shadowMode : true,
|
45
|
+
urlType : '',
|
46
|
+
skinType : 'default',
|
47
|
+
newlineTag : 'p',
|
48
|
+
dialogAlignType : 'page',
|
49
|
+
cssPath : '',
|
50
|
+
skinsPath : KE.scriptPath === '' ? '' : KE.scriptPath + 'skins/',
|
51
|
+
pluginsPath : KE.scriptPath === '' ? '' : KE.scriptPath + 'plugins/',
|
52
|
+
minWidth : 200,
|
53
|
+
minHeight : 100,
|
54
|
+
minChangeSize : 5,
|
55
|
+
toolbarLineHeight : 24,
|
56
|
+
statusbarHeight : 11,
|
57
|
+
items : [
|
58
|
+
'source', '|', 'fullscreen', 'undo', 'redo', 'print', 'cut', 'copy', 'paste',
|
59
|
+
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
|
60
|
+
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
61
|
+
'superscript', '|', 'selectall', '-',
|
62
|
+
'title', 'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold',
|
63
|
+
'italic', 'underline', 'strikethrough', 'removeformat', '|', 'image',
|
64
|
+
'flash', 'media', 'advtable', 'hr', 'emoticons', 'link', 'unlink', '|', 'about'
|
65
|
+
],
|
66
|
+
colorTable : [
|
67
|
+
['#E53333', '#E56600', '#FF9900', '#64451D', '#DFC5A4', '#FFE500'],
|
68
|
+
['#009900', '#006600', '#99BB00', '#B8D100', '#60D978', '#00D5FF'],
|
69
|
+
['#337FE5', '#003399', '#4C33E5', '#9933E5', '#CC33E5', '#EE33EE'],
|
70
|
+
['#FFFFFF', '#CCCCCC', '#999999', '#666666', '#333333', '#000000']
|
71
|
+
],
|
72
|
+
noEndTags : ['br', 'hr', 'img', 'area', 'col', 'embed', 'input', 'param'],
|
73
|
+
inlineTags : ['b', 'del', 'em', 'font', 'i', 'span', 'strike', 'strong', 'sub', 'sup', 'u'],
|
74
|
+
endlineTags : [
|
75
|
+
'br', 'hr', 'table', 'tbody', 'td', 'tr', 'th', 'div', 'p', 'ol', 'ul',
|
76
|
+
'li', 'blockquote', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'script', 'style', 'marquee'
|
77
|
+
],
|
78
|
+
htmlTags : {
|
79
|
+
font : ['color', 'size', 'face', '.background-color'],
|
80
|
+
span : [
|
81
|
+
'.color', '.background-color', '.font-size', '.font-family', '.background',
|
82
|
+
'.font-weight', '.font-style', '.text-decoration', '.vertical-align'
|
83
|
+
],
|
84
|
+
div : [
|
85
|
+
'align', '.border', '.margin', '.padding', '.text-align', '.color',
|
86
|
+
'.background-color', '.font-size', '.font-family', '.font-weight', '.background',
|
87
|
+
'.font-style', '.text-decoration', '.vertical-align', '.margin-left'
|
88
|
+
],
|
89
|
+
table: [
|
90
|
+
'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
|
91
|
+
'.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
|
92
|
+
'.font-size', '.font-family', '.font-weight', '.font-style', '.text-decoration', '.background',
|
93
|
+
'.width', '.height'
|
94
|
+
],
|
95
|
+
'td,th': [
|
96
|
+
'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
|
97
|
+
'.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight',
|
98
|
+
'.font-style', '.text-decoration', '.vertical-align', '.background'
|
99
|
+
],
|
100
|
+
a : ['href', 'target', 'name'],
|
101
|
+
embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess', '/'],
|
102
|
+
img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height', '/'],
|
103
|
+
hr : ['/'],
|
104
|
+
br : ['/'],
|
105
|
+
'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
|
106
|
+
'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
|
107
|
+
'.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
|
108
|
+
],
|
109
|
+
'tbody,tr,strong,b,sub,sup,em,i,u,strike' : []
|
110
|
+
},
|
111
|
+
mediaTypes : {
|
112
|
+
rm : 'audio/x-pn-realaudio-plugin',
|
113
|
+
flash : 'application/x-shockwave-flash',
|
114
|
+
media : 'video/x-ms-asf-plugin'
|
115
|
+
}
|
116
|
+
};
|
117
|
+
|
118
|
+
KE.g = {};
|
119
|
+
|
120
|
+
KE.plugin = {};
|
121
|
+
|
122
|
+
KE.$ = function(id, doc){
|
123
|
+
var doc = doc || document;
|
124
|
+
return doc.getElementById(id);
|
125
|
+
};
|
126
|
+
|
127
|
+
KE.$$ = function(name, doc){
|
128
|
+
var doc = doc || document;
|
129
|
+
return doc.createElement(name);
|
130
|
+
};
|
131
|
+
|
132
|
+
KE.event = {
|
133
|
+
add : function(el, type, fn, id) {
|
134
|
+
if (el.addEventListener){
|
135
|
+
el.addEventListener(type, fn, false);
|
136
|
+
} else if (el.attachEvent){
|
137
|
+
el.attachEvent('on' + type, fn);
|
138
|
+
}
|
139
|
+
if (id !== undefined) {
|
140
|
+
KE.g[id].eventStack.push({
|
141
|
+
el : el,
|
142
|
+
type : type,
|
143
|
+
fn : fn
|
144
|
+
});
|
145
|
+
}
|
146
|
+
},
|
147
|
+
remove : function(el, type, fn, id) {
|
148
|
+
if (el.removeEventListener){
|
149
|
+
el.removeEventListener(type, fn, false);
|
150
|
+
} else if (el.detachEvent){
|
151
|
+
el.detachEvent('on' + type, fn);
|
152
|
+
}
|
153
|
+
if (id !== undefined) {
|
154
|
+
var stack = KE.g[id].eventStack;
|
155
|
+
for (var i = 0, len = stack.length; i < len; i++) {
|
156
|
+
var item = stack[i];
|
157
|
+
if (item && el === item.el && type === item.type && fn === item.fn) {
|
158
|
+
delete stack[i];
|
159
|
+
}
|
160
|
+
}
|
161
|
+
}
|
162
|
+
},
|
163
|
+
stop : function(e) {
|
164
|
+
if (e.preventDefault) e.preventDefault();
|
165
|
+
if (e.stopPropagation) e.stopPropagation();
|
166
|
+
if (e.cancelBubble !== undefined) e.cancelBubble = true;
|
167
|
+
if (e.returnValue !== undefined) e.returnValue = false;
|
168
|
+
},
|
169
|
+
bind : function(el, type, fn, id) {
|
170
|
+
this.add(el, type, function(e) {
|
171
|
+
fn(e);
|
172
|
+
KE.event.stop(e);
|
173
|
+
return false;
|
174
|
+
}, id);
|
175
|
+
},
|
176
|
+
input : function(el, func, id) {
|
177
|
+
this.add(el, 'keyup', function(e) {
|
178
|
+
if (!e.ctrlKey && !e.altKey && (e.keyCode < 16 || e.keyCode > 18) && e.keyCode != 116) {
|
179
|
+
func(e);
|
180
|
+
KE.event.stop(e);
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
}, id);
|
184
|
+
function handler (e) {
|
185
|
+
window.setTimeout(function() {
|
186
|
+
func(e);
|
187
|
+
}, 1);
|
188
|
+
}
|
189
|
+
var newElement = (el.nodeName == '#document') ? el.body : el;
|
190
|
+
this.add(newElement, 'paste', handler, id);
|
191
|
+
this.add(newElement, 'cut', handler, id);
|
192
|
+
},
|
193
|
+
ctrl : function(el, key, func, id) {
|
194
|
+
key = key.toString().match(/^\d{2,}$/) ? key : key.toUpperCase().charCodeAt(0);
|
195
|
+
this.add(el, 'keydown', function(e) {
|
196
|
+
if (e.ctrlKey && e.keyCode == key && !e.shiftKey && !e.altKey) {
|
197
|
+
func(e);
|
198
|
+
KE.event.stop(e);
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
}, id);
|
202
|
+
},
|
203
|
+
ready : function(func, win, doc, id) {
|
204
|
+
var win = win || window;
|
205
|
+
var doc = doc || document;
|
206
|
+
var loaded = false;
|
207
|
+
var readyFunc = function() {
|
208
|
+
if (loaded) return;
|
209
|
+
loaded = true;
|
210
|
+
func();
|
211
|
+
};
|
212
|
+
if (doc.addEventListener) {
|
213
|
+
this.add(doc, "DOMContentLoaded", readyFunc, id);
|
214
|
+
} else if (doc.attachEvent){
|
215
|
+
this.add(doc, "readystatechange", function() {
|
216
|
+
if (doc.readyState == "complete") readyFunc();
|
217
|
+
}, id);
|
218
|
+
if ( doc.documentElement.doScroll && typeof win.frameElement === "undefined" ) {
|
219
|
+
var ieReadyFunc = function() {
|
220
|
+
if (loaded) return;
|
221
|
+
try {
|
222
|
+
doc.documentElement.doScroll("left");
|
223
|
+
} catch(e) {
|
224
|
+
window.setTimeout(ieReadyFunc, 0);
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
readyFunc();
|
228
|
+
};
|
229
|
+
ieReadyFunc();
|
230
|
+
}
|
231
|
+
}
|
232
|
+
this.add(win, 'load', readyFunc, id);
|
233
|
+
}
|
234
|
+
};
|
235
|
+
|
236
|
+
KE.each = function(obj, func) {
|
237
|
+
for (var key in obj) {
|
238
|
+
if (obj.hasOwnProperty(key)) func(key, obj[key]);
|
239
|
+
}
|
240
|
+
};
|
241
|
+
|
242
|
+
KE.eachNode = function(node, func) {
|
243
|
+
var walkNodes = function(parent) {
|
244
|
+
if (KE.util.getNodeType(parent) != 1) return true;
|
245
|
+
var n = parent.firstChild;
|
246
|
+
while (n) {
|
247
|
+
var next = n.nextSibling;
|
248
|
+
if (!func(n)) return false;
|
249
|
+
if (!walkNodes(n)) return false;
|
250
|
+
n = next;
|
251
|
+
}
|
252
|
+
return true;
|
253
|
+
};
|
254
|
+
walkNodes(node);
|
255
|
+
};
|
256
|
+
|
257
|
+
KE.selection = function(doc) {
|
258
|
+
this.sel = null;
|
259
|
+
this.range = null;
|
260
|
+
this.keRange = null;
|
261
|
+
this.isControl = false;
|
262
|
+
var win = doc.parentWindow || doc.defaultView;
|
263
|
+
this.init = function() {
|
264
|
+
var sel = win.getSelection ? win.getSelection() : doc.selection;
|
265
|
+
var range;
|
266
|
+
try {
|
267
|
+
if (sel.rangeCount > 0) range = sel.getRangeAt(0);
|
268
|
+
else range = sel.createRange();
|
269
|
+
} catch(e) {}
|
270
|
+
if (!range) range = KE.util.createRange(doc);
|
271
|
+
this.sel = sel;
|
272
|
+
this.range = range;
|
273
|
+
var startNode, startPos, endNode, endPos;
|
274
|
+
if (KE.browser.IE) {
|
275
|
+
if (range.item) {
|
276
|
+
this.isControl = true;
|
277
|
+
var el = range.item(0);
|
278
|
+
startNode = endNode = el;
|
279
|
+
startPos = endPos = 0;
|
280
|
+
} else {
|
281
|
+
this.isControl = false;
|
282
|
+
var getStartEnd = function(isStart) {
|
283
|
+
var pointRange = range.duplicate();
|
284
|
+
pointRange.collapse(isStart);
|
285
|
+
var parentNode = pointRange.parentElement();
|
286
|
+
var nodes = parentNode.childNodes;
|
287
|
+
if (nodes.length == 0) return {node: parentNode, pos: 0};
|
288
|
+
var startNode;
|
289
|
+
var endElement;
|
290
|
+
var startPos = 0;
|
291
|
+
var isEnd = false;
|
292
|
+
var testRange = range.duplicate();
|
293
|
+
KE.util.moveToElementText(testRange, parentNode);
|
294
|
+
for (var i = 0, len = nodes.length; i < len; i++) {
|
295
|
+
var node = nodes[i];
|
296
|
+
var cmp = testRange.compareEndPoints('StartToStart', pointRange);
|
297
|
+
if (cmp > 0) {
|
298
|
+
isEnd = true;
|
299
|
+
} else if (cmp == 0) {
|
300
|
+
if (node.nodeType == 1) {
|
301
|
+
var keRange = new KE.range(doc);
|
302
|
+
keRange.selectTextNode(node);
|
303
|
+
return {node: keRange.startNode, pos: 0};
|
304
|
+
} else {
|
305
|
+
return {node: node, pos: 0};
|
306
|
+
}
|
307
|
+
}
|
308
|
+
if (node.nodeType == 1) {
|
309
|
+
var nodeRange = range.duplicate();
|
310
|
+
KE.util.moveToElementText(nodeRange, node);
|
311
|
+
testRange.setEndPoint('StartToEnd', nodeRange);
|
312
|
+
if (isEnd) startPos += nodeRange.text.length;
|
313
|
+
else startPos = 0;
|
314
|
+
} else if (node.nodeType == 3) {
|
315
|
+
testRange.moveStart('character', node.nodeValue.length);
|
316
|
+
startPos += node.nodeValue.length;
|
317
|
+
}
|
318
|
+
if (!isEnd) startNode = node;
|
319
|
+
}
|
320
|
+
if (!isEnd && startNode.nodeType == 1) {
|
321
|
+
var startNode = parentNode.lastChild;
|
322
|
+
return {node: startNode, pos: startNode.nodeType == 1 ? 1 : startNode.nodeValue.length};
|
323
|
+
}
|
324
|
+
testRange = range.duplicate();
|
325
|
+
KE.util.moveToElementText(testRange, parentNode);
|
326
|
+
testRange.setEndPoint('StartToEnd', pointRange);
|
327
|
+
startPos -= testRange.text.replace(/\r\n|\n|\r/g, '').length;
|
328
|
+
return {node: startNode, pos: startPos};
|
329
|
+
};
|
330
|
+
var start = getStartEnd(true);
|
331
|
+
var end = getStartEnd(false);
|
332
|
+
startNode = start.node;
|
333
|
+
startPos = start.pos;
|
334
|
+
endNode = end.node;
|
335
|
+
endPos = end.pos;
|
336
|
+
}
|
337
|
+
} else {
|
338
|
+
startNode = range.startContainer;
|
339
|
+
startPos = range.startOffset;
|
340
|
+
endNode = range.endContainer;
|
341
|
+
endPos = range.endOffset;
|
342
|
+
if (startNode.nodeType == 1 && typeof startNode.childNodes[startPos] != 'undefined') {
|
343
|
+
startNode = startNode.childNodes[startPos];
|
344
|
+
startPos = 0;
|
345
|
+
}
|
346
|
+
if (endNode.nodeType == 1) {
|
347
|
+
endPos = endPos == 0 ? 1 : endPos;
|
348
|
+
if (typeof endNode.childNodes[endPos - 1] != 'undefined') {
|
349
|
+
endNode = endNode.childNodes[endPos - 1];
|
350
|
+
endPos = (endNode.nodeType == 1) ? 0 : endNode.nodeValue.length;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
this.isControl = (startNode.nodeType == 1 && startNode === endNode && range.startOffset + 1 == range.endOffset);
|
354
|
+
if (startNode.nodeType == 1 && endNode.nodeType == 3 && endPos == 0 && endNode.previousSibling) {
|
355
|
+
var node = endNode.previousSibling;
|
356
|
+
while (node) {
|
357
|
+
if (node === startNode) {
|
358
|
+
endNode = startNode;
|
359
|
+
break;
|
360
|
+
}
|
361
|
+
if (node.childNodes.length != 1) break;
|
362
|
+
node = node.childNodes[0];
|
363
|
+
}
|
364
|
+
}
|
365
|
+
if (range.collapsed) {
|
366
|
+
var keRange = new KE.range(doc);
|
367
|
+
keRange.setTextStart(startNode, startPos);
|
368
|
+
endNode = keRange.startNode;
|
369
|
+
endPos = keRange.startPos;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
var keRange = new KE.range(doc);
|
373
|
+
keRange.setTextStart(startNode, startPos);
|
374
|
+
keRange.setTextEnd(endNode, endPos);
|
375
|
+
this.keRange = keRange;
|
376
|
+
};
|
377
|
+
this.init();
|
378
|
+
this.addRange = function(keRange) {
|
379
|
+
if (KE.browser.GECKO && KE.browser.VERSION < 3) return;
|
380
|
+
this.keRange = keRange;
|
381
|
+
if (KE.browser.IE) {
|
382
|
+
var getEndRange = function(isStart) {
|
383
|
+
var range = KE.util.createRange(doc);
|
384
|
+
var node = isStart ? keRange.startNode : keRange.endNode;
|
385
|
+
if (node.nodeType == 1) {
|
386
|
+
KE.util.moveToElementText(range, node);
|
387
|
+
range.collapse(isStart);
|
388
|
+
} else if (node.nodeType == 3) {
|
389
|
+
range = KE.util.getNodeStartRange(doc, node);
|
390
|
+
var pos = isStart ? keRange.startPos : keRange.endPos;
|
391
|
+
range.moveStart('character', pos);
|
392
|
+
}
|
393
|
+
return range;
|
394
|
+
}
|
395
|
+
if (!this.range.item) {
|
396
|
+
var node = keRange.startNode;
|
397
|
+
if (node == keRange.endNode && KE.util.getNodeType(node) == 1 && KE.util.getNodeTextLength(node) == 0) {
|
398
|
+
var temp = doc.createTextNode(" ");
|
399
|
+
node.appendChild(temp);
|
400
|
+
KE.util.moveToElementText(this.range, node);
|
401
|
+
this.range.collapse(false);
|
402
|
+
this.range.select();
|
403
|
+
node.removeChild(temp);
|
404
|
+
} else {
|
405
|
+
if (node.nodeType == 3 && keRange.collapsed()) {
|
406
|
+
this.range = getEndRange(true);
|
407
|
+
this.range.collapse(true);
|
408
|
+
} else {
|
409
|
+
this.range.setEndPoint('StartToStart', getEndRange(true));
|
410
|
+
this.range.setEndPoint('EndToStart', getEndRange(false));
|
411
|
+
}
|
412
|
+
this.range.select();
|
413
|
+
}
|
414
|
+
}
|
415
|
+
} else {
|
416
|
+
var getNodePos = function(node) {
|
417
|
+
var pos = 0;
|
418
|
+
while (node) {
|
419
|
+
node = node.previousSibling;
|
420
|
+
pos++;
|
421
|
+
}
|
422
|
+
return --pos;
|
423
|
+
};
|
424
|
+
var range = new KE.range(doc);
|
425
|
+
range.setTextStart(keRange.startNode, keRange.startPos);
|
426
|
+
range.setTextEnd(keRange.endNode, keRange.endPos);
|
427
|
+
var startNode = range.startNode;
|
428
|
+
var endNode = range.endNode;
|
429
|
+
if (KE.util.getNodeType(startNode) == 88) {
|
430
|
+
this.range.setStart(startNode.parentNode, getNodePos(range.startNode));
|
431
|
+
} else {
|
432
|
+
this.range.setStart(startNode, range.startPos);
|
433
|
+
}
|
434
|
+
if (KE.util.getNodeType(endNode) == 88) {
|
435
|
+
this.range.setEnd(endNode.parentNode, getNodePos(range.endNode) + 1);
|
436
|
+
} else {
|
437
|
+
this.range.setEnd(endNode, range.endPos);
|
438
|
+
}
|
439
|
+
this.sel.removeAllRanges();
|
440
|
+
this.sel.addRange(this.range);
|
441
|
+
}
|
442
|
+
};
|
443
|
+
this.focus = function() {
|
444
|
+
if (KE.browser.IE && this.range != null) this.range.select();
|
445
|
+
}
|
446
|
+
};
|
447
|
+
|
448
|
+
KE.range = function(doc) {
|
449
|
+
this.startNode = null;
|
450
|
+
this.startPos = null;
|
451
|
+
this.endNode = null;
|
452
|
+
this.endPos = null;
|
453
|
+
this.getParentElement = function() {
|
454
|
+
var scanParent = function(node, func) {
|
455
|
+
while (node && (!node.tagName || node.tagName.toLowerCase() != 'body')) {
|
456
|
+
node = node.parentNode;
|
457
|
+
if (func(node)) return;
|
458
|
+
}
|
459
|
+
}
|
460
|
+
var nodeList = [];
|
461
|
+
scanParent(this.startNode, function(node) {
|
462
|
+
nodeList.push(node);
|
463
|
+
});
|
464
|
+
var parentNode;
|
465
|
+
scanParent(this.endNode, function(node) {
|
466
|
+
if (KE.util.inArray(node, nodeList)) {
|
467
|
+
parentNode = node;
|
468
|
+
return true;
|
469
|
+
}
|
470
|
+
});
|
471
|
+
return parentNode ? parentNode : doc.body;
|
472
|
+
};
|
473
|
+
this.getNodeList = function() {
|
474
|
+
var self = this;
|
475
|
+
var parentNode = this.getParentElement();
|
476
|
+
var nodeList = [];
|
477
|
+
var isStarted = false;
|
478
|
+
if (parentNode == self.startNode) isStarted = true;
|
479
|
+
if (isStarted) nodeList.push(parentNode);
|
480
|
+
KE.eachNode(parentNode, function(node) {
|
481
|
+
if (node == self.startNode) isStarted = true;
|
482
|
+
var range = new KE.range(doc);
|
483
|
+
range.selectTextNode(node);
|
484
|
+
var cmp = range.comparePoints('START_TO_END', self);
|
485
|
+
if (cmp > 0) {
|
486
|
+
return false;
|
487
|
+
} else if (cmp == 0) {
|
488
|
+
if (range.startNode !== range.endNode || range.startPos !== range.endPos) return false;
|
489
|
+
}
|
490
|
+
if (isStarted) nodeList.push(node);
|
491
|
+
return true;
|
492
|
+
});
|
493
|
+
return nodeList;
|
494
|
+
};
|
495
|
+
this.comparePoints = function(how, range) {
|
496
|
+
var compareNodes = function(nodeA, posA, nodeB, posB) {
|
497
|
+
var cmp;
|
498
|
+
if (KE.browser.IE) {
|
499
|
+
var getStartRange = function(node, pos, isStart) {
|
500
|
+
var range = KE.util.createRange(doc);
|
501
|
+
var type = KE.util.getNodeType(node);
|
502
|
+
if (type == 1) {
|
503
|
+
KE.util.moveToElementText(range, node);
|
504
|
+
range.collapse(isStart);
|
505
|
+
} else if (type == 3) {
|
506
|
+
range = KE.util.getNodeStartRange(doc, node);
|
507
|
+
range.moveStart('character', pos);
|
508
|
+
range.collapse(true);
|
509
|
+
}
|
510
|
+
return range;
|
511
|
+
}
|
512
|
+
var rangeA, rangeB;
|
513
|
+
if (how == 'START_TO_START' || how == 'START_TO_END') rangeA = getStartRange(nodeA, posA, true);
|
514
|
+
else rangeA = getStartRange(nodeA, posA, false);
|
515
|
+
if (how == 'START_TO_START' || how == 'END_TO_START') rangeB = getStartRange(nodeB, posB, true);
|
516
|
+
else rangeB = getStartRange(nodeB, posB, false);
|
517
|
+
return rangeA.compareEndPoints('StartToStart', rangeB);
|
518
|
+
} else {
|
519
|
+
var rangeA = KE.util.createRange(doc);
|
520
|
+
rangeA.selectNode(nodeA);
|
521
|
+
if (how == 'START_TO_START' || how == 'START_TO_END') rangeA.collapse(true);
|
522
|
+
else rangeA.collapse(false);
|
523
|
+
var rangeB = KE.util.createRange(doc);
|
524
|
+
rangeB.selectNode(nodeB);
|
525
|
+
if (how == 'START_TO_START' || how == 'END_TO_START') rangeB.collapse(true);
|
526
|
+
else rangeB.collapse(false);
|
527
|
+
if (rangeA.compareBoundaryPoints(Range.START_TO_START, rangeB) > 0) {
|
528
|
+
cmp = 1;
|
529
|
+
} else if (rangeA.compareBoundaryPoints(Range.START_TO_START, rangeB) == 0) {
|
530
|
+
if (posA > posB) cmp = 1;
|
531
|
+
else if (posA == posB) cmp = 0;
|
532
|
+
else cmp = -1;
|
533
|
+
} else {
|
534
|
+
cmp = -1;
|
535
|
+
}
|
536
|
+
}
|
537
|
+
return cmp;
|
538
|
+
}
|
539
|
+
if (how == 'START_TO_START') return compareNodes(this.startNode, this.startPos, range.startNode, range.startPos);
|
540
|
+
if (how == 'START_TO_END') return compareNodes(this.startNode, this.startPos, range.endNode, range.endPos);
|
541
|
+
if (how == 'END_TO_START') return compareNodes(this.endNode, this.endPos, range.startNode, range.startPos);
|
542
|
+
if (how == 'END_TO_END') return compareNodes(this.endNode, this.endPos, range.endNode, range.endPos);
|
543
|
+
};
|
544
|
+
this.collapsed = function() {
|
545
|
+
return (this.startNode === this.endNode && this.startPos === this.endPos);
|
546
|
+
};
|
547
|
+
this.collapse = function(toStart) {
|
548
|
+
if (toStart) {
|
549
|
+
this.setEnd(this.startNode, this.startPos);
|
550
|
+
} else {
|
551
|
+
this.setStart(this.endNode, this.endPos);
|
552
|
+
}
|
553
|
+
};
|
554
|
+
this.setTextStart = function(node, pos) {
|
555
|
+
var textNode = node;
|
556
|
+
KE.eachNode(node, function(n) {
|
557
|
+
if (KE.util.getNodeType(n) == 3 && n.nodeValue.length > 0 || KE.util.getNodeType(n) == 88) {
|
558
|
+
textNode = n;
|
559
|
+
pos = 0;
|
560
|
+
return false;
|
561
|
+
}
|
562
|
+
return true;
|
563
|
+
});
|
564
|
+
this.setStart(textNode, pos);
|
565
|
+
};
|
566
|
+
this.setStart = function(node, pos) {
|
567
|
+
this.startNode = node;
|
568
|
+
this.startPos = pos;
|
569
|
+
if (this.endNode === null) {
|
570
|
+
this.endNode = node;
|
571
|
+
this.endPos = pos;
|
572
|
+
}
|
573
|
+
};
|
574
|
+
this.setTextEnd = function(node, pos) {
|
575
|
+
var textNode = node;
|
576
|
+
KE.eachNode(node, function(n) {
|
577
|
+
if (KE.util.getNodeType(n) == 3 && n.nodeValue.length > 0 || KE.util.getNodeType(n) == 88) {
|
578
|
+
textNode = n;
|
579
|
+
pos = KE.util.getNodeType(n) == 3 ? n.nodeValue.length : 0;
|
580
|
+
}
|
581
|
+
return true;
|
582
|
+
});
|
583
|
+
this.setEnd(textNode, pos);
|
584
|
+
};
|
585
|
+
this.setEnd = function(node, pos) {
|
586
|
+
this.endNode = node;
|
587
|
+
this.endPos = pos;
|
588
|
+
if (this.startNode === null) {
|
589
|
+
this.startNode = node;
|
590
|
+
this.startPos = pos;
|
591
|
+
}
|
592
|
+
};
|
593
|
+
this.selectNode = function(node) {
|
594
|
+
this.setStart(node, 0);
|
595
|
+
this.setEnd(node, node.nodeType == 1 ? 0 : node.nodeValue.length);
|
596
|
+
};
|
597
|
+
this.selectTextNode = function(node) {
|
598
|
+
this.setTextStart(node, 0);
|
599
|
+
this.setTextEnd(node, node.nodeType == 1 ? 0 : node.nodeValue.length);
|
600
|
+
};
|
601
|
+
this.extractContents = function(isDelete) {
|
602
|
+
isDelete = (isDelete === undefined) ? true : isDelete;
|
603
|
+
var thisRange = this;
|
604
|
+
var startNode = this.startNode;
|
605
|
+
var startPos = this.startPos;
|
606
|
+
var endNode = this.endNode;
|
607
|
+
var endPos = this.endPos;
|
608
|
+
var extractTextNode = function(node, startPos, endPos) {
|
609
|
+
var length = node.nodeValue.length;
|
610
|
+
var cloneNode = node.cloneNode(true);
|
611
|
+
var centerNode = cloneNode.splitText(startPos);
|
612
|
+
centerNode.splitText(endPos - startPos);
|
613
|
+
if (isDelete) {
|
614
|
+
var center = node;
|
615
|
+
if (startPos > 0) center = node.splitText(startPos);
|
616
|
+
if (endPos < length) center.splitText(endPos - startPos);
|
617
|
+
center.parentNode.removeChild(center);
|
618
|
+
}
|
619
|
+
return centerNode;
|
620
|
+
};
|
621
|
+
var noEndTagHash = KE.util.arrayToHash(KE.setting.noEndTags);
|
622
|
+
var isStarted = false;
|
623
|
+
var isEnd = false;
|
624
|
+
var extractNodes = function(parent, frag) {
|
625
|
+
if (KE.util.getNodeType(parent) != 1) return true;
|
626
|
+
var node = parent.firstChild;
|
627
|
+
while (node) {
|
628
|
+
if (node == startNode) isStarted = true;
|
629
|
+
if (node == endNode) isEnd = true;
|
630
|
+
var nextNode = node.nextSibling;
|
631
|
+
var type = node.nodeType;
|
632
|
+
if (type == 1) {
|
633
|
+
var range = new KE.range(doc);
|
634
|
+
range.selectNode(node);
|
635
|
+
var cmp = range.comparePoints('END_TO_END', thisRange);
|
636
|
+
if (isStarted && (cmp < 0 || (cmp == 0 && noEndTagHash[node.nodeName.toLowerCase()] !== undefined))) {
|
637
|
+
var cloneNode = node.cloneNode(true);
|
638
|
+
frag.appendChild(cloneNode);
|
639
|
+
if (isDelete) {
|
640
|
+
node.parentNode.removeChild(node);
|
641
|
+
}
|
642
|
+
} else {
|
643
|
+
var childFlag = node.cloneNode(false);
|
644
|
+
if (noEndTagHash[childFlag.nodeName.toLowerCase()] === undefined) {
|
645
|
+
frag.appendChild(childFlag);
|
646
|
+
if (!extractNodes(node, childFlag)) return false;
|
647
|
+
}
|
648
|
+
}
|
649
|
+
} else if (type == 3) {
|
650
|
+
if (isStarted) {
|
651
|
+
var textNode;
|
652
|
+
if (node == startNode && node == endNode) {
|
653
|
+
textNode = extractTextNode(node, startPos, endPos);
|
654
|
+
frag.appendChild(textNode);
|
655
|
+
return false;
|
656
|
+
} else if (node == startNode) {
|
657
|
+
textNode = extractTextNode(node, startPos, node.nodeValue.length);
|
658
|
+
frag.appendChild(textNode);
|
659
|
+
} else if (node == endNode) {
|
660
|
+
textNode = extractTextNode(node, 0, endPos);
|
661
|
+
frag.appendChild(textNode);
|
662
|
+
return false;
|
663
|
+
} else {
|
664
|
+
textNode = extractTextNode(node, 0, node.nodeValue.length);
|
665
|
+
frag.appendChild(textNode);
|
666
|
+
}
|
667
|
+
}
|
668
|
+
}
|
669
|
+
node = nextNode;
|
670
|
+
if (isEnd) return false;
|
671
|
+
}
|
672
|
+
if (frag.innerHTML.replace(/<.*?>/g, '') === '' && frag.parentNode) {
|
673
|
+
frag.parentNode.removeChild(frag);
|
674
|
+
}
|
675
|
+
return true;
|
676
|
+
}
|
677
|
+
var parentNode = this.getParentElement();
|
678
|
+
var docFrag = parentNode.cloneNode(false);
|
679
|
+
extractNodes(parentNode, docFrag);
|
680
|
+
return docFrag;
|
681
|
+
};
|
682
|
+
this.cloneContents = function() {
|
683
|
+
return this.extractContents(false);
|
684
|
+
};
|
685
|
+
this.getText = function() {
|
686
|
+
var html = this.cloneContents().innerHTML;
|
687
|
+
return html.replace(/<.*?>/g, "");
|
688
|
+
};
|
689
|
+
};
|
690
|
+
|
691
|
+
KE.cmd = function(id) {
|
692
|
+
this.doc = KE.g[id].iframeDoc;
|
693
|
+
this.keSel = KE.g[id].keSel;
|
694
|
+
this.keRange = KE.g[id].keRange;
|
695
|
+
this.mergeAttributes = function(el, attr) {
|
696
|
+
for (var i = 0, len = attr.length; i < len; i++) {
|
697
|
+
KE.each(attr[i], function(key, value) {
|
698
|
+
if (key.charAt(0) == '.') {
|
699
|
+
var jsKey = KE.util.getJsKey(key.substr(1));
|
700
|
+
el.style[jsKey] = value;
|
701
|
+
} else {
|
702
|
+
if (KE.browser.IE && KE.browser.VERSION < 8 && key == 'class') key = 'className';
|
703
|
+
el.setAttribute(key, value);
|
704
|
+
}
|
705
|
+
});
|
706
|
+
}
|
707
|
+
return el;
|
708
|
+
};
|
709
|
+
this.wrapTextNode = function(node, startPos, endPos, element, attributes) {
|
710
|
+
var length = node.nodeValue.length;
|
711
|
+
var isFull = (startPos == 0 && endPos == length);
|
712
|
+
var range = new KE.range(this.doc);
|
713
|
+
range.selectTextNode(node.parentNode);
|
714
|
+
if (isFull &&
|
715
|
+
node.parentNode.tagName == element.tagName &&
|
716
|
+
range.comparePoints('END_TO_END', this.keRange) <= 0 &&
|
717
|
+
range.comparePoints('START_TO_START', this.keRange) >= 0) {
|
718
|
+
this.mergeAttributes(node.parentNode, attributes);
|
719
|
+
return node;
|
720
|
+
} else {
|
721
|
+
var el = element.cloneNode(true);
|
722
|
+
if (isFull) {
|
723
|
+
var cloneNode = node.cloneNode(true);
|
724
|
+
el.appendChild(cloneNode);
|
725
|
+
node.parentNode.replaceChild(el, node);
|
726
|
+
return cloneNode;
|
727
|
+
} else {
|
728
|
+
var centerNode = node;
|
729
|
+
if (startPos < endPos) {
|
730
|
+
if (startPos > 0) centerNode = node.splitText(startPos);
|
731
|
+
if (endPos < length) centerNode.splitText(endPos - startPos);
|
732
|
+
var cloneNode = centerNode.cloneNode(true);
|
733
|
+
el.appendChild(cloneNode);
|
734
|
+
centerNode.parentNode.replaceChild(el, centerNode);
|
735
|
+
return cloneNode;
|
736
|
+
} else {
|
737
|
+
if (startPos < length) {
|
738
|
+
centerNode = node.splitText(startPos);
|
739
|
+
centerNode.parentNode.insertBefore(el, centerNode);
|
740
|
+
} else {
|
741
|
+
if (centerNode.nextSibling) {
|
742
|
+
centerNode.parentNode.insertBefore(el, centerNode.nextSibling);
|
743
|
+
} else {
|
744
|
+
centerNode.parentNode.appendChild(el);
|
745
|
+
}
|
746
|
+
}
|
747
|
+
return el;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
}
|
751
|
+
};
|
752
|
+
this.wrap = function(tagName, attributes) {
|
753
|
+
attributes = attributes || [];
|
754
|
+
var self = this;
|
755
|
+
this.keSel.focus();
|
756
|
+
var element = KE.$$(tagName, this.doc);
|
757
|
+
this.mergeAttributes(element, attributes);
|
758
|
+
var keRange = this.keRange;
|
759
|
+
var startNode = keRange.startNode;
|
760
|
+
var startPos = keRange.startPos;
|
761
|
+
var endNode = keRange.endNode;
|
762
|
+
var endPos = keRange.endPos;
|
763
|
+
var parentNode = keRange.getParentElement();
|
764
|
+
if (KE.util.inMarquee(parentNode)) return;
|
765
|
+
var isStarted = false;
|
766
|
+
KE.eachNode(parentNode, function(node) {
|
767
|
+
if (node == startNode) isStarted = true;
|
768
|
+
if (node.nodeType == 1) {
|
769
|
+
if (node == startNode && node == endNode) {
|
770
|
+
if (KE.util.inArray(node.tagName.toLowerCase(), KE.g[id].noEndTags)) {
|
771
|
+
if (startPos > 0) node.parentNode.appendChild(element);
|
772
|
+
else node.parentNode.insertBefore(element, node);
|
773
|
+
} else {
|
774
|
+
node.appendChild(element);
|
775
|
+
}
|
776
|
+
keRange.selectNode(element);
|
777
|
+
return false;
|
778
|
+
} else if (node == startNode) {
|
779
|
+
keRange.setStart(node, 0);
|
780
|
+
} else if (node == endNode) {
|
781
|
+
keRange.setEnd(node, 0);
|
782
|
+
return false;
|
783
|
+
}
|
784
|
+
} else if (node.nodeType == 3) {
|
785
|
+
if (isStarted) {
|
786
|
+
if (node == startNode && node == endNode) {
|
787
|
+
var rangeNode = self.wrapTextNode(node, startPos, endPos, element, attributes);
|
788
|
+
keRange.selectNode(rangeNode);
|
789
|
+
return false;
|
790
|
+
} else if (node == startNode) {
|
791
|
+
var rangeNode = self.wrapTextNode(node, startPos, node.nodeValue.length, element, attributes);
|
792
|
+
keRange.setStart(rangeNode, 0);
|
793
|
+
} else if (node == endNode) {
|
794
|
+
var rangeNode = self.wrapTextNode(node, 0, endPos, element, attributes);
|
795
|
+
keRange.setEnd(rangeNode, rangeNode.nodeType == 1 ? 0 : rangeNode.nodeValue.length);
|
796
|
+
return false;
|
797
|
+
} else {
|
798
|
+
self.wrapTextNode(node, 0, node.nodeValue.length, element, attributes);
|
799
|
+
}
|
800
|
+
}
|
801
|
+
}
|
802
|
+
return true;
|
803
|
+
});
|
804
|
+
this.keSel.addRange(keRange);
|
805
|
+
};
|
806
|
+
this.getTopParent = function(tagNames, node) {
|
807
|
+
var parent = null;
|
808
|
+
while (node) {
|
809
|
+
node = node.parentNode;
|
810
|
+
if (KE.util.inArray(node.tagName.toLowerCase(), tagNames)) {
|
811
|
+
parent = node;
|
812
|
+
} else {
|
813
|
+
break;
|
814
|
+
}
|
815
|
+
}
|
816
|
+
return parent;
|
817
|
+
};
|
818
|
+
this.splitNodeParent = function(parent, node, pos) {
|
819
|
+
var leftRange = new KE.range(this.doc);
|
820
|
+
leftRange.selectNode(parent.firstChild);
|
821
|
+
leftRange.setEnd(node, pos);
|
822
|
+
var leftFrag = leftRange.extractContents();
|
823
|
+
parent.parentNode.insertBefore(leftFrag, parent);
|
824
|
+
return {left : leftFrag, right : parent};
|
825
|
+
};
|
826
|
+
this.remove = function(tags) {
|
827
|
+
var self = this;
|
828
|
+
var keRange = this.keRange;
|
829
|
+
var startNode = keRange.startNode;
|
830
|
+
var startPos = keRange.startPos;
|
831
|
+
var endNode = keRange.endNode;
|
832
|
+
var endPos = keRange.endPos;
|
833
|
+
this.keSel.focus();
|
834
|
+
if (KE.util.inMarquee(keRange.getParentElement())) return;
|
835
|
+
var isCollapsed = (keRange.getText().replace(/\s+/g, '') === '');
|
836
|
+
if (isCollapsed && !KE.browser.IE) return;
|
837
|
+
var tagNames = [];
|
838
|
+
KE.each(tags, function(key, val) {
|
839
|
+
if (key != '*') tagNames.push(key);
|
840
|
+
});
|
841
|
+
var startParent = this.getTopParent(tagNames, startNode);
|
842
|
+
var endParent = this.getTopParent(tagNames, endNode);
|
843
|
+
if (startParent) {
|
844
|
+
var startFrags = this.splitNodeParent(startParent, startNode, startPos);
|
845
|
+
keRange.setStart(startFrags.right, 0);
|
846
|
+
if (startNode == endNode && KE.util.getNodeTextLength(startFrags.right) > 0) {
|
847
|
+
keRange.selectNode(startFrags.right);
|
848
|
+
var range = new KE.range(this.doc);
|
849
|
+
range.selectTextNode(startFrags.left);
|
850
|
+
if (startPos > 0) endPos -= range.endNode.nodeValue.length;
|
851
|
+
range.selectTextNode(startFrags.right);
|
852
|
+
endNode = range.startNode;
|
853
|
+
}
|
854
|
+
}
|
855
|
+
if (isCollapsed) {
|
856
|
+
var node = keRange.startNode;
|
857
|
+
if (node.nodeType == 1) {
|
858
|
+
if (node.nodeName.toLowerCase() == 'br') return;
|
859
|
+
keRange.selectNode(node);
|
860
|
+
} else {
|
861
|
+
return;
|
862
|
+
}
|
863
|
+
} else if (endParent) {
|
864
|
+
var endFrags = this.splitNodeParent(endParent, endNode, endPos);
|
865
|
+
keRange.setEnd(endFrags.left, 0);
|
866
|
+
if (startParent == endParent) {
|
867
|
+
keRange.setStart(endFrags.left, 0);
|
868
|
+
}
|
869
|
+
}
|
870
|
+
var removeAttr = function(node, attr) {
|
871
|
+
if (attr.charAt(0) == '.') {
|
872
|
+
var jsKey = KE.util.getJsKey(attr.substr(1));
|
873
|
+
node.style[jsKey] = '';
|
874
|
+
} else {
|
875
|
+
if (KE.browser.IE && KE.browser.VERSION < 8 && attr == 'class') attr = 'className';
|
876
|
+
node.removeAttribute(attr);
|
877
|
+
}
|
878
|
+
};
|
879
|
+
var nodeList = keRange.getNodeList();
|
880
|
+
keRange.setTextStart(keRange.startNode, keRange.startPos);
|
881
|
+
keRange.setTextEnd(keRange.endNode, keRange.endPos);
|
882
|
+
for (var i = 0, length = nodeList.length; i < length; i++) {
|
883
|
+
var node = nodeList[i];
|
884
|
+
if (node.nodeType == 1) {
|
885
|
+
var tagName = node.tagName.toLowerCase();
|
886
|
+
if (tags[tagName]) {
|
887
|
+
var attr = tags[tagName];
|
888
|
+
for (var j = 0, len = attr.length; j < len; j++) {
|
889
|
+
if (attr[j] == '*') {
|
890
|
+
KE.util.removeParent(node);
|
891
|
+
break;
|
892
|
+
} else {
|
893
|
+
removeAttr(node, attr[j]);
|
894
|
+
var attrs = [];
|
895
|
+
if (node.outerHTML) {
|
896
|
+
attrHash = KE.util.getAttrList(node.outerHTML);
|
897
|
+
KE.each(attrHash, function(key, val) {
|
898
|
+
attrs.push({
|
899
|
+
name : key,
|
900
|
+
value : val
|
901
|
+
});
|
902
|
+
});
|
903
|
+
} else {
|
904
|
+
attrs = node.attributes;
|
905
|
+
}
|
906
|
+
if (attrs.length == 0) {
|
907
|
+
KE.util.removeParent(node);
|
908
|
+
break;
|
909
|
+
} else if (attrs[0].name == 'style' && attrs[0].value === '') {
|
910
|
+
KE.util.removeParent(node);
|
911
|
+
break;
|
912
|
+
}
|
913
|
+
}
|
914
|
+
}
|
915
|
+
}
|
916
|
+
if (tags['*']) {
|
917
|
+
var attr = tags['*'];
|
918
|
+
for (var j = 0, len = attr.length; j < len; j++) {
|
919
|
+
removeAttr(node, attr[j]);
|
920
|
+
}
|
921
|
+
}
|
922
|
+
}
|
923
|
+
}
|
924
|
+
try {
|
925
|
+
this.keSel.addRange(keRange);
|
926
|
+
} catch(e) {}
|
927
|
+
};
|
928
|
+
};
|
929
|
+
|
930
|
+
KE.format = {
|
931
|
+
getUrl : function(url, mode, host, pathname) {
|
932
|
+
if (!mode) return url;
|
933
|
+
mode = mode.toLowerCase();
|
934
|
+
if (!KE.util.inArray(mode, ['absolute', 'relative', 'domain'])) return url;
|
935
|
+
host = host || location.protocol + '//' + location.host;
|
936
|
+
if (pathname === undefined) {
|
937
|
+
var m = location.pathname.match(/^(\/.*)\//);
|
938
|
+
pathname = m ? m[1] : '';
|
939
|
+
}
|
940
|
+
var matches = url.match(/^(\w+:\/\/[^\/]*)/);
|
941
|
+
if (matches) {
|
942
|
+
if (matches[1] !== host) return url;
|
943
|
+
} else if (url.match(/^\w+:/)) {
|
944
|
+
return url;
|
945
|
+
}
|
946
|
+
var getRealPath = function(path) {
|
947
|
+
var parts = path.split('/');
|
948
|
+
paths = [];
|
949
|
+
for (var i = 0, len = parts.length; i < len; i++) {
|
950
|
+
var part = parts[i];
|
951
|
+
if (part == '..') {
|
952
|
+
if (paths.length > 0) paths.pop();
|
953
|
+
} else if (part !== '' && part != '.') {
|
954
|
+
paths.push(part);
|
955
|
+
}
|
956
|
+
}
|
957
|
+
return '/' + paths.join('/');
|
958
|
+
};
|
959
|
+
if (url.match(/^\//)) {
|
960
|
+
url = host + getRealPath(url.substr(1));
|
961
|
+
} else if (!url.match(/^\w+:\/\//)) {
|
962
|
+
url = host + getRealPath(pathname + '/' + url);
|
963
|
+
}
|
964
|
+
if (mode == 'relative') {
|
965
|
+
var getRelativePath = function(path, depth) {
|
966
|
+
if (url.substr(0, path.length) === path) {
|
967
|
+
var arr = [];
|
968
|
+
for (var i = 0; i < depth; i++) {
|
969
|
+
arr.push('..');
|
970
|
+
}
|
971
|
+
var prefix = '.';
|
972
|
+
if (arr.length > 0) prefix += '/' + arr.join('/');
|
973
|
+
if (pathname == '/') prefix += '/';
|
974
|
+
return prefix + url.substr(path.length);
|
975
|
+
} else {
|
976
|
+
var m = path.match(/^(.*)\//);
|
977
|
+
if (m) {
|
978
|
+
return getRelativePath(m[1], ++depth);
|
979
|
+
}
|
980
|
+
}
|
981
|
+
};
|
982
|
+
url = getRelativePath(host + pathname, 0).substr(2);
|
983
|
+
} else if (mode == 'absolute') {
|
984
|
+
if (url.substr(0, host.length) === host) {
|
985
|
+
url = url.substr(host.length);
|
986
|
+
}
|
987
|
+
}
|
988
|
+
return url;
|
989
|
+
},
|
990
|
+
getHtml : function(html, htmlTags, urlType) {
|
991
|
+
var isFilter = htmlTags ? true : false;
|
992
|
+
html = html.replace(/(<pre[^>]*>)([\s\S]*?)(<\/pre>)/ig, function($0, $1, $2, $3){
|
993
|
+
return $1 + $2.replace(/<br[^>]*>/ig, '\n') + $3;
|
994
|
+
});
|
995
|
+
var htmlTagHash = {};
|
996
|
+
var fontSizeHash = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
|
997
|
+
if (isFilter) {
|
998
|
+
KE.each(htmlTags, function(key, val) {
|
999
|
+
var arr = key.split(',');
|
1000
|
+
for (var i = 0, len = arr.length; i < len; i++) htmlTagHash[arr[i]] = KE.util.arrayToHash(val);
|
1001
|
+
});
|
1002
|
+
}
|
1003
|
+
var noEndTagHash = KE.util.arrayToHash(KE.setting.noEndTags);
|
1004
|
+
var inlineTagHash = KE.util.arrayToHash(KE.setting.inlineTags);
|
1005
|
+
var endlineTagHash = KE.util.arrayToHash(KE.setting.endlineTags);
|
1006
|
+
var re = /((?:\r\n|\n|\r)*)<(\/)?([\w-:]+)((?:\s+|(?:\s+[\w-:]+)|(?:\s+[\w-:]+=[^\s"'<>]+)|(?:\s+[\w-:]+="[^"]*")|(?:\s+[\w-:]+='[^']*'))*)(\/)?>((?:\r\n|\n|\r)*)/g;
|
1007
|
+
html = html.replace(re, function($0, $1, $2, $3, $4, $5, $6) {
|
1008
|
+
var startNewline = $1 || '';
|
1009
|
+
var startSlash = $2 || '';
|
1010
|
+
var tagName = $3.toLowerCase();
|
1011
|
+
var attr = $4 || '';
|
1012
|
+
var endSlash = $5 ? ' ' + $5 : '';
|
1013
|
+
var endNewline = $6 || '';
|
1014
|
+
if (isFilter && typeof htmlTagHash[tagName] == "undefined") return '';
|
1015
|
+
if (endSlash === '' && typeof noEndTagHash[tagName] != "undefined") endSlash = ' /';
|
1016
|
+
if (tagName in endlineTagHash) {
|
1017
|
+
if (startSlash || endSlash) endNewline = '\n';
|
1018
|
+
} else {
|
1019
|
+
if (endNewline) endNewline = ' ';
|
1020
|
+
}
|
1021
|
+
if (tagName !== 'script' && tagName !== 'style') {
|
1022
|
+
startNewline = '';
|
1023
|
+
}
|
1024
|
+
if (tagName === 'font') {
|
1025
|
+
var style = {}, styleStr = '';
|
1026
|
+
attr = attr.replace(/\s*([\w-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g, function($0, $1, $2) {
|
1027
|
+
var key = $1.toLowerCase();
|
1028
|
+
var val = $2 || '';
|
1029
|
+
val = val.replace(/^["']|["']$/g, '');
|
1030
|
+
if (key === 'color') {
|
1031
|
+
style['color'] = val;
|
1032
|
+
return ' ';
|
1033
|
+
}
|
1034
|
+
if (key === 'size') {
|
1035
|
+
style['font-size'] = fontSizeHash[parseInt(val) - 1] || '';
|
1036
|
+
return ' ';
|
1037
|
+
}
|
1038
|
+
if (key === 'face') {
|
1039
|
+
style['font-family'] = val;
|
1040
|
+
return ' ';
|
1041
|
+
}
|
1042
|
+
if (key === 'style') {
|
1043
|
+
styleStr = val;
|
1044
|
+
return ' ';
|
1045
|
+
}
|
1046
|
+
return $0;
|
1047
|
+
});
|
1048
|
+
if (styleStr && !/;$/.test(styleStr)) styleStr += ';';
|
1049
|
+
KE.each(style, function(key, val) {
|
1050
|
+
if (val !== '') {
|
1051
|
+
if (/\s/.test(val)) val = "'" + val + "'";
|
1052
|
+
styleStr += key + ':' + val + ';';
|
1053
|
+
}
|
1054
|
+
});
|
1055
|
+
if (styleStr) attr += ' style="' + styleStr + '"';
|
1056
|
+
tagName = 'span';
|
1057
|
+
}
|
1058
|
+
if (attr !== '') {
|
1059
|
+
attr = attr.replace(/\s*([\w-:]+)=([^\s"'<>]+|"[^"]*"|'[^']*')/g, function($0, $1, $2) {
|
1060
|
+
var key = $1.toLowerCase();
|
1061
|
+
var val = $2 || '';
|
1062
|
+
if (isFilter) {
|
1063
|
+
if (key.charAt(0) === "." || (key !== "style" && typeof htmlTagHash[tagName][key] == "undefined")) return ' ';
|
1064
|
+
}
|
1065
|
+
if (val === '') {
|
1066
|
+
val = '""';
|
1067
|
+
} else {
|
1068
|
+
if (key === "style") {
|
1069
|
+
val = val.substr(1, val.length - 2);
|
1070
|
+
val = val.replace(/\s*([^\s]+?)\s*:(.*?)(;|$)/g, function($0, $1, $2) {
|
1071
|
+
var k = $1.toLowerCase();
|
1072
|
+
if (isFilter) {
|
1073
|
+
if (typeof htmlTagHash[tagName]['style'] == "undefined" && typeof htmlTagHash[tagName]['.' + k] == "undefined") return '';
|
1074
|
+
}
|
1075
|
+
var v = KE.util.trim($2);
|
1076
|
+
v = KE.util.rgbToHex(v);
|
1077
|
+
return k + ':' + v + ';';
|
1078
|
+
});
|
1079
|
+
val = KE.util.trim(val);
|
1080
|
+
if (val === '') return '';
|
1081
|
+
val = '"' + val + '"';
|
1082
|
+
}
|
1083
|
+
if (KE.util.inArray(key, ['src', 'href'])) {
|
1084
|
+
if (val.charAt(0) === '"') {
|
1085
|
+
val = val.substr(1, val.length - 2);
|
1086
|
+
}
|
1087
|
+
val = KE.format.getUrl(val, urlType);
|
1088
|
+
}
|
1089
|
+
if (val.charAt(0) !== '"') val = '"' + val + '"';
|
1090
|
+
}
|
1091
|
+
return ' ' + key + '=' + val + ' ';
|
1092
|
+
});
|
1093
|
+
attr = attr.replace(/\s+(checked|selected|disabled|readonly)(\s+|$)/ig, function($0, $1) {
|
1094
|
+
var key = $1.toLowerCase();
|
1095
|
+
if (isFilter) {
|
1096
|
+
if (key.charAt(0) === "." || typeof htmlTagHash[tagName][key] == "undefined") return ' ';
|
1097
|
+
}
|
1098
|
+
return ' ' + key + '="' + key + '"' + ' ';
|
1099
|
+
});
|
1100
|
+
attr = KE.util.trim(attr);
|
1101
|
+
attr = attr.replace(/\s+/g, ' ');
|
1102
|
+
if (attr) attr = ' ' + attr;
|
1103
|
+
return startNewline + '<' + startSlash + tagName + attr + endSlash + '>' + endNewline;
|
1104
|
+
} else {
|
1105
|
+
return startNewline + '<' + startSlash + tagName + endSlash + '>' + endNewline;
|
1106
|
+
}
|
1107
|
+
});
|
1108
|
+
if (!KE.browser.IE) {
|
1109
|
+
html = html.replace(/<p><br\s+\/>\n<\/p>/ig, '<p> </p>');
|
1110
|
+
html = html.replace(/<br\s+\/>\n<\/p>/ig, '</p>');
|
1111
|
+
}
|
1112
|
+
var reg = KE.setting.inlineTags.join('|');
|
1113
|
+
var trimHtml = function(inHtml) {
|
1114
|
+
var outHtml = inHtml.replace(new RegExp('<(' + reg + ')[^>]*><\\/(' + reg + ')>', 'ig'), function($0, $1, $2) {
|
1115
|
+
if ($1 == $2) return '';
|
1116
|
+
else return $0;
|
1117
|
+
});
|
1118
|
+
if (inHtml !== outHtml) outHtml = trimHtml(outHtml);
|
1119
|
+
return outHtml;
|
1120
|
+
};
|
1121
|
+
return KE.util.trim(trimHtml(html));
|
1122
|
+
}
|
1123
|
+
};
|
1124
|
+
|
1125
|
+
KE.addClass = function(el, className) {
|
1126
|
+
if (typeof el == 'object') {
|
1127
|
+
var cls = el.className;
|
1128
|
+
if (cls) {
|
1129
|
+
if ((' ' + cls + ' ').indexOf(' ' + className + ' ') < 0) {
|
1130
|
+
el.className = cls + ' ' + className;
|
1131
|
+
}
|
1132
|
+
} else {
|
1133
|
+
el.className = className;
|
1134
|
+
}
|
1135
|
+
} else if (typeof el == 'string') {
|
1136
|
+
if (/\s+class\s*=/.test(el)) {
|
1137
|
+
el = el.replace(/(\s+class=["']?)([^"']*)(["']?[\s>])/, function($0, $1, $2, $3) {
|
1138
|
+
if ((' ' + $2 + ' ').indexOf(' ' + className + ' ') < 0) {
|
1139
|
+
return $2 === '' ? $1 + className + $3 : $1 + $2 + ' ' + className + $3;
|
1140
|
+
} else {
|
1141
|
+
return $0;
|
1142
|
+
}
|
1143
|
+
});
|
1144
|
+
} else {
|
1145
|
+
el = el.substr(0, el.length - 1) + ' class="' + className + '">';
|
1146
|
+
}
|
1147
|
+
}
|
1148
|
+
return el;
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
KE.removeClass = function(el, className) {
|
1152
|
+
var cls = el.className || '';
|
1153
|
+
cls = ' ' + cls + ' ';
|
1154
|
+
className = ' ' + className + ' ';
|
1155
|
+
if (cls.indexOf(className) >= 0) {
|
1156
|
+
cls = KE.util.trim(cls.replace(new RegExp(className, 'ig'), ''));
|
1157
|
+
if (cls === '') {
|
1158
|
+
var key = el.getAttribute('class') ? 'class' : 'className';
|
1159
|
+
el.removeAttribute(key);
|
1160
|
+
} else {
|
1161
|
+
el.className = cls;
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
return el;
|
1165
|
+
};
|
1166
|
+
|
1167
|
+
KE.getComputedStyle = function(el, key) {
|
1168
|
+
var doc = el.ownerDocument,
|
1169
|
+
win = doc.parentWindow || doc.defaultView,
|
1170
|
+
jsKey = KE.util.getJsKey(key),
|
1171
|
+
val = '';
|
1172
|
+
if (win.getComputedStyle) {
|
1173
|
+
var style = win.getComputedStyle(el, null);
|
1174
|
+
val = style[jsKey] || style.getPropertyValue(key) || el.style[jsKey];
|
1175
|
+
} else if (el.currentStyle) {
|
1176
|
+
val = el.currentStyle[jsKey] || el.style[jsKey];
|
1177
|
+
}
|
1178
|
+
return val;
|
1179
|
+
};
|
1180
|
+
|
1181
|
+
KE.getCommonAncestor = function(keSel, tagName) {
|
1182
|
+
var range = keSel.range,
|
1183
|
+
keRange = keSel.keRange,
|
1184
|
+
startNode = keRange.startNode,
|
1185
|
+
endNode = keRange.endNode;
|
1186
|
+
if (KE.util.inArray(tagName, ['table', 'td', 'tr'])) {
|
1187
|
+
if (KE.browser.IE) {
|
1188
|
+
if (range.item) {
|
1189
|
+
if (range.item(0).nodeName.toLowerCase() === tagName) {
|
1190
|
+
startNode = endNode = range.item(0);
|
1191
|
+
}
|
1192
|
+
} else {
|
1193
|
+
var rangeA = range.duplicate();
|
1194
|
+
rangeA.collapse(true);
|
1195
|
+
var rangeB = range.duplicate();
|
1196
|
+
rangeB.collapse(false);
|
1197
|
+
startNode = rangeA.parentElement();
|
1198
|
+
endNode = rangeB.parentElement();
|
1199
|
+
}
|
1200
|
+
} else {
|
1201
|
+
var rangeA = range.cloneRange();
|
1202
|
+
rangeA.collapse(true);
|
1203
|
+
var rangeB = range.cloneRange();
|
1204
|
+
rangeB.collapse(false);
|
1205
|
+
startNode = rangeA.startContainer;
|
1206
|
+
endNode = rangeB.startContainer;
|
1207
|
+
}
|
1208
|
+
}
|
1209
|
+
function find(node) {
|
1210
|
+
while (node) {
|
1211
|
+
if (node.nodeType == 1) {
|
1212
|
+
if (node.tagName.toLowerCase() === tagName) return node;
|
1213
|
+
}
|
1214
|
+
node = node.parentNode;
|
1215
|
+
}
|
1216
|
+
return null;
|
1217
|
+
};
|
1218
|
+
var start = find(startNode),
|
1219
|
+
end = find(endNode);
|
1220
|
+
if (start && end && start === end) {
|
1221
|
+
return start;
|
1222
|
+
}
|
1223
|
+
return null;
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
KE.queryCommandValue = function(doc, cmd) {
|
1227
|
+
cmd = cmd.toLowerCase();
|
1228
|
+
function commandValue() {
|
1229
|
+
var val = doc.queryCommandValue(cmd);
|
1230
|
+
if (typeof val !== 'string') val = '';
|
1231
|
+
return val;
|
1232
|
+
}
|
1233
|
+
var val = '';
|
1234
|
+
if (cmd === 'fontname') {
|
1235
|
+
val = commandValue();
|
1236
|
+
val = val.replace(/['"]/g, '');
|
1237
|
+
} else if (cmd === 'formatblock') {
|
1238
|
+
val = commandValue();
|
1239
|
+
if (val === '') {
|
1240
|
+
var keSel = new KE.selection(doc);
|
1241
|
+
var el = KE.getCommonAncestor(keSel, 'h1');
|
1242
|
+
if (!el) el = KE.getCommonAncestor(keSel, 'h2');
|
1243
|
+
if (!el) el = KE.getCommonAncestor(keSel, 'h3');
|
1244
|
+
if (!el) el = KE.getCommonAncestor(keSel, 'h4');
|
1245
|
+
if (!el) el = KE.getCommonAncestor(keSel, 'p');
|
1246
|
+
if (el) val = el.nodeName;
|
1247
|
+
}
|
1248
|
+
if (val === 'Normal') val = 'p';
|
1249
|
+
} else if (cmd === 'fontsize') {
|
1250
|
+
var keSel = new KE.selection(doc);
|
1251
|
+
var el = KE.getCommonAncestor(keSel, 'span');
|
1252
|
+
if (el) val = KE.getComputedStyle(el, 'font-size');
|
1253
|
+
} else if (cmd === 'textcolor') {
|
1254
|
+
var keSel = new KE.selection(doc);
|
1255
|
+
var el = KE.getCommonAncestor(keSel, 'span');
|
1256
|
+
if (el) val = KE.getComputedStyle(el, 'color');
|
1257
|
+
val = KE.util.rgbToHex(val);
|
1258
|
+
if (val === '') val = 'default';
|
1259
|
+
} else if (cmd === 'bgcolor') {
|
1260
|
+
var keSel = new KE.selection(doc);
|
1261
|
+
var el = KE.getCommonAncestor(keSel, 'span');
|
1262
|
+
if (el) val = KE.getComputedStyle(el, 'background-color');
|
1263
|
+
val = KE.util.rgbToHex(val);
|
1264
|
+
if (val === '') val = 'default';
|
1265
|
+
}
|
1266
|
+
return val.toLowerCase();
|
1267
|
+
};
|
1268
|
+
|
1269
|
+
KE.util = {
|
1270
|
+
getDocumentElement : function(doc) {
|
1271
|
+
doc = doc || document;
|
1272
|
+
return (doc.compatMode != "CSS1Compat") ? doc.body : doc.documentElement;
|
1273
|
+
},
|
1274
|
+
getDocumentHeight : function(doc) {
|
1275
|
+
var el = this.getDocumentElement(doc);
|
1276
|
+
return Math.max(el.scrollHeight, el.clientHeight);
|
1277
|
+
},
|
1278
|
+
getDocumentWidth : function(doc) {
|
1279
|
+
var el = this.getDocumentElement(doc);
|
1280
|
+
return Math.max(el.scrollWidth, el.clientWidth);
|
1281
|
+
},
|
1282
|
+
createTable : function(doc) {
|
1283
|
+
var table = KE.$$('table', doc);
|
1284
|
+
table.cellPadding = 0;
|
1285
|
+
table.cellSpacing = 0;
|
1286
|
+
table.border = 0;
|
1287
|
+
return {table: table, cell: table.insertRow(0).insertCell(0)};
|
1288
|
+
},
|
1289
|
+
loadStyle : function(path) {
|
1290
|
+
var link = KE.$$('link');
|
1291
|
+
link.setAttribute('type', 'text/css');
|
1292
|
+
link.setAttribute('rel', 'stylesheet');
|
1293
|
+
link.setAttribute('href', path);
|
1294
|
+
document.getElementsByTagName("head")[0].appendChild(link);
|
1295
|
+
},
|
1296
|
+
getAttrList : function(tag) {
|
1297
|
+
var re = /\s+(?:([\w-:]+)|(?:([\w-:]+)=([\w-:]+))|(?:([\w-:]+)="([^"]*)")|(?:([\w-:]+)='([^']*)'))(?=(?:\s|\/|>)+)/g;
|
1298
|
+
var arr, key, val, list = {};
|
1299
|
+
while ((arr = re.exec(tag))) {
|
1300
|
+
key = arr[1] || arr[2] || arr[4] || arr[6];
|
1301
|
+
val = arr[1] || (arr[2] ? arr[3] : (arr[4] ? arr[5] : arr[7]));
|
1302
|
+
list[key] = val;
|
1303
|
+
}
|
1304
|
+
return list;
|
1305
|
+
},
|
1306
|
+
inArray : function(str, arr) {
|
1307
|
+
for (var i = 0; i < arr.length; i++) {if (str == arr[i]) return true;}
|
1308
|
+
return false;
|
1309
|
+
},
|
1310
|
+
trim : function(str) {
|
1311
|
+
return str.replace(/^\s+|\s+$/g, "");
|
1312
|
+
},
|
1313
|
+
getJsKey : function(key) {
|
1314
|
+
var arr = key.split('-');
|
1315
|
+
key = '';
|
1316
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
1317
|
+
key += (i > 0) ? arr[i].charAt(0).toUpperCase() + arr[i].substr(1) : arr[i];
|
1318
|
+
}
|
1319
|
+
return key;
|
1320
|
+
},
|
1321
|
+
arrayToHash : function(arr) {
|
1322
|
+
var hash = {};
|
1323
|
+
for (var i = 0, len = arr.length; i < len; i++) hash[arr[i]] = 1;
|
1324
|
+
return hash;
|
1325
|
+
},
|
1326
|
+
escape : function(str) {
|
1327
|
+
str = str.replace(/&/g, '&');
|
1328
|
+
str = str.replace(/</g, '<');
|
1329
|
+
str = str.replace(/>/g, '>');
|
1330
|
+
str = str.replace(/"/g, '"');
|
1331
|
+
return str;
|
1332
|
+
},
|
1333
|
+
unescape : function(str) {
|
1334
|
+
str = str.replace(/</g, '<');
|
1335
|
+
str = str.replace(/>/g, '>');
|
1336
|
+
str = str.replace(/"/g, '"');
|
1337
|
+
str = str.replace(/&/g, '&');
|
1338
|
+
return str;
|
1339
|
+
},
|
1340
|
+
getScrollPos : function() {
|
1341
|
+
var x, y;
|
1342
|
+
if (KE.browser.IE || KE.browser.OPERA) {
|
1343
|
+
var el = this.getDocumentElement();
|
1344
|
+
x = el.scrollLeft;
|
1345
|
+
y = el.scrollTop;
|
1346
|
+
} else {
|
1347
|
+
x = window.scrollX;
|
1348
|
+
y = window.scrollY;
|
1349
|
+
}
|
1350
|
+
return {x : x, y : y};
|
1351
|
+
},
|
1352
|
+
getElementPos : function(el) {
|
1353
|
+
var x = 0, y = 0;
|
1354
|
+
if (el.getBoundingClientRect) {
|
1355
|
+
var box = el.getBoundingClientRect();
|
1356
|
+
var pos = this.getScrollPos();
|
1357
|
+
x = box.left + pos.x;
|
1358
|
+
y = box.top + pos.y;
|
1359
|
+
} else {
|
1360
|
+
x = el.offsetLeft;
|
1361
|
+
y = el.offsetTop;
|
1362
|
+
var parent = el.offsetParent;
|
1363
|
+
while (parent) {
|
1364
|
+
x += parent.offsetLeft;
|
1365
|
+
y += parent.offsetTop;
|
1366
|
+
parent = parent.offsetParent;
|
1367
|
+
}
|
1368
|
+
}
|
1369
|
+
return {x : x, y : y};
|
1370
|
+
},
|
1371
|
+
getCoords : function(ev) {
|
1372
|
+
ev = ev || window.event;
|
1373
|
+
return {
|
1374
|
+
x : ev.clientX,
|
1375
|
+
y : ev.clientY
|
1376
|
+
};
|
1377
|
+
},
|
1378
|
+
setOpacity : function(el, opacity) {
|
1379
|
+
if (typeof el.style.opacity == "undefined") {
|
1380
|
+
el.style.filter = (opacity == 100) ? "" : "alpha(opacity=" + opacity + ")";
|
1381
|
+
} else {
|
1382
|
+
el.style.opacity = (opacity == 100) ? "" : "0." + opacity.toString();
|
1383
|
+
}
|
1384
|
+
},
|
1385
|
+
getIframeDoc : function(iframe) {
|
1386
|
+
return iframe.contentDocument || iframe.contentWindow.document;
|
1387
|
+
},
|
1388
|
+
rgbToHex : function(str) {
|
1389
|
+
function hex(s) {
|
1390
|
+
s = parseInt(s).toString(16);
|
1391
|
+
return s.length > 1 ? s : '0' + s;
|
1392
|
+
};
|
1393
|
+
return str.replace(/rgb\s*?\(\s*?(\d+)\s*?,\s*?(\d+)\s*?,\s*?(\d+)\s*?\)/ig,
|
1394
|
+
function($0, $1, $2, $3) {
|
1395
|
+
return '#' + hex($1) + hex($2) + hex($3);
|
1396
|
+
}
|
1397
|
+
);
|
1398
|
+
},
|
1399
|
+
parseJson : function (text) {
|
1400
|
+
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
1401
|
+
cx.lastIndex = 0;
|
1402
|
+
if (cx.test(text)) {
|
1403
|
+
text = text.replace(cx, function (a) {
|
1404
|
+
return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
1405
|
+
});
|
1406
|
+
}
|
1407
|
+
if (/^[\],:{}\s]*$/.
|
1408
|
+
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
1409
|
+
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
1410
|
+
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
1411
|
+
return eval('(' + text + ')');
|
1412
|
+
}
|
1413
|
+
throw 'JSON parse error';
|
1414
|
+
},
|
1415
|
+
createRange : function(doc) {
|
1416
|
+
return doc.createRange ? doc.createRange() : doc.body.createTextRange();
|
1417
|
+
},
|
1418
|
+
getNodeType : function(node) {
|
1419
|
+
return (node.nodeType == 1 && KE.util.inArray(node.tagName.toLowerCase(), KE.setting.noEndTags)) ? 88 : node.nodeType;
|
1420
|
+
},
|
1421
|
+
inMarquee : function(node) {
|
1422
|
+
var n = node;
|
1423
|
+
while (n) {
|
1424
|
+
if (n.nodeName.toLowerCase() === 'marquee') return true;
|
1425
|
+
n = n.parentNode;
|
1426
|
+
}
|
1427
|
+
return false;
|
1428
|
+
},
|
1429
|
+
moveToElementText : function (range, el) {
|
1430
|
+
if (!this.inMarquee(el)) range.moveToElementText(el);
|
1431
|
+
},
|
1432
|
+
getNodeTextLength : function(node) {
|
1433
|
+
var type = KE.util.getNodeType(node);
|
1434
|
+
if (type == 1) {
|
1435
|
+
var html = node.innerHTML;
|
1436
|
+
return html.replace(/<.*?>/ig, "").length;
|
1437
|
+
} else if (type == 3) {
|
1438
|
+
return node.nodeValue.length;
|
1439
|
+
}
|
1440
|
+
},
|
1441
|
+
getNodeStartRange : function(doc, node) {
|
1442
|
+
var range = KE.util.createRange(doc);
|
1443
|
+
var type = node.nodeType;
|
1444
|
+
if (type == 1) {
|
1445
|
+
KE.util.moveToElementText(range, node);
|
1446
|
+
return range;
|
1447
|
+
} else if (type == 3) {
|
1448
|
+
var offset = 0;
|
1449
|
+
var sibling = node.previousSibling;
|
1450
|
+
while (sibling) {
|
1451
|
+
if (sibling.nodeType == 1) {
|
1452
|
+
var nodeRange = KE.util.createRange(doc);
|
1453
|
+
KE.util.moveToElementText(nodeRange, sibling);
|
1454
|
+
range.setEndPoint('StartToEnd', nodeRange);
|
1455
|
+
range.moveStart('character', offset);
|
1456
|
+
return range;
|
1457
|
+
} else if (sibling.nodeType == 3) {
|
1458
|
+
offset += sibling.nodeValue.length;
|
1459
|
+
}
|
1460
|
+
sibling = sibling.previousSibling;
|
1461
|
+
}
|
1462
|
+
KE.util.moveToElementText(range, node.parentNode);
|
1463
|
+
range.moveStart('character', offset);
|
1464
|
+
return range;
|
1465
|
+
}
|
1466
|
+
},
|
1467
|
+
removeParent : function(parent) {
|
1468
|
+
if (parent.hasChildNodes) {
|
1469
|
+
var node = parent.firstChild;
|
1470
|
+
while (node) {
|
1471
|
+
var nextNode = node.nextSibling;
|
1472
|
+
parent.parentNode.insertBefore(node, parent);
|
1473
|
+
node = nextNode;
|
1474
|
+
}
|
1475
|
+
}
|
1476
|
+
parent.parentNode.removeChild(parent);
|
1477
|
+
},
|
1478
|
+
pluginLang : function(pluginName, doc) {
|
1479
|
+
KE.each(KE.lang.plugins[pluginName], function (key, val) {
|
1480
|
+
var span = KE.$('lang.' + key, doc);
|
1481
|
+
if (span) {
|
1482
|
+
span.parentNode.insertBefore(doc.createTextNode(val), span);
|
1483
|
+
span.parentNode.removeChild(span);
|
1484
|
+
}
|
1485
|
+
});
|
1486
|
+
},
|
1487
|
+
drag : function(id, mousedownObj, moveObj, func) {
|
1488
|
+
var g = KE.g[id];
|
1489
|
+
mousedownObj.onmousedown = function(e) {
|
1490
|
+
var self = this;
|
1491
|
+
e = e || window.event;
|
1492
|
+
var pos = KE.util.getCoords(e);
|
1493
|
+
var objTop = parseInt(moveObj.style.top);
|
1494
|
+
var objLeft = parseInt(moveObj.style.left);
|
1495
|
+
var objWidth = moveObj.style.width;
|
1496
|
+
var objHeight = moveObj.style.height;
|
1497
|
+
if (objWidth.match(/%$/)) objWidth = moveObj.offsetWidth + 'px';
|
1498
|
+
if (objHeight.match(/%$/)) objHeight = moveObj.offsetHeight + 'px';
|
1499
|
+
objWidth = parseInt(objWidth);
|
1500
|
+
objHeight = parseInt(objHeight);
|
1501
|
+
var mouseTop = pos.y;
|
1502
|
+
var mouseLeft = pos.x;
|
1503
|
+
var scrollPos = KE.util.getScrollPos();
|
1504
|
+
var scrollTop = scrollPos.y;
|
1505
|
+
var scrollLeft = scrollPos.x;
|
1506
|
+
var dragFlag = true;
|
1507
|
+
function moveListener(e) {
|
1508
|
+
if (dragFlag) {
|
1509
|
+
var pos = KE.util.getCoords(e);
|
1510
|
+
var scrollPos = KE.util.getScrollPos();
|
1511
|
+
var top = parseInt(pos.y - mouseTop - scrollTop + scrollPos.y);
|
1512
|
+
var left = parseInt(pos.x - mouseLeft - scrollLeft + scrollPos.x);
|
1513
|
+
func(objTop, objLeft, objWidth, objHeight, top, left);
|
1514
|
+
}
|
1515
|
+
}
|
1516
|
+
var iframePos = KE.util.getElementPos(g.iframe);
|
1517
|
+
function iframeMoveListener(e) {
|
1518
|
+
if (dragFlag) {
|
1519
|
+
var pos = KE.util.getCoords(e, g.iframeDoc);
|
1520
|
+
var top = parseInt(iframePos.y + pos.y - mouseTop - scrollTop);
|
1521
|
+
var left = parseInt(iframePos.x + pos.x - mouseLeft - scrollLeft);
|
1522
|
+
func(objTop, objLeft, objWidth, objHeight, top, left);
|
1523
|
+
}
|
1524
|
+
}
|
1525
|
+
var selectListener = function() { return false; };
|
1526
|
+
function upListener(e) {
|
1527
|
+
dragFlag = false;
|
1528
|
+
if (self.releaseCapture) self.releaseCapture();
|
1529
|
+
KE.event.remove(document, 'mousemove', moveListener);
|
1530
|
+
KE.event.remove(document, 'mouseup', upListener);
|
1531
|
+
KE.event.remove(g.iframeDoc, 'mousemove', iframeMoveListener);
|
1532
|
+
KE.event.remove(g.iframeDoc, 'mouseup', upListener);
|
1533
|
+
KE.event.remove(document, 'selectstart', selectListener);
|
1534
|
+
KE.event.stop(e);
|
1535
|
+
return false;
|
1536
|
+
}
|
1537
|
+
KE.event.add(document, 'mousemove', moveListener);
|
1538
|
+
KE.event.add(document, 'mouseup', upListener);
|
1539
|
+
KE.event.add(g.iframeDoc, 'mousemove', iframeMoveListener);
|
1540
|
+
KE.event.add(g.iframeDoc, 'mouseup', upListener);
|
1541
|
+
KE.event.add(document, 'selectstart', selectListener);
|
1542
|
+
if (self.setCapture) self.setCapture();
|
1543
|
+
KE.event.stop(e);
|
1544
|
+
return false;
|
1545
|
+
};
|
1546
|
+
},
|
1547
|
+
resize : function(id, width, height, isCheck, isResizeWidth) {
|
1548
|
+
isResizeWidth = (typeof isResizeWidth == "undefined") ? true : isResizeWidth;
|
1549
|
+
var g = KE.g[id];
|
1550
|
+
if (!g.container) return;
|
1551
|
+
if (isCheck && (parseInt(width) <= g.minWidth || parseInt(height) <= g.minHeight)) return;
|
1552
|
+
if (isResizeWidth) g.container.style.width = width;
|
1553
|
+
g.container.style.height = height;
|
1554
|
+
var diff = parseInt(height) - g.toolbarHeight - g.statusbarHeight;
|
1555
|
+
if (diff >= 0) {
|
1556
|
+
g.iframe.style.height = diff + 'px';
|
1557
|
+
g.newTextarea.style.height = (((KE.browser.IE && KE.browser.VERSION < 8) || document.compatMode != 'CSS1Compat') ? diff - 2 : diff) + 'px';
|
1558
|
+
}
|
1559
|
+
},
|
1560
|
+
hideLoadingPage : function(id) {
|
1561
|
+
var stack = KE.g[id].dialogStack;
|
1562
|
+
var dialog = stack[stack.length - 1];
|
1563
|
+
dialog.loading.style.display = 'none';
|
1564
|
+
dialog.iframe.style.display = '';
|
1565
|
+
},
|
1566
|
+
showLoadingPage : function(id) {
|
1567
|
+
var stack = KE.g[id].dialogStack;
|
1568
|
+
var dialog = stack[stack.length - 1];
|
1569
|
+
dialog.loading.style.display = '';
|
1570
|
+
dialog.iframe.style.display = 'none';
|
1571
|
+
},
|
1572
|
+
setDefaultPlugin : function(id) {
|
1573
|
+
var items = [
|
1574
|
+
'selectall', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull',
|
1575
|
+
'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
1576
|
+
'superscript', 'bold', 'italic', 'underline', 'strikethrough'
|
1577
|
+
];
|
1578
|
+
var shortcuts = {
|
1579
|
+
bold : 'B',
|
1580
|
+
italic : 'I',
|
1581
|
+
underline : 'U'
|
1582
|
+
};
|
1583
|
+
for (var i = 0; i < items.length; i++) {
|
1584
|
+
var item = items[i],
|
1585
|
+
plugin = {};
|
1586
|
+
if (item in shortcuts) {
|
1587
|
+
plugin.init = (function(item) {
|
1588
|
+
return function(id) {
|
1589
|
+
KE.event.ctrl(KE.g[id].iframeDoc, shortcuts[item], function(e) {
|
1590
|
+
KE.plugin[item].click(id);
|
1591
|
+
KE.util.focus(id);
|
1592
|
+
}, id);
|
1593
|
+
};
|
1594
|
+
})(item);
|
1595
|
+
}
|
1596
|
+
plugin.click = (function(item) {
|
1597
|
+
return function(id) {
|
1598
|
+
KE.util.execCommand(id, item, null);
|
1599
|
+
};
|
1600
|
+
})(item);
|
1601
|
+
KE.plugin[item] = plugin;
|
1602
|
+
}
|
1603
|
+
},
|
1604
|
+
getFullHtml : function(id) {
|
1605
|
+
var html = '<html>';
|
1606
|
+
html += '<head>';
|
1607
|
+
html += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
|
1608
|
+
html += '<title>KindEditor</title>';
|
1609
|
+
html += '<link href="' + KE.g[id].skinsPath + 'common/editor.css?ver=' + escape(KE.version) + '" rel="stylesheet" type="text/css" />';
|
1610
|
+
var cssPath = KE.g[id].cssPath;
|
1611
|
+
if (typeof cssPath == 'string') cssPath = [cssPath];
|
1612
|
+
for (var i = 0, len = cssPath.length; i < len; i++) {
|
1613
|
+
if (cssPath[i] !== '') html += '<link href="' + cssPath[i] + '" rel="stylesheet" type="text/css" />';
|
1614
|
+
}
|
1615
|
+
html += '</head>';
|
1616
|
+
html += '<body class="ke-content"></body>';
|
1617
|
+
html += '</html>';
|
1618
|
+
return html;
|
1619
|
+
},
|
1620
|
+
getMediaType : function(src) {
|
1621
|
+
if (src.match(/\.(rm|rmvb)(\?|$)/i)) return 'rm';
|
1622
|
+
else if (src.match(/\.(swf|flv)(\?|$)/i)) return 'flash';
|
1623
|
+
else return 'media';
|
1624
|
+
},
|
1625
|
+
getMediaImage : function(id, type, attrs) {
|
1626
|
+
var width = attrs.width;
|
1627
|
+
var height = attrs.height;
|
1628
|
+
type = type || this.getMediaType(attrs.src);
|
1629
|
+
var srcTag = this.getMediaEmbed(attrs);
|
1630
|
+
var style = '';
|
1631
|
+
if (width > 0) style += 'width:' + width + 'px;';
|
1632
|
+
if (height > 0) style += 'height:' + height + 'px;';
|
1633
|
+
var className = 'ke-' + type;
|
1634
|
+
var html = '<img class="' + className + '" src="' + KE.g[id].skinsPath + 'common/blank.gif" ';
|
1635
|
+
if (style !== '') html += 'style="' + style + '" ';
|
1636
|
+
html += 'kesrctag="' + escape(srcTag) + '" alt="" />';
|
1637
|
+
return html;
|
1638
|
+
},
|
1639
|
+
getMediaEmbed : function(attrs) {
|
1640
|
+
var html = '<embed ';
|
1641
|
+
KE.each(attrs, function(key, val) {
|
1642
|
+
html += key + '="' + val + '" ';
|
1643
|
+
});
|
1644
|
+
html += '/>';
|
1645
|
+
return html;
|
1646
|
+
},
|
1647
|
+
execGetHtmlHooks : function(id, html) {
|
1648
|
+
var hooks = KE.g[id].getHtmlHooks;
|
1649
|
+
for (var i = 0, len = hooks.length; i < len; i++) {
|
1650
|
+
html = hooks[i](html);
|
1651
|
+
}
|
1652
|
+
return html;
|
1653
|
+
},
|
1654
|
+
execSetHtmlHooks : function(id, html) {
|
1655
|
+
var hooks = KE.g[id].setHtmlHooks;
|
1656
|
+
for (var i = 0, len = hooks.length; i < len; i++) {
|
1657
|
+
html = hooks[i](html);
|
1658
|
+
}
|
1659
|
+
return html;
|
1660
|
+
},
|
1661
|
+
execOnchangeHandler : function(id) {
|
1662
|
+
var handlers = KE.g[id].onchangeHandlerStack;
|
1663
|
+
for (var i = 0, len = handlers.length; i < len; i++) {
|
1664
|
+
handlers[i]();
|
1665
|
+
}
|
1666
|
+
},
|
1667
|
+
toData : function(id, srcData) {
|
1668
|
+
var g = KE.g[id];
|
1669
|
+
var html = this.execGetHtmlHooks(id, srcData);
|
1670
|
+
html = html.replace(/^\s*<br[^>]*>\s*$/ig, '');
|
1671
|
+
html = html.replace(/^\s*<p>\s* \s*<\/p>\s*$/ig, '');
|
1672
|
+
if (g.filterMode) {
|
1673
|
+
return KE.format.getHtml(html, g.htmlTags, g.urlType);
|
1674
|
+
} else {
|
1675
|
+
return KE.format.getHtml(html, null, g.urlType);
|
1676
|
+
}
|
1677
|
+
},
|
1678
|
+
getData : function(id, wyswygMode) {
|
1679
|
+
var g = KE.g[id];
|
1680
|
+
wyswygMode = (wyswygMode === undefined) ? g.wyswygMode : wyswygMode;
|
1681
|
+
if (!wyswygMode) {
|
1682
|
+
this.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, g.newTextarea.value));
|
1683
|
+
}
|
1684
|
+
return this.toData(id, g.iframeDoc.body.innerHTML);
|
1685
|
+
},
|
1686
|
+
getSrcData : function(id) {
|
1687
|
+
var g = KE.g[id];
|
1688
|
+
if (!g.wyswygMode) {
|
1689
|
+
this.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, g.newTextarea.value));
|
1690
|
+
}
|
1691
|
+
return g.iframeDoc.body.innerHTML;
|
1692
|
+
},
|
1693
|
+
getPureData : function(id) {
|
1694
|
+
return this.extractText(this.getData(id));
|
1695
|
+
},
|
1696
|
+
extractText : function(str) {
|
1697
|
+
str = str.replace(/<(?!img|embed).*?>/ig, '');
|
1698
|
+
str = str.replace(/ /ig, ' ');
|
1699
|
+
return str;
|
1700
|
+
},
|
1701
|
+
isEmpty : function(id) {
|
1702
|
+
return this.getPureData(id).replace(/\r\n|\n|\r/, '').replace(/^\s+|\s+$/, '') === '';
|
1703
|
+
},
|
1704
|
+
setData : function(id) {
|
1705
|
+
var g = KE.g[id];
|
1706
|
+
if (g.srcTextarea) g.srcTextarea.value = this.getData(id);
|
1707
|
+
},
|
1708
|
+
focus : function(id) {
|
1709
|
+
var g = KE.g[id];
|
1710
|
+
if (g.wyswygMode) {
|
1711
|
+
g.iframeWin.focus();
|
1712
|
+
} else {
|
1713
|
+
g.newTextarea.focus();
|
1714
|
+
}
|
1715
|
+
},
|
1716
|
+
click : function(id, cmd) {
|
1717
|
+
this.focus(id);
|
1718
|
+
KE.hideMenu(id);
|
1719
|
+
KE.plugin[cmd].click(id);
|
1720
|
+
},
|
1721
|
+
selection : function(id) {
|
1722
|
+
if (!KE.browser.IE || !KE.g[id].keRange) {
|
1723
|
+
this.setSelection(id);
|
1724
|
+
}
|
1725
|
+
},
|
1726
|
+
setSelection : function(id) {
|
1727
|
+
var g = KE.g[id];
|
1728
|
+
var keSel = new KE.selection(g.iframeDoc);
|
1729
|
+
if (!KE.browser.IE || keSel.range.item || keSel.range.parentElement().ownerDocument === g.iframeDoc) {
|
1730
|
+
g.keSel = keSel;
|
1731
|
+
g.keRange = g.keSel.keRange;
|
1732
|
+
g.sel = g.keSel.sel;
|
1733
|
+
g.range = g.keSel.range;
|
1734
|
+
}
|
1735
|
+
},
|
1736
|
+
select : function(id) {
|
1737
|
+
if (KE.browser.IE && KE.g[id].wyswygMode && KE.g[id].range) KE.g[id].range.select();
|
1738
|
+
},
|
1739
|
+
execCommand : function(id, cmd, value) {
|
1740
|
+
KE.util.focus(id);
|
1741
|
+
KE.util.select(id);
|
1742
|
+
try {
|
1743
|
+
KE.g[id].iframeDoc.execCommand(cmd, false, value);
|
1744
|
+
} catch(e) {}
|
1745
|
+
KE.toolbar.updateState(id);
|
1746
|
+
KE.util.execOnchangeHandler(id);
|
1747
|
+
},
|
1748
|
+
innerHtml : function(el, html) {
|
1749
|
+
if (KE.browser.IE) {
|
1750
|
+
el.innerHTML = '<img id="__ke_temp_tag__" width="0" height="0" />' + html;
|
1751
|
+
var temp = KE.$('__ke_temp_tag__', el.ownerDocument);
|
1752
|
+
if (temp) temp.parentNode.removeChild(temp);
|
1753
|
+
} else {
|
1754
|
+
el.innerHTML = html;
|
1755
|
+
}
|
1756
|
+
},
|
1757
|
+
pasteHtml : function(id, html, isStart) {
|
1758
|
+
var g = KE.g[id];
|
1759
|
+
var imgStr = '<img id="__ke_temp_tag__" width="0" height="0" />';
|
1760
|
+
if (isStart) html = imgStr + html;
|
1761
|
+
else html += imgStr;
|
1762
|
+
if (KE.browser.IE) {
|
1763
|
+
if (g.range.item) g.range.item(0).outerHTML = html;
|
1764
|
+
else g.range.pasteHTML(html);
|
1765
|
+
} else {
|
1766
|
+
g.range.deleteContents();
|
1767
|
+
var frag = g.range.createContextualFragment(html);
|
1768
|
+
g.range.insertNode(frag);
|
1769
|
+
}
|
1770
|
+
var node = KE.$('__ke_temp_tag__', g.iframeDoc);
|
1771
|
+
var blank = g.iframeDoc.createTextNode('');
|
1772
|
+
node.parentNode.replaceChild(blank, node);
|
1773
|
+
g.keRange.selectNode(blank);
|
1774
|
+
g.keSel.addRange(g.keRange);
|
1775
|
+
},
|
1776
|
+
insertHtml : function(id, html) {
|
1777
|
+
if (html === '') return;
|
1778
|
+
var g = KE.g[id];
|
1779
|
+
if (!g.wyswygMode) return;
|
1780
|
+
if (!g.range) return;
|
1781
|
+
html = this.execSetHtmlHooks(id, html);
|
1782
|
+
if (KE.browser.IE) {
|
1783
|
+
this.select(id);
|
1784
|
+
if (g.range.item) {
|
1785
|
+
try {
|
1786
|
+
g.range.item(0).outerHTML = html;
|
1787
|
+
} catch(e) {
|
1788
|
+
var el = g.range.item(0);
|
1789
|
+
var parent = el.parentNode;
|
1790
|
+
parent.removeChild(el);
|
1791
|
+
if (parent.nodeName.toLowerCase() != 'body') parent = parent.parentNode;
|
1792
|
+
this.innerHtml(parent, html + parent.innerHTML);
|
1793
|
+
}
|
1794
|
+
} else {
|
1795
|
+
g.range.pasteHTML(html);
|
1796
|
+
}
|
1797
|
+
} else if (KE.browser.GECKO && KE.browser.VERSION < 3) {
|
1798
|
+
this.execCommand(id, 'inserthtml', html);
|
1799
|
+
return;
|
1800
|
+
} else {
|
1801
|
+
this.pasteHtml(id, html);
|
1802
|
+
}
|
1803
|
+
KE.util.execOnchangeHandler(id);
|
1804
|
+
},
|
1805
|
+
setFullHtml : function(id, html) {
|
1806
|
+
var g = KE.g[id];
|
1807
|
+
if (!KE.browser.IE && html === '') html = '<br />';
|
1808
|
+
var html = KE.util.execSetHtmlHooks(id, html);
|
1809
|
+
this.innerHtml(g.iframeDoc.body, html);
|
1810
|
+
if (!g.wyswygMode) g.newTextarea.value = KE.util.getData(id, true);
|
1811
|
+
KE.util.execOnchangeHandler(id);
|
1812
|
+
},
|
1813
|
+
selectImageWebkit : function(id, e, isSelection) {
|
1814
|
+
if (KE.browser.WEBKIT) {
|
1815
|
+
var target = e.srcElement || e.target;
|
1816
|
+
if (target.tagName.toLowerCase() == 'img') {
|
1817
|
+
if (isSelection) KE.util.selection(id);
|
1818
|
+
var range = KE.g[id].keRange;
|
1819
|
+
range.selectNode(target);
|
1820
|
+
KE.g[id].keSel.addRange(range);
|
1821
|
+
}
|
1822
|
+
}
|
1823
|
+
},
|
1824
|
+
addTabEvent : function(id) {
|
1825
|
+
KE.event.add(KE.g[id].iframeDoc, 'keydown', function(e) {
|
1826
|
+
if (e.keyCode == 9) {
|
1827
|
+
KE.util.setSelection(id);
|
1828
|
+
KE.util.insertHtml(id, ' ');
|
1829
|
+
KE.event.stop(e);
|
1830
|
+
return false;
|
1831
|
+
}
|
1832
|
+
}, id);
|
1833
|
+
},
|
1834
|
+
addContextmenuEvent : function(id) {
|
1835
|
+
var g = KE.g[id];
|
1836
|
+
if (g.contextmenuItems.length == 0) return;
|
1837
|
+
KE.event.add(g.iframeDoc, 'contextmenu', function(e){
|
1838
|
+
KE.hideMenu(id);
|
1839
|
+
KE.util.setSelection(id);
|
1840
|
+
KE.util.selectImageWebkit(id, e, false);
|
1841
|
+
var maxWidth = 0;
|
1842
|
+
var items = [];
|
1843
|
+
for (var i = 0, len = g.contextmenuItems.length; i < len; i++) {
|
1844
|
+
var item = g.contextmenuItems[i];
|
1845
|
+
if (item === '-') {
|
1846
|
+
items.push(item);
|
1847
|
+
} else if (item.cond && item.cond(id)) {
|
1848
|
+
items.push(item);
|
1849
|
+
if (item.options) {
|
1850
|
+
var width = parseInt(item.options.width) || 0;
|
1851
|
+
if (width > maxWidth) maxWidth = width;
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
prevItem = item;
|
1855
|
+
}
|
1856
|
+
while (items.length > 0 && items[0] === '-') {
|
1857
|
+
items.shift();
|
1858
|
+
}
|
1859
|
+
while (items.length > 0 && items[items.length - 1] === '-') {
|
1860
|
+
items.pop();
|
1861
|
+
}
|
1862
|
+
var prevItem = null;
|
1863
|
+
for (var i = 0, len = items.length; i < len; i++) {
|
1864
|
+
if (items[i] === '-' && prevItem === '-') delete items[i];
|
1865
|
+
prevItem = items[i] || null;
|
1866
|
+
}
|
1867
|
+
if (items.length > 0) {
|
1868
|
+
var menu = new KE.menu({
|
1869
|
+
id : id,
|
1870
|
+
event : e,
|
1871
|
+
type : 'contextmenu',
|
1872
|
+
width : maxWidth
|
1873
|
+
});
|
1874
|
+
for (var i = 0, len = items.length; i < len; i++) {
|
1875
|
+
var item = items[i];
|
1876
|
+
if (!item) continue;
|
1877
|
+
if (item === '-') {
|
1878
|
+
if (i < len - 1) menu.addSeparator();
|
1879
|
+
} else {
|
1880
|
+
menu.add(item.text, (function(item) {
|
1881
|
+
return function() {
|
1882
|
+
item.click(id, menu);
|
1883
|
+
};
|
1884
|
+
})(item), item.options);
|
1885
|
+
}
|
1886
|
+
}
|
1887
|
+
menu.show();
|
1888
|
+
KE.event.stop(e);
|
1889
|
+
return false;
|
1890
|
+
}
|
1891
|
+
return true;
|
1892
|
+
}, id);
|
1893
|
+
},
|
1894
|
+
addNewlineEvent : function(id) {
|
1895
|
+
var g = KE.g[id];
|
1896
|
+
if (KE.browser.IE && g.newlineTag.toLowerCase() != 'br') return;
|
1897
|
+
if (KE.browser.GECKO && KE.browser.VERSION < 3 && g.newlineTag.toLowerCase() != 'p') return;
|
1898
|
+
if (KE.browser.OPERA) return;
|
1899
|
+
KE.event.add(g.iframeDoc, 'keydown', function(e) {
|
1900
|
+
if (e.keyCode != 13 || e.shiftKey || e.ctrlKey || e.altKey) return true;
|
1901
|
+
KE.util.setSelection(id);
|
1902
|
+
var parent = g.keRange.getParentElement();
|
1903
|
+
if (KE.util.inMarquee(parent)) return;
|
1904
|
+
var tagName = parent.tagName.toLowerCase();
|
1905
|
+
if (g.newlineTag.toLowerCase() == 'br') {
|
1906
|
+
if (!KE.util.inArray(tagName, ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li'])) {
|
1907
|
+
KE.util.pasteHtml(id, '<br />');
|
1908
|
+
var nextNode = g.keRange.startNode.nextSibling;
|
1909
|
+
if (KE.browser.IE) {
|
1910
|
+
if (!nextNode) KE.util.pasteHtml(id, '<br />', true);
|
1911
|
+
} else if (KE.browser.WEBKIT) {
|
1912
|
+
if (!nextNode) {
|
1913
|
+
KE.util.pasteHtml(id, '<br />', true);
|
1914
|
+
} else {
|
1915
|
+
var range = new KE.range(g.iframeDoc);
|
1916
|
+
range.selectNode(nextNode.parentNode);
|
1917
|
+
range.setStart(nextNode, 0);
|
1918
|
+
if (range.cloneContents().innerHTML.replace(/<(?!img|embed).*?>/ig, '') === '') {
|
1919
|
+
KE.util.pasteHtml(id, '<br />', true);
|
1920
|
+
}
|
1921
|
+
}
|
1922
|
+
}
|
1923
|
+
KE.event.stop(e);
|
1924
|
+
return false;
|
1925
|
+
}
|
1926
|
+
} else {
|
1927
|
+
if (!KE.util.inArray(tagName, ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'div', 'li'])) {
|
1928
|
+
KE.util.execCommand(id, 'formatblock', '<P>');
|
1929
|
+
}
|
1930
|
+
}
|
1931
|
+
return true;
|
1932
|
+
}, id);
|
1933
|
+
}
|
1934
|
+
};
|
1935
|
+
|
1936
|
+
KE.layout = {
|
1937
|
+
hide : function(id) {
|
1938
|
+
var g = KE.g[id];
|
1939
|
+
KE.hideMenu(id);
|
1940
|
+
var stack = g.dialogStack;
|
1941
|
+
while (stack.length > 0) {
|
1942
|
+
var dialog = stack[stack.length - 1];
|
1943
|
+
dialog.hide();
|
1944
|
+
}
|
1945
|
+
g.maskDiv.style.display = 'none';
|
1946
|
+
}
|
1947
|
+
};
|
1948
|
+
|
1949
|
+
KE.hideMenu = function(id) {
|
1950
|
+
var g = KE.g[id];
|
1951
|
+
g.hideDiv.innerHTML = '';
|
1952
|
+
g.hideDiv.style.display = 'none';
|
1953
|
+
};
|
1954
|
+
|
1955
|
+
KE.colorpicker = function(arg) {
|
1956
|
+
var wrapper;
|
1957
|
+
var x = arg.x || 0;
|
1958
|
+
var y = arg.y || 0;
|
1959
|
+
var z = arg.z || 0;
|
1960
|
+
var colors = arg.colors || KE.setting.colorTable;
|
1961
|
+
var doc = arg.doc || document;
|
1962
|
+
var onclick = arg.onclick;
|
1963
|
+
var selectedColor = (arg.selectedColor || '').toLowerCase();
|
1964
|
+
function init() {
|
1965
|
+
wrapper = KE.$$('div');
|
1966
|
+
wrapper.className = 'ke-colorpicker';
|
1967
|
+
wrapper.style.top = y + 'px';
|
1968
|
+
wrapper.style.left = x + 'px';
|
1969
|
+
wrapper.style.zIndex = z;
|
1970
|
+
}
|
1971
|
+
init.call(this);
|
1972
|
+
this.remove = function() {
|
1973
|
+
doc.body.removeChild(wrapper);
|
1974
|
+
};
|
1975
|
+
this.getElement = function() {
|
1976
|
+
function addAttr(cell, color, cls) {
|
1977
|
+
if (selectedColor === color.toLowerCase()) cls += ' ke-colorpicker-cell-selected';
|
1978
|
+
cell.className = cls;
|
1979
|
+
cell.title = color || KE.lang['noColor'];
|
1980
|
+
cell.onmouseover = function() { this.className = cls + ' ke-colorpicker-cell-on'; };
|
1981
|
+
cell.onmouseout = function() { this.className = cls; };
|
1982
|
+
cell.onclick = function() { onclick(color); };
|
1983
|
+
if (color) {
|
1984
|
+
var div = KE.$$('div');
|
1985
|
+
div.className = 'ke-colorpicker-cell-color';
|
1986
|
+
div.style.backgroundColor = color;
|
1987
|
+
cell.appendChild(div);
|
1988
|
+
} else {
|
1989
|
+
cell.innerHTML = KE.lang['noColor'];
|
1990
|
+
}
|
1991
|
+
}
|
1992
|
+
var table = KE.$$('table');
|
1993
|
+
table.className = 'ke-colorpicker-table';
|
1994
|
+
table.cellPadding = 0;
|
1995
|
+
table.cellSpacing = 0;
|
1996
|
+
table.border = 0;
|
1997
|
+
var row = table.insertRow(0),
|
1998
|
+
cell = row.insertCell(0);
|
1999
|
+
cell.colSpan = colors[0].length;
|
2000
|
+
addAttr(cell, '', 'ke-colorpicker-cell-top');
|
2001
|
+
for (var i = 0; i < colors.length; i++) {
|
2002
|
+
var row = table.insertRow(i + 1);
|
2003
|
+
for (var j = 0; j < colors[i].length; j++) {
|
2004
|
+
var color = colors[i][j],
|
2005
|
+
cell = row.insertCell(j);
|
2006
|
+
addAttr(cell, color, 'ke-colorpicker-cell');
|
2007
|
+
}
|
2008
|
+
}
|
2009
|
+
return table;
|
2010
|
+
};
|
2011
|
+
this.create = function() {
|
2012
|
+
wrapper.appendChild(this.getElement());
|
2013
|
+
KE.event.bind(wrapper, 'click', function(e){});
|
2014
|
+
KE.event.bind(wrapper, 'mousedown', function(e){});
|
2015
|
+
doc.body.appendChild(wrapper);
|
2016
|
+
};
|
2017
|
+
};
|
2018
|
+
|
2019
|
+
KE.menu = function(arg){
|
2020
|
+
function getPos(width, height) {
|
2021
|
+
var id = arg.id;
|
2022
|
+
var x = 0;
|
2023
|
+
var y = 0;
|
2024
|
+
if (this.type == 'menu') {
|
2025
|
+
var obj = KE.g[id].toolbarIcon[arg.cmd];
|
2026
|
+
var pos = KE.util.getElementPos(obj[0]);
|
2027
|
+
x = pos.x;
|
2028
|
+
y = pos.y + obj[0].offsetHeight;
|
2029
|
+
} else {
|
2030
|
+
var pos = KE.util.getCoords(arg.event);
|
2031
|
+
var iframePos = KE.util.getElementPos(KE.g[id].iframe);
|
2032
|
+
x = pos.x + iframePos.x;
|
2033
|
+
y = pos.y + iframePos.y + 5;
|
2034
|
+
}
|
2035
|
+
if (width > 0 || height > 0) {
|
2036
|
+
var scrollPos = KE.util.getScrollPos();
|
2037
|
+
var docEl = KE.util.getDocumentElement();
|
2038
|
+
var maxLeft = scrollPos.x + docEl.clientWidth - width - 2;
|
2039
|
+
if (x > maxLeft) x = maxLeft;
|
2040
|
+
}
|
2041
|
+
return {x : x, y : y};
|
2042
|
+
};
|
2043
|
+
function init() {
|
2044
|
+
var width = arg.width;
|
2045
|
+
this.type = (arg.type && arg.type == 'contextmenu') ? arg.type : 'menu';
|
2046
|
+
var div = KE.$$('div');
|
2047
|
+
div.className = 'ke-' + this.type;
|
2048
|
+
div.setAttribute('name', arg.cmd);
|
2049
|
+
var pos = getPos.call(this, 0, 0);
|
2050
|
+
div.style.top = pos.y + 'px';
|
2051
|
+
div.style.left = pos.x + 'px';
|
2052
|
+
if (arg.width) div.style.width = (/^\d+$/.test(width)) ? width + 'px' : width;
|
2053
|
+
KE.event.bind(div, 'click', function(e){}, arg.id);
|
2054
|
+
KE.event.bind(div, 'mousedown', function(e){}, arg.id);
|
2055
|
+
this.div = div;
|
2056
|
+
};
|
2057
|
+
init.call(this);
|
2058
|
+
this.add = function(html, event, options) {
|
2059
|
+
var height, iconHtml, checked = false;
|
2060
|
+
if (options !== undefined) {
|
2061
|
+
height = options.height;
|
2062
|
+
iconHtml = options.iconHtml;
|
2063
|
+
checked = options.checked;
|
2064
|
+
}
|
2065
|
+
var self = this;
|
2066
|
+
var cDiv = KE.$$('div');
|
2067
|
+
cDiv.className = 'ke-' + self.type + '-item';
|
2068
|
+
if (height) cDiv.style.height = height;
|
2069
|
+
var left = KE.$$('div');
|
2070
|
+
left.className = 'ke-' + this.type + '-left';
|
2071
|
+
var center = KE.$$('div');
|
2072
|
+
center.className = 'ke-' + self.type + '-center';
|
2073
|
+
if (height) center.style.height = height;
|
2074
|
+
var right = KE.$$('div');
|
2075
|
+
right.className = 'ke-' + this.type + '-right';
|
2076
|
+
if (height) right.style.lineHeight = height;
|
2077
|
+
cDiv.onmouseover = function() {
|
2078
|
+
this.className = 'ke-' + self.type + '-item ke-' + self.type + '-item-on';
|
2079
|
+
center.className = 'ke-' + self.type + '-center ke-' + self.type + '-center-on';
|
2080
|
+
};
|
2081
|
+
cDiv.onmouseout = function() {
|
2082
|
+
this.className = 'ke-' + self.type + '-item';
|
2083
|
+
center.className = 'ke-' + self.type + '-center';
|
2084
|
+
};
|
2085
|
+
cDiv.onclick = event;
|
2086
|
+
cDiv.appendChild(left);
|
2087
|
+
cDiv.appendChild(center);
|
2088
|
+
cDiv.appendChild(right);
|
2089
|
+
if (checked) {
|
2090
|
+
KE.util.innerHtml(left, '<span class="ke-common-icon ke-common-icon-url ke-icon-checked"></span>');
|
2091
|
+
} else {
|
2092
|
+
if (iconHtml) KE.util.innerHtml(left, iconHtml);
|
2093
|
+
}
|
2094
|
+
KE.util.innerHtml(right, html);
|
2095
|
+
this.append(cDiv);
|
2096
|
+
};
|
2097
|
+
this.addSeparator = function() {
|
2098
|
+
var div = KE.$$('div');
|
2099
|
+
div.className = 'ke-' + this.type + '-separator';
|
2100
|
+
this.append(div);
|
2101
|
+
};
|
2102
|
+
this.append = function(el) {
|
2103
|
+
this.div.appendChild(el);
|
2104
|
+
};
|
2105
|
+
this.insert = function(html) {
|
2106
|
+
KE.util.innerHtml(this.div, html);
|
2107
|
+
};
|
2108
|
+
this.hide = function() {
|
2109
|
+
KE.hideMenu(arg.id);
|
2110
|
+
};
|
2111
|
+
this.show = function() {
|
2112
|
+
this.hide();
|
2113
|
+
var id = arg.id;
|
2114
|
+
KE.g[id].hideDiv.style.display = '';
|
2115
|
+
KE.g[id].hideDiv.appendChild(this.div);
|
2116
|
+
var pos = getPos.call(this, this.div.clientWidth, this.div.clientHeight);
|
2117
|
+
this.div.style.top = pos.y + 'px';
|
2118
|
+
this.div.style.left = pos.x + 'px';
|
2119
|
+
};
|
2120
|
+
this.picker = function(color) {
|
2121
|
+
var colorTable = KE.g[arg.id].colorTable;
|
2122
|
+
var picker = new KE.colorpicker({
|
2123
|
+
colors : colorTable,
|
2124
|
+
onclick : function(color) { KE.plugin[arg.cmd].exec(arg.id, color); },
|
2125
|
+
selectedColor : color
|
2126
|
+
});
|
2127
|
+
this.append(picker.getElement());
|
2128
|
+
this.show();
|
2129
|
+
};
|
2130
|
+
};
|
2131
|
+
|
2132
|
+
KE.dialog = function(arg){
|
2133
|
+
var self = this;
|
2134
|
+
this.widthMargin = 30;
|
2135
|
+
this.heightMargin = 100;
|
2136
|
+
this.zIndex = 19811214;
|
2137
|
+
this.width = arg.width;
|
2138
|
+
this.height = arg.height;
|
2139
|
+
var minTop, minLeft;
|
2140
|
+
function setLimitNumber() {
|
2141
|
+
var docEl = KE.util.getDocumentElement();
|
2142
|
+
var pos = KE.util.getScrollPos();
|
2143
|
+
minTop = pos.y;
|
2144
|
+
minLeft = pos.x;
|
2145
|
+
}
|
2146
|
+
function init() {
|
2147
|
+
this.beforeHide = arg.beforeHide;
|
2148
|
+
this.afterHide = arg.afterHide;
|
2149
|
+
this.beforeShow = arg.beforeShow;
|
2150
|
+
this.afterShow = arg.afterShow;
|
2151
|
+
this.ondrag = arg.ondrag;
|
2152
|
+
}
|
2153
|
+
init.call(this);
|
2154
|
+
function getPos() {
|
2155
|
+
var width = this.width + this.widthMargin;
|
2156
|
+
var height = this.height + this.heightMargin;
|
2157
|
+
var id = arg.id;
|
2158
|
+
var g = KE.g[id];
|
2159
|
+
var x = 0, y = 0;
|
2160
|
+
if (g.dialogAlignType == 'page') {
|
2161
|
+
var el = KE.util.getDocumentElement();
|
2162
|
+
var scrollPos = KE.util.getScrollPos();
|
2163
|
+
x = Math.round(scrollPos.x + (el.clientWidth - width) / 2);
|
2164
|
+
y = Math.round(scrollPos.y + (el.clientHeight - height) / 2);
|
2165
|
+
} else {
|
2166
|
+
var pos = KE.util.getElementPos(KE.g[id].container);
|
2167
|
+
var el = g.container;
|
2168
|
+
var xDiff = Math.round(el.clientWidth / 2) - Math.round(width / 2);
|
2169
|
+
var yDiff = Math.round(el.clientHeight / 2) - Math.round(height / 2);
|
2170
|
+
x = xDiff < 0 ? pos.x : pos.x + xDiff;
|
2171
|
+
y = yDiff < 0 ? pos.y : pos.y + yDiff;
|
2172
|
+
}
|
2173
|
+
x = x < 0 ? 0 : x;
|
2174
|
+
y = y < 0 ? 0 : y;
|
2175
|
+
return {x : x, y : y};
|
2176
|
+
};
|
2177
|
+
this.resize = function(width, height) {
|
2178
|
+
if (width) this.width = width;
|
2179
|
+
if (height) this.height = height;
|
2180
|
+
this.hide();
|
2181
|
+
this.show();
|
2182
|
+
};
|
2183
|
+
this.hide = function() {
|
2184
|
+
if (this.beforeHide) this.beforeHide(id);
|
2185
|
+
var id = arg.id;
|
2186
|
+
var stack = KE.g[id].dialogStack;
|
2187
|
+
if (stack[stack.length - 1] != this) return;
|
2188
|
+
var dialog = stack.pop();
|
2189
|
+
var iframe = dialog.iframe;
|
2190
|
+
iframe.src = 'javascript:false';
|
2191
|
+
iframe.parentNode.removeChild(iframe);
|
2192
|
+
document.body.removeChild(this.div);
|
2193
|
+
if (stack.length < 1) {
|
2194
|
+
KE.g[id].maskDiv.style.display = 'none';
|
2195
|
+
}
|
2196
|
+
KE.event.remove(window, 'resize', setLimitNumber);
|
2197
|
+
KE.event.remove(window, 'scroll', setLimitNumber);
|
2198
|
+
if (this.afterHide) this.afterHide(id);
|
2199
|
+
KE.util.focus(id);
|
2200
|
+
};
|
2201
|
+
this.show = function() {
|
2202
|
+
if (this.beforeShow) this.beforeShow(id);
|
2203
|
+
var self = this;
|
2204
|
+
var id = arg.id;
|
2205
|
+
var div = KE.$$('div');
|
2206
|
+
div.className = 'ke-dialog';
|
2207
|
+
KE.event.bind(div, 'click', function(e){}, id);
|
2208
|
+
KE.event.bind(div, 'mousedown', function(e){}, id);
|
2209
|
+
var stack = KE.g[id].dialogStack;
|
2210
|
+
if (stack.length > 0) {
|
2211
|
+
this.zIndex = stack[stack.length - 1].zIndex + 1;
|
2212
|
+
}
|
2213
|
+
div.style.zIndex = this.zIndex;
|
2214
|
+
var pos = getPos.call(this);
|
2215
|
+
div.style.top = pos.y + 'px';
|
2216
|
+
div.style.left = pos.x + 'px';
|
2217
|
+
var contentCell;
|
2218
|
+
if (KE.g[id].shadowMode) {
|
2219
|
+
var table = KE.$$('table');
|
2220
|
+
table.className = 'ke-dialog-table';
|
2221
|
+
table.cellPadding = 0;
|
2222
|
+
table.cellSpacing = 0;
|
2223
|
+
table.border = 0;
|
2224
|
+
var rowNames = ['t', 'm', 'b'];
|
2225
|
+
var colNames = ['l', 'c', 'r'];
|
2226
|
+
for (var i = 0, len = 3; i < len; i++) {
|
2227
|
+
var row = table.insertRow(i);
|
2228
|
+
for (var j = 0, l = 3; j < l; j++) {
|
2229
|
+
var cell = row.insertCell(j);
|
2230
|
+
cell.className = 'ke-' + rowNames[i] + colNames[j];
|
2231
|
+
if (i == 1 && j == 1) contentCell = cell;
|
2232
|
+
else cell.innerHTML = '<span class="ke-dialog-empty"></span>';
|
2233
|
+
}
|
2234
|
+
}
|
2235
|
+
div.appendChild(table);
|
2236
|
+
} else {
|
2237
|
+
KE.addClass(div, 'ke-dialog-no-shadow');
|
2238
|
+
contentCell = div;
|
2239
|
+
}
|
2240
|
+
var titleDiv = KE.$$('div');
|
2241
|
+
titleDiv.className = 'ke-dialog-title';
|
2242
|
+
titleDiv.innerHTML = arg.title;
|
2243
|
+
var span = KE.$$('span');
|
2244
|
+
span.className = 'ke-dialog-close';
|
2245
|
+
if (KE.g[id].shadowMode) KE.addClass(span, 'ke-dialog-close-shadow');
|
2246
|
+
else KE.addClass(span, 'ke-dialog-close-no-shadow');
|
2247
|
+
span.alt = KE.lang['close'];
|
2248
|
+
span.title = KE.lang['close'];
|
2249
|
+
span.onclick = function () {
|
2250
|
+
self.hide();
|
2251
|
+
KE.util.select(id);
|
2252
|
+
};
|
2253
|
+
titleDiv.appendChild(span);
|
2254
|
+
setLimitNumber();
|
2255
|
+
KE.event.add(window, 'resize', setLimitNumber);
|
2256
|
+
KE.event.add(window, 'scroll', setLimitNumber);
|
2257
|
+
KE.util.drag(id, titleDiv, div, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2258
|
+
if (self.ondrag) self.ondrag(id);
|
2259
|
+
setLimitNumber();
|
2260
|
+
top = objTop + top;
|
2261
|
+
left = objLeft + left;
|
2262
|
+
if (top < minTop) top = minTop;
|
2263
|
+
if (left < minLeft) left = minLeft;
|
2264
|
+
div.style.top = top + 'px';
|
2265
|
+
div.style.left = left + 'px';
|
2266
|
+
});
|
2267
|
+
contentCell.appendChild(titleDiv);
|
2268
|
+
var bodyDiv = KE.$$('div');
|
2269
|
+
bodyDiv.className = 'ke-dialog-body';
|
2270
|
+
var loadingTable = KE.util.createTable();
|
2271
|
+
loadingTable.table.className = 'ke-loading-table';
|
2272
|
+
loadingTable.table.style.width = this.width + 'px';
|
2273
|
+
loadingTable.table.style.height = this.height + 'px';
|
2274
|
+
var loadingImg = KE.$$('span');
|
2275
|
+
loadingImg.className = 'ke-loading-img';
|
2276
|
+
loadingTable.cell.appendChild(loadingImg);
|
2277
|
+
var iframe = (KE.g[id].dialogStack.length == 0 && KE.g[id].dialog) ? KE.g[id].dialog : KE.$$('iframe');
|
2278
|
+
if (arg.useFrameCSS) {
|
2279
|
+
iframe.className = 'ke-dialog-iframe ke-dialog-iframe-border';
|
2280
|
+
} else {
|
2281
|
+
iframe.className = 'ke-dialog-iframe';
|
2282
|
+
}
|
2283
|
+
iframe.setAttribute("frameBorder", "0");
|
2284
|
+
iframe.style.width = this.width + 'px';
|
2285
|
+
iframe.style.height = this.height + 'px';
|
2286
|
+
iframe.style.display = 'none';
|
2287
|
+
bodyDiv.appendChild(iframe);
|
2288
|
+
bodyDiv.appendChild(loadingTable.table);
|
2289
|
+
contentCell.appendChild(bodyDiv);
|
2290
|
+
|
2291
|
+
var bottomDiv = KE.$$('div');
|
2292
|
+
bottomDiv.className = 'ke-dialog-bottom';
|
2293
|
+
var noButton = null;
|
2294
|
+
var yesButton = null;
|
2295
|
+
var previewButton = null;
|
2296
|
+
if (arg.previewButton) {
|
2297
|
+
previewButton = KE.$$('input');
|
2298
|
+
previewButton.className = 'ke-button ke-dialog-preview';
|
2299
|
+
previewButton.type = 'button';
|
2300
|
+
previewButton.name = 'previewButton';
|
2301
|
+
previewButton.value = arg.previewButton;
|
2302
|
+
previewButton.onclick = function() {
|
2303
|
+
var stack = KE.g[id].dialogStack;
|
2304
|
+
if (stack[stack.length - 1] == self) {
|
2305
|
+
KE.plugin[arg.cmd].preview(id);
|
2306
|
+
}
|
2307
|
+
};
|
2308
|
+
bottomDiv.appendChild(previewButton);
|
2309
|
+
}
|
2310
|
+
if (arg.yesButton) {
|
2311
|
+
yesButton = KE.$$('input');
|
2312
|
+
yesButton.className = 'ke-button ke-dialog-yes';
|
2313
|
+
yesButton.type = 'button';
|
2314
|
+
yesButton.name = 'yesButton';
|
2315
|
+
yesButton.value = arg.yesButton;
|
2316
|
+
yesButton.onclick = function() {
|
2317
|
+
var stack = KE.g[id].dialogStack;
|
2318
|
+
if (stack[stack.length - 1] == self) {
|
2319
|
+
KE.plugin[arg.cmd].exec(id);
|
2320
|
+
}
|
2321
|
+
};
|
2322
|
+
bottomDiv.appendChild(yesButton);
|
2323
|
+
}
|
2324
|
+
if (arg.noButton) {
|
2325
|
+
noButton = KE.$$('input');
|
2326
|
+
noButton.className = 'ke-button ke-dialog-no';
|
2327
|
+
noButton.type = 'button';
|
2328
|
+
noButton.name = 'noButton';
|
2329
|
+
noButton.value = arg.noButton;
|
2330
|
+
noButton.onclick = function () {
|
2331
|
+
self.hide();
|
2332
|
+
KE.util.select(id);
|
2333
|
+
};
|
2334
|
+
bottomDiv.appendChild(noButton);
|
2335
|
+
}
|
2336
|
+
if (arg.yesButton || arg.noButton || arg.previewButton) {
|
2337
|
+
contentCell.appendChild(bottomDiv);
|
2338
|
+
}
|
2339
|
+
document.body.appendChild(div);
|
2340
|
+
window.focus();
|
2341
|
+
if (yesButton) yesButton.focus();
|
2342
|
+
else if (noButton) noButton.focus();
|
2343
|
+
if (arg.html !== undefined) {
|
2344
|
+
var dialogDoc = KE.util.getIframeDoc(iframe);
|
2345
|
+
var html = KE.util.getFullHtml(id);
|
2346
|
+
dialogDoc.open();
|
2347
|
+
dialogDoc.write(html);
|
2348
|
+
dialogDoc.close();
|
2349
|
+
KE.util.innerHtml(dialogDoc.body, arg.html);
|
2350
|
+
} else if (arg.url !== undefined) {
|
2351
|
+
iframe.src = arg.url;
|
2352
|
+
} else {
|
2353
|
+
var param = 'id=' + escape(id) + '&ver=' + escape(KE.version);
|
2354
|
+
if (arg.file === undefined) {
|
2355
|
+
iframe.src = KE.g[id].pluginsPath + arg.cmd + '.html?' + param;
|
2356
|
+
} else {
|
2357
|
+
param = (/\?/.test(arg.file) ? '&' : '?') + param;
|
2358
|
+
iframe.src = KE.g[id].pluginsPath + arg.file + param;
|
2359
|
+
}
|
2360
|
+
}
|
2361
|
+
KE.g[id].maskDiv.style.width = KE.util.getDocumentWidth() + 'px';
|
2362
|
+
KE.g[id].maskDiv.style.height = KE.util.getDocumentHeight() + 'px';
|
2363
|
+
KE.g[id].maskDiv.style.display = 'block';
|
2364
|
+
this.iframe = iframe;
|
2365
|
+
this.loading = loadingTable.table;
|
2366
|
+
this.noButton = noButton;
|
2367
|
+
this.yesButton = yesButton;
|
2368
|
+
this.previewButton = previewButton;
|
2369
|
+
this.div = div;
|
2370
|
+
KE.g[id].dialogStack.push(this);
|
2371
|
+
KE.g[id].dialog = iframe;
|
2372
|
+
KE.g[id].yesButton = yesButton;
|
2373
|
+
KE.g[id].noButton = noButton;
|
2374
|
+
KE.g[id].previewButton = previewButton;
|
2375
|
+
if (!arg.loadingMode) KE.util.hideLoadingPage(id);
|
2376
|
+
if (this.afterShow) this.afterShow(id);
|
2377
|
+
if (KE.g[id].afterDialogCreate) KE.g[id].afterDialogCreate(id);
|
2378
|
+
};
|
2379
|
+
};
|
2380
|
+
|
2381
|
+
KE.toolbar = {
|
2382
|
+
updateState : function(id) {
|
2383
|
+
var cmdList = [
|
2384
|
+
'justifyleft', 'justifycenter', 'justifyright',
|
2385
|
+
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript',
|
2386
|
+
'bold', 'italic', 'underline', 'strikethrough'
|
2387
|
+
];
|
2388
|
+
for (var i = 0; i < cmdList.length; i++) {
|
2389
|
+
var cmd = cmdList[i];
|
2390
|
+
var state = false;
|
2391
|
+
try {
|
2392
|
+
state = KE.g[id].iframeDoc.queryCommandState(cmd);
|
2393
|
+
} catch(e) {}
|
2394
|
+
if (state) {
|
2395
|
+
KE.toolbar.select(id, cmd);
|
2396
|
+
} else {
|
2397
|
+
KE.toolbar.unselect(id, cmd);
|
2398
|
+
}
|
2399
|
+
}
|
2400
|
+
},
|
2401
|
+
isSelected : function(id, cmd) {
|
2402
|
+
if (KE.plugin[cmd] && KE.plugin[cmd].isSelected) return true;
|
2403
|
+
else return false;
|
2404
|
+
},
|
2405
|
+
select : function(id, cmd) {
|
2406
|
+
if (KE.g[id].toolbarIcon[cmd]) {
|
2407
|
+
var a = KE.g[id].toolbarIcon[cmd][0];
|
2408
|
+
a.className = 'ke-icon ke-icon-selected';
|
2409
|
+
a.onmouseover = null;
|
2410
|
+
a.onmouseout = null;
|
2411
|
+
}
|
2412
|
+
},
|
2413
|
+
unselect : function(id, cmd) {
|
2414
|
+
if (KE.g[id].toolbarIcon[cmd]) {
|
2415
|
+
var a = KE.g[id].toolbarIcon[cmd][0];
|
2416
|
+
a.className = 'ke-icon';
|
2417
|
+
a.onmouseover = function(){ this.className = 'ke-icon ke-icon-on'; };
|
2418
|
+
a.onmouseout = function(){ this.className = 'ke-icon'; };
|
2419
|
+
}
|
2420
|
+
},
|
2421
|
+
_setAttr : function(id, a, cmd) {
|
2422
|
+
a.className = 'ke-icon';
|
2423
|
+
a.href = 'javascript:;';
|
2424
|
+
a.onclick = function(e) {
|
2425
|
+
e = e || window.event;
|
2426
|
+
var div = KE.g[id].hideDiv.firstChild;
|
2427
|
+
if (div && div.getAttribute('name') == cmd) {
|
2428
|
+
KE.hideMenu(id);
|
2429
|
+
} else {
|
2430
|
+
KE.util.click(id, cmd);
|
2431
|
+
}
|
2432
|
+
if (e.preventDefault) e.preventDefault();
|
2433
|
+
if (e.stopPropagation) e.stopPropagation();
|
2434
|
+
if (e.cancelBubble !== undefined) e.cancelBubble = true;
|
2435
|
+
return false;
|
2436
|
+
};
|
2437
|
+
a.onmouseover = function(){ this.className = 'ke-icon ke-icon-on'; };
|
2438
|
+
a.onmouseout = function(){ this.className = 'ke-icon'; };
|
2439
|
+
a.hidefocus = true;
|
2440
|
+
a.title = KE.lang[cmd];
|
2441
|
+
},
|
2442
|
+
able : function(id, arr) {
|
2443
|
+
var self = this;
|
2444
|
+
KE.each(KE.g[id].toolbarIcon, function(cmd, obj) {
|
2445
|
+
if (!KE.util.inArray(cmd, arr)) {
|
2446
|
+
var a = obj[0];
|
2447
|
+
var span = obj[1];
|
2448
|
+
self._setAttr(id, a, cmd);
|
2449
|
+
KE.util.setOpacity(span, 100);
|
2450
|
+
}
|
2451
|
+
});
|
2452
|
+
},
|
2453
|
+
disable : function(id, arr) {
|
2454
|
+
KE.each(KE.g[id].toolbarIcon, function(cmd, obj) {
|
2455
|
+
if (!KE.util.inArray(cmd, arr)) {
|
2456
|
+
var a = obj[0];
|
2457
|
+
var span = obj[1];
|
2458
|
+
a.className = 'ke-icon ke-icon-disabled';
|
2459
|
+
KE.util.setOpacity(span, 50);
|
2460
|
+
a.onclick = null;
|
2461
|
+
a.onmouseover = null;
|
2462
|
+
a.onmouseout = null;
|
2463
|
+
}
|
2464
|
+
});
|
2465
|
+
},
|
2466
|
+
create : function(id) {
|
2467
|
+
var self = this;
|
2468
|
+
var defaultItemHash = KE.util.arrayToHash(KE.setting.items);
|
2469
|
+
KE.g[id].toolbarIcon = [];
|
2470
|
+
var tableObj = KE.util.createTable();
|
2471
|
+
var toolbar = tableObj.table;
|
2472
|
+
toolbar.className = 'ke-toolbar';
|
2473
|
+
toolbar.oncontextmenu = function() { return false; };
|
2474
|
+
toolbar.onmousedown = function() { return false; };
|
2475
|
+
toolbar.onmousemove = function() { return false; };
|
2476
|
+
var toolbarCell = tableObj.cell;
|
2477
|
+
var length = KE.g[id].items.length;
|
2478
|
+
var cellNum = 0;
|
2479
|
+
var row;
|
2480
|
+
KE.g[id].toolbarHeight = KE.g[id].toolbarLineHeight;
|
2481
|
+
for (var i = 0; i < length; i++) {
|
2482
|
+
var cmd = KE.g[id].items[i];
|
2483
|
+
if (i == 0 || cmd == '-') {
|
2484
|
+
var table = KE.util.createTable().table;
|
2485
|
+
table.className = 'ke-toolbar-table';
|
2486
|
+
row = table.insertRow(0);
|
2487
|
+
cellNum = 0;
|
2488
|
+
toolbarCell.appendChild(table);
|
2489
|
+
if (cmd == '-') {
|
2490
|
+
KE.g[id].toolbarHeight += KE.g[id].toolbarLineHeight;
|
2491
|
+
continue;
|
2492
|
+
}
|
2493
|
+
}
|
2494
|
+
var cell = row.insertCell(cellNum);
|
2495
|
+
cell.hideforcus = true;
|
2496
|
+
cellNum++;
|
2497
|
+
if (cmd == '|') {
|
2498
|
+
var div = KE.$$('div');
|
2499
|
+
div.className = 'ke-toolbar-separator';
|
2500
|
+
cell.appendChild(div);
|
2501
|
+
continue;
|
2502
|
+
}
|
2503
|
+
var a = KE.$$('a');
|
2504
|
+
self._setAttr(id, a, cmd);
|
2505
|
+
var span = KE.$$('span');
|
2506
|
+
if (typeof defaultItemHash[cmd] == 'undefined') {
|
2507
|
+
span.className = 'ke-common-icon ke-icon-' + cmd;
|
2508
|
+
} else {
|
2509
|
+
span.className = 'ke-common-icon ke-common-icon-url ke-icon-' + cmd;
|
2510
|
+
}
|
2511
|
+
a.appendChild(span);
|
2512
|
+
cell.appendChild(a);
|
2513
|
+
KE.g[id].toolbarIcon[cmd] = [a, span];
|
2514
|
+
if (KE.toolbar.isSelected(id, cmd)) KE.toolbar.select(id, cmd);
|
2515
|
+
}
|
2516
|
+
return toolbar;
|
2517
|
+
}
|
2518
|
+
};
|
2519
|
+
|
2520
|
+
KE.history = {
|
2521
|
+
addStackData : function(stack, data) {
|
2522
|
+
var prev = '';
|
2523
|
+
if (stack.length > 0) {
|
2524
|
+
prev = stack[stack.length - 1];
|
2525
|
+
}
|
2526
|
+
if (stack.length == 0 || data !== prev) stack.push(data);
|
2527
|
+
},
|
2528
|
+
add : function(id, minChangeSize) {
|
2529
|
+
var g = KE.g[id];
|
2530
|
+
var html = KE.util.getSrcData(id);
|
2531
|
+
if (g.undoStack.length > 0) {
|
2532
|
+
var prevHtml = g.undoStack[g.undoStack.length - 1];
|
2533
|
+
if (Math.abs(html.length - prevHtml.length) < minChangeSize) return;
|
2534
|
+
}
|
2535
|
+
this.addStackData(g.undoStack, html);
|
2536
|
+
},
|
2537
|
+
undo : function(id) {
|
2538
|
+
var g = KE.g[id];
|
2539
|
+
if (g.undoStack.length == 0) return;
|
2540
|
+
var html = KE.util.getSrcData(id);
|
2541
|
+
this.addStackData(g.redoStack, html);
|
2542
|
+
var prevHtml = g.undoStack.pop();
|
2543
|
+
if (html === prevHtml && g.undoStack.length > 0) {
|
2544
|
+
prevHtml = g.undoStack.pop();
|
2545
|
+
}
|
2546
|
+
prevHtml = KE.util.toData(id, prevHtml);
|
2547
|
+
if (g.wyswygMode) {
|
2548
|
+
KE.util.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, prevHtml));
|
2549
|
+
} else {
|
2550
|
+
g.newTextarea.value = prevHtml;
|
2551
|
+
}
|
2552
|
+
},
|
2553
|
+
redo : function(id) {
|
2554
|
+
var g = KE.g[id];
|
2555
|
+
if (g.redoStack.length == 0) return;
|
2556
|
+
var html = KE.util.getSrcData(id);
|
2557
|
+
this.addStackData(g.undoStack, html);
|
2558
|
+
var nextHtml = g.redoStack.pop();
|
2559
|
+
nextHtml = KE.util.toData(id, nextHtml);
|
2560
|
+
if (g.wyswygMode) {
|
2561
|
+
KE.util.innerHtml(g.iframeDoc.body, KE.util.execSetHtmlHooks(id, nextHtml));
|
2562
|
+
} else {
|
2563
|
+
g.newTextarea.value = nextHtml;
|
2564
|
+
}
|
2565
|
+
}
|
2566
|
+
};
|
2567
|
+
|
2568
|
+
KE.readonly = function(id, isReadonly) {
|
2569
|
+
isReadonly = isReadonly == undefined ? true : isReadonly;
|
2570
|
+
var g = KE.g[id];
|
2571
|
+
if (KE.browser.IE) g.iframeDoc.body.contentEditable = isReadonly ? 'false' : 'true';
|
2572
|
+
else g.iframeDoc.designMode = isReadonly ? 'off' : 'on';
|
2573
|
+
};
|
2574
|
+
|
2575
|
+
KE.focus = function(id, position) {
|
2576
|
+
position = (position || '').toLowerCase();
|
2577
|
+
if (!KE.g[id].container) return;
|
2578
|
+
KE.util.focus(id);
|
2579
|
+
if (position === 'end') {
|
2580
|
+
KE.util.setSelection(id);
|
2581
|
+
if (!KE.g[id].sel) return; //issue #120: Sometimes Firefox does not get selection
|
2582
|
+
var sel = KE.g[id].keSel,
|
2583
|
+
range = KE.g[id].keRange,
|
2584
|
+
doc = KE.g[id].iframeDoc;
|
2585
|
+
range.selectTextNode(doc.body);
|
2586
|
+
range.collapse(false);
|
2587
|
+
sel.addRange(range);
|
2588
|
+
}
|
2589
|
+
};
|
2590
|
+
|
2591
|
+
KE.html = function(id, val) {
|
2592
|
+
if (val === undefined) {
|
2593
|
+
return KE.util.getData(id);
|
2594
|
+
} else {
|
2595
|
+
if (!KE.g[id].container) return;
|
2596
|
+
KE.util.setFullHtml(id, val);
|
2597
|
+
KE.focus(id, 'end');
|
2598
|
+
}
|
2599
|
+
};
|
2600
|
+
|
2601
|
+
KE.text = function(id, val) {
|
2602
|
+
if (val === undefined) {
|
2603
|
+
val = KE.html(id);
|
2604
|
+
val = val.replace(/<.*?>/ig, '');
|
2605
|
+
val = val.replace(/ /ig, ' ');
|
2606
|
+
val = KE.util.trim(val);
|
2607
|
+
return val;
|
2608
|
+
} else {
|
2609
|
+
KE.html(id, KE.util.escape(val));
|
2610
|
+
}
|
2611
|
+
};
|
2612
|
+
|
2613
|
+
KE.insertHtml = function(id, val) {
|
2614
|
+
if (!KE.g[id].container) return;
|
2615
|
+
var range = KE.g[id].range;
|
2616
|
+
if (!range) {
|
2617
|
+
KE.appendHtml(id, val);
|
2618
|
+
} else {
|
2619
|
+
KE.focus(id);
|
2620
|
+
KE.util.selection(id);
|
2621
|
+
KE.util.insertHtml(id, val);
|
2622
|
+
}
|
2623
|
+
};
|
2624
|
+
|
2625
|
+
KE.appendHtml = function(id, val) {
|
2626
|
+
KE.html(id, KE.html(id) + val);
|
2627
|
+
KE.focus(id, 'end');
|
2628
|
+
};
|
2629
|
+
|
2630
|
+
KE.isEmpty = function(id) {
|
2631
|
+
return KE.util.isEmpty(id);
|
2632
|
+
};
|
2633
|
+
|
2634
|
+
KE.selectedHtml = function(id) {
|
2635
|
+
var range = KE.g[id].range;
|
2636
|
+
if (!range) return '';
|
2637
|
+
var html = '';
|
2638
|
+
if (KE.browser.IE) {
|
2639
|
+
if (range.item) {
|
2640
|
+
html = range.item(0).outerHTML;
|
2641
|
+
} else {
|
2642
|
+
html = range.htmlText;
|
2643
|
+
}
|
2644
|
+
} else {
|
2645
|
+
var temp = KE.$$('div', KE.g[id].iframeDoc);
|
2646
|
+
temp.appendChild(range.cloneContents());
|
2647
|
+
html = temp.innerHTML;
|
2648
|
+
}
|
2649
|
+
return KE.util.toData(id, html);
|
2650
|
+
};
|
2651
|
+
|
2652
|
+
KE.count = function(id, mode) {
|
2653
|
+
mode = (mode || 'html').toLowerCase();
|
2654
|
+
if (mode === 'html') {
|
2655
|
+
return KE.html(id).length;
|
2656
|
+
} else if (mode === 'text') {
|
2657
|
+
var data = KE.util.getPureData(id);
|
2658
|
+
data = data.replace(/<(?:img|embed).*?>/ig, 'K');
|
2659
|
+
data = data.replace(/\r\n|\n|\r/g, '');
|
2660
|
+
data = KE.util.trim(data);
|
2661
|
+
return data.length;
|
2662
|
+
}
|
2663
|
+
return 0;
|
2664
|
+
};
|
2665
|
+
|
2666
|
+
KE.remove = function(id, mode) {
|
2667
|
+
var g = KE.g[id];
|
2668
|
+
if (!g.container) return false;
|
2669
|
+
mode = (typeof mode == "undefined") ? 0 : mode;
|
2670
|
+
KE.util.setData(id);
|
2671
|
+
var container = g.container;
|
2672
|
+
var eventStack = g.eventStack;
|
2673
|
+
for (var i = 0, len = eventStack.length; i < len; i++) {
|
2674
|
+
var item = eventStack[i];
|
2675
|
+
if (item) KE.event.remove(item.el, item.type, item.fn, id);
|
2676
|
+
}
|
2677
|
+
g.iframeDoc.src = 'javascript:false';
|
2678
|
+
g.iframe.parentNode.removeChild(g.iframe);
|
2679
|
+
if (mode == 1) {
|
2680
|
+
document.body.removeChild(container);
|
2681
|
+
} else {
|
2682
|
+
var srcTextarea = g.srcTextarea;
|
2683
|
+
srcTextarea.parentNode.removeChild(container);
|
2684
|
+
if (mode == 0) srcTextarea.style.display = '';
|
2685
|
+
}
|
2686
|
+
document.body.removeChild(g.hideDiv);
|
2687
|
+
document.body.removeChild(g.maskDiv);
|
2688
|
+
g.container = null;
|
2689
|
+
g.dialogStack = [];
|
2690
|
+
g.contextmenuItems = [];
|
2691
|
+
g.getHtmlHooks = [];
|
2692
|
+
g.setHtmlHooks = [];
|
2693
|
+
g.onchangeHandlerStack = [];
|
2694
|
+
g.eventStack = [];
|
2695
|
+
};
|
2696
|
+
|
2697
|
+
KE.create = function(id, mode) {
|
2698
|
+
if (KE.g[id].beforeCreate) KE.g[id].beforeCreate(id);
|
2699
|
+
if (KE.browser.IE && KE.browser.VERSION < 7) try { document.execCommand('BackgroundImageCache', false, true); }catch(e){}
|
2700
|
+
var srcTextarea = KE.$(id) || document.getElementsByName(id)[0];
|
2701
|
+
mode = (typeof mode == "undefined") ? 0 : mode;
|
2702
|
+
if (mode == 0 && KE.g[id].container) return;
|
2703
|
+
var width = KE.g[id].width || srcTextarea.style.width || srcTextarea.offsetWidth + 'px';
|
2704
|
+
var height = KE.g[id].height || srcTextarea.style.height || srcTextarea.offsetHeight + 'px';
|
2705
|
+
var tableObj = KE.util.createTable();
|
2706
|
+
var container = tableObj.table;
|
2707
|
+
container.className = 'ke-container';
|
2708
|
+
container.style.width = width;
|
2709
|
+
container.style.height = height;
|
2710
|
+
var toolbarOuter = tableObj.cell;
|
2711
|
+
toolbarOuter.className = 'ke-toolbar-outer';
|
2712
|
+
var textareaOuter = container.insertRow(1).insertCell(0);
|
2713
|
+
textareaOuter.className = 'ke-textarea-outer';
|
2714
|
+
tableObj = KE.util.createTable();
|
2715
|
+
var textareaTable = tableObj.table;
|
2716
|
+
textareaTable.className = 'ke-textarea-table';
|
2717
|
+
var textareaCell = tableObj.cell;
|
2718
|
+
textareaOuter.appendChild(textareaTable);
|
2719
|
+
var bottomOuter = container.insertRow(2).insertCell(0);
|
2720
|
+
bottomOuter.className = 'ke-bottom-outer';
|
2721
|
+
srcTextarea.style.display = 'none';
|
2722
|
+
if (mode == 1) document.body.appendChild(container);
|
2723
|
+
else srcTextarea.parentNode.insertBefore(container, srcTextarea);
|
2724
|
+
var toolbarTable = KE.toolbar.create(id);
|
2725
|
+
toolbarTable.style.height = KE.g[id].toolbarHeight + 'px';
|
2726
|
+
toolbarOuter.appendChild(toolbarTable);
|
2727
|
+
var iframe = KE.g[id].iframe || KE.$$('iframe');
|
2728
|
+
iframe.className = 'ke-iframe';
|
2729
|
+
iframe.setAttribute("frameBorder", "0");
|
2730
|
+
var newTextarea = KE.$$('textarea');
|
2731
|
+
newTextarea.className = 'ke-textarea';
|
2732
|
+
newTextarea.style.display = 'none';
|
2733
|
+
KE.g[id].container = container;
|
2734
|
+
KE.g[id].iframe = iframe;
|
2735
|
+
KE.g[id].newTextarea = newTextarea;
|
2736
|
+
KE.util.resize(id, width, height);
|
2737
|
+
textareaCell.appendChild(iframe);
|
2738
|
+
textareaCell.appendChild(newTextarea);
|
2739
|
+
var bottom = KE.$$('table');
|
2740
|
+
bottom.className = 'ke-bottom';
|
2741
|
+
bottom.cellPadding = 0;
|
2742
|
+
bottom.cellSpacing = 0;
|
2743
|
+
bottom.border = 0;
|
2744
|
+
bottom.style.height = KE.g[id].statusbarHeight + 'px';
|
2745
|
+
var row = bottom.insertRow(0);
|
2746
|
+
var bottomLeft = row.insertCell(0);
|
2747
|
+
bottomLeft.className = 'ke-bottom-left';
|
2748
|
+
var leftImg = KE.$$('span');
|
2749
|
+
leftImg.className = 'ke-bottom-left-img';
|
2750
|
+
if (KE.g[id].config.resizeMode == 0 || mode == 1) {
|
2751
|
+
bottomLeft.style.cursor = 'default';
|
2752
|
+
leftImg.style.visibility = 'hidden';
|
2753
|
+
}
|
2754
|
+
bottomLeft.appendChild(leftImg);
|
2755
|
+
var bottomRight = row.insertCell(1);
|
2756
|
+
bottomRight.className = 'ke-bottom-right';
|
2757
|
+
var rightImg = KE.$$('span');
|
2758
|
+
rightImg.className = 'ke-bottom-right-img';
|
2759
|
+
if (KE.g[id].config.resizeMode == 0 || mode == 1) {
|
2760
|
+
bottomRight.style.cursor = 'default';
|
2761
|
+
rightImg.style.visibility = 'hidden';
|
2762
|
+
} else if (KE.g[id].config.resizeMode == 1) {
|
2763
|
+
bottomRight.style.cursor = 's-resize';
|
2764
|
+
rightImg.style.visibility = 'hidden';
|
2765
|
+
}
|
2766
|
+
bottomRight.appendChild(rightImg);
|
2767
|
+
bottomOuter.appendChild(bottom);
|
2768
|
+
var hideDiv = KE.$$('div');
|
2769
|
+
hideDiv.className = 'ke-reset';
|
2770
|
+
hideDiv.style.display = 'none';
|
2771
|
+
var maskDiv = KE.$$('div');
|
2772
|
+
maskDiv.className = 'ke-mask';
|
2773
|
+
KE.util.setOpacity(maskDiv, 50);
|
2774
|
+
KE.event.bind(maskDiv, 'click', function(e){}, id);
|
2775
|
+
KE.event.bind(maskDiv, 'mousedown', function(e){}, id);
|
2776
|
+
document.body.appendChild(hideDiv);
|
2777
|
+
document.body.appendChild(maskDiv);
|
2778
|
+
KE.util.setDefaultPlugin(id);
|
2779
|
+
var iframeWin = iframe.contentWindow;
|
2780
|
+
var iframeDoc = KE.util.getIframeDoc(iframe);
|
2781
|
+
if (!KE.browser.IE || KE.browser.VERSION < 8) iframeDoc.designMode = 'on';
|
2782
|
+
var html = KE.util.getFullHtml(id);
|
2783
|
+
iframeDoc.open();
|
2784
|
+
iframeDoc.write(html);
|
2785
|
+
iframeDoc.close();
|
2786
|
+
if (!KE.g[id].wyswygMode) {
|
2787
|
+
newTextarea.value = KE.util.execSetHtmlHooks(id, srcTextarea.value);
|
2788
|
+
newTextarea.style.display = 'block';
|
2789
|
+
iframe.style.display = 'none';
|
2790
|
+
KE.toolbar.disable(id, ['source', 'fullscreen']);
|
2791
|
+
KE.toolbar.select(id, 'source');
|
2792
|
+
}
|
2793
|
+
function hideMenu() {
|
2794
|
+
KE.hideMenu(id);
|
2795
|
+
}
|
2796
|
+
function updateToolbar() {
|
2797
|
+
KE.toolbar.updateState(id);
|
2798
|
+
}
|
2799
|
+
if (KE.browser.WEBKIT) {
|
2800
|
+
KE.event.add(iframeDoc, 'click', function(e) {
|
2801
|
+
KE.util.selectImageWebkit(id, e, true);
|
2802
|
+
}, id);
|
2803
|
+
}
|
2804
|
+
if (KE.browser.IE) {
|
2805
|
+
KE.event.add(iframeDoc, 'keydown', function(e) {
|
2806
|
+
if (e.keyCode == 8) {
|
2807
|
+
var range = KE.g[id].range;
|
2808
|
+
if (range.item) {
|
2809
|
+
var item = range.item(0);
|
2810
|
+
item.parentNode.removeChild(item);
|
2811
|
+
KE.util.execOnchangeHandler(id);
|
2812
|
+
KE.event.stop(id);
|
2813
|
+
return false;
|
2814
|
+
}
|
2815
|
+
}
|
2816
|
+
}, id);
|
2817
|
+
}
|
2818
|
+
KE.event.add(iframeDoc, 'click', hideMenu, id);
|
2819
|
+
KE.event.add(iframeDoc, 'click', updateToolbar, id);
|
2820
|
+
KE.event.input(iframeDoc, updateToolbar, id);
|
2821
|
+
KE.event.bind(newTextarea, 'click', hideMenu, id);
|
2822
|
+
KE.event.add(document, 'click', hideMenu, id);
|
2823
|
+
KE.g[id].toolbarTable = toolbarTable;
|
2824
|
+
KE.g[id].textareaTable = textareaTable;
|
2825
|
+
KE.g[id].srcTextarea = srcTextarea;
|
2826
|
+
KE.g[id].bottom = bottom;
|
2827
|
+
KE.g[id].hideDiv = hideDiv;
|
2828
|
+
KE.g[id].maskDiv = maskDiv;
|
2829
|
+
KE.g[id].iframeWin = iframeWin;
|
2830
|
+
KE.g[id].iframeDoc = iframeDoc;
|
2831
|
+
KE.g[id].width = width;
|
2832
|
+
KE.g[id].height = height;
|
2833
|
+
KE.util.drag(id, bottomRight, container, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2834
|
+
if (KE.g[id].resizeMode == 2) KE.util.resize(id, (objWidth + left) + 'px', (objHeight + top) + 'px', true);
|
2835
|
+
else if (KE.g[id].resizeMode == 1) KE.util.resize(id, objWidth + 'px', (objHeight + top) + 'px', true, false);
|
2836
|
+
});
|
2837
|
+
KE.util.drag(id, bottomLeft, container, function(objTop, objLeft, objWidth, objHeight, top, left) {
|
2838
|
+
if (KE.g[id].resizeMode > 0) KE.util.resize(id, objWidth + 'px', (objHeight + top) + 'px', true, false);
|
2839
|
+
});
|
2840
|
+
KE.each(KE.plugin, function(cmd, plugin) {
|
2841
|
+
if (plugin.init) plugin.init(id);
|
2842
|
+
});
|
2843
|
+
KE.g[id].getHtmlHooks.push(function(html) {
|
2844
|
+
return html.replace(/(<[^>]*)kesrc="([^"]+)"([^>]*>)/ig, function(full, start, src, end) {
|
2845
|
+
full = full.replace(/(\s+(?:href|src)=")[^"]+(")/i, '$1' + src + '$2');
|
2846
|
+
full = full.replace(/\s+kesrc="[^"]+"/i, '');
|
2847
|
+
return full;
|
2848
|
+
});
|
2849
|
+
});
|
2850
|
+
KE.g[id].setHtmlHooks.push(function(html) {
|
2851
|
+
return html.replace(/(<[^>]*)(href|src)="([^"]+)"([^>]*>)/ig, function(full, start, key, src, end) {
|
2852
|
+
if (full.match(/\skesrc="[^"]+"/i)) return full;
|
2853
|
+
full = start + key + '="' + src + '"' + ' kesrc="' + src + '"' + end;
|
2854
|
+
return full;
|
2855
|
+
});
|
2856
|
+
});
|
2857
|
+
KE.util.addContextmenuEvent(id);
|
2858
|
+
KE.util.addNewlineEvent(id);
|
2859
|
+
KE.util.addTabEvent(id);
|
2860
|
+
function setSelectionHandler() {
|
2861
|
+
KE.util.setSelection(id);
|
2862
|
+
}
|
2863
|
+
KE.event.input(iframeDoc, setSelectionHandler, id);
|
2864
|
+
KE.event.add(iframeDoc, 'mouseup', setSelectionHandler, id);
|
2865
|
+
KE.event.add(document, 'mousedown', setSelectionHandler, id);
|
2866
|
+
KE.onchange(id, function(id) {
|
2867
|
+
if (KE.g[id].autoSetDataMode) {
|
2868
|
+
KE.util.setData(id);
|
2869
|
+
if (KE.g[id].afterSetData) KE.g[id].afterSetData(id);
|
2870
|
+
}
|
2871
|
+
KE.history.add(id, KE.g[id].minChangeSize);
|
2872
|
+
});
|
2873
|
+
if (KE.browser.IE && KE.browser.VERSION > 7) KE.readonly(id, false);
|
2874
|
+
KE.util.setFullHtml(id, srcTextarea.value);
|
2875
|
+
KE.history.add(id, 0);
|
2876
|
+
if (mode > 0) KE.util.focus(id);
|
2877
|
+
if (KE.g[id].afterCreate) KE.g[id].afterCreate(id);
|
2878
|
+
};
|
2879
|
+
|
2880
|
+
KE.onchange = function(id, func) {
|
2881
|
+
var g = KE.g[id];
|
2882
|
+
function handler() {
|
2883
|
+
func(id);
|
2884
|
+
};
|
2885
|
+
g.onchangeHandlerStack.push(handler);
|
2886
|
+
KE.event.input(g.iframeDoc, handler, id);
|
2887
|
+
KE.event.input(g.newTextarea, handler, id);
|
2888
|
+
KE.event.add(g.iframeDoc, 'mouseup', function(e) {
|
2889
|
+
window.setTimeout(function() {
|
2890
|
+
func(id);
|
2891
|
+
}, 0);
|
2892
|
+
}, id);
|
2893
|
+
};
|
2894
|
+
|
2895
|
+
KE.init = function(args) {
|
2896
|
+
var g = KE.g[args.id] = args;
|
2897
|
+
g.config = {};
|
2898
|
+
g.undoStack = [];
|
2899
|
+
g.redoStack = [];
|
2900
|
+
g.dialogStack = [];
|
2901
|
+
g.contextmenuItems = [];
|
2902
|
+
g.getHtmlHooks = [];
|
2903
|
+
g.setHtmlHooks = [];
|
2904
|
+
g.onchangeHandlerStack = [];
|
2905
|
+
g.eventStack = [];
|
2906
|
+
KE.each(KE.setting, function(key, val) {
|
2907
|
+
g[key] = (typeof args[key] == 'undefined') ? val : args[key];
|
2908
|
+
g.config[key] = g[key];
|
2909
|
+
});
|
2910
|
+
if (g.loadStyleMode) KE.util.loadStyle(g.skinsPath + g.skinType + '.css');
|
2911
|
+
}
|
2912
|
+
|
2913
|
+
KE.show = function(args) {
|
2914
|
+
KE.init(args);
|
2915
|
+
KE.event.ready(function() { KE.create(args.id); });
|
2916
|
+
};
|
2917
|
+
|
2918
|
+
if (window.KE === undefined) window.KE = KE;
|
2919
|
+
window.KindEditor = KE;
|
2920
|
+
|
2921
|
+
})();
|
2922
|
+
|
2923
|
+
(function (KE, undefined) {
|
2924
|
+
|
2925
|
+
KE.langType = 'zh_CN';
|
2926
|
+
|
2927
|
+
KE.lang = {
|
2928
|
+
source : 'HTML代码',
|
2929
|
+
undo : '后退(Ctrl+Z)',
|
2930
|
+
redo : '前进(Ctrl+Y)',
|
2931
|
+
cut : '剪切(Ctrl+X)',
|
2932
|
+
copy : '复制(Ctrl+C)',
|
2933
|
+
paste : '粘贴(Ctrl+V)',
|
2934
|
+
plainpaste : '粘贴为无格式文本',
|
2935
|
+
wordpaste : '从Word粘贴',
|
2936
|
+
selectall : '全选',
|
2937
|
+
justifyleft : '左对齐',
|
2938
|
+
justifycenter : '居中',
|
2939
|
+
justifyright : '右对齐',
|
2940
|
+
justifyfull : '两端对齐',
|
2941
|
+
insertorderedlist : '编号',
|
2942
|
+
insertunorderedlist : '项目符号',
|
2943
|
+
indent : '增加缩进',
|
2944
|
+
outdent : '减少缩进',
|
2945
|
+
subscript : '下标',
|
2946
|
+
superscript : '上标',
|
2947
|
+
title : '标题',
|
2948
|
+
fontname : '字体',
|
2949
|
+
fontsize : '文字大小',
|
2950
|
+
textcolor : '文字颜色',
|
2951
|
+
bgcolor : '文字背景',
|
2952
|
+
bold : '粗体(Ctrl+B)',
|
2953
|
+
italic : '斜体(Ctrl+I)',
|
2954
|
+
underline : '下划线(Ctrl+U)',
|
2955
|
+
strikethrough : '删除线',
|
2956
|
+
removeformat : '删除格式',
|
2957
|
+
image : '图片',
|
2958
|
+
flash : '插入Flash',
|
2959
|
+
media : '插入多媒体',
|
2960
|
+
table : '插入表格',
|
2961
|
+
hr : '插入横线',
|
2962
|
+
emoticons : '插入表情',
|
2963
|
+
link : '超级链接',
|
2964
|
+
unlink : '取消超级链接',
|
2965
|
+
fullscreen : '全屏显示',
|
2966
|
+
about : '关于',
|
2967
|
+
print : '打印',
|
2968
|
+
fileManager : '浏览服务器',
|
2969
|
+
advtable : '表格',
|
2970
|
+
yes : '确定',
|
2971
|
+
no : '取消',
|
2972
|
+
close : '关闭',
|
2973
|
+
editImage : '图片属性',
|
2974
|
+
deleteImage : '删除图片',
|
2975
|
+
editLink : '超级链接属性',
|
2976
|
+
deleteLink : '取消超级链接',
|
2977
|
+
tableprop : '表格属性',
|
2978
|
+
tableinsert : '插入表格',
|
2979
|
+
tabledelete : '删除表格',
|
2980
|
+
tablecolinsertleft : '左侧插入列',
|
2981
|
+
tablecolinsertright : '右侧插入列',
|
2982
|
+
tablerowinsertabove : '上方插入行',
|
2983
|
+
tablerowinsertbelow : '下方插入行',
|
2984
|
+
tablecoldelete : '删除列',
|
2985
|
+
tablerowdelete : '删除行',
|
2986
|
+
noColor : '无颜色',
|
2987
|
+
invalidImg : "请输入有效的URL地址。\n只允许jpg,gif,bmp,png格式。",
|
2988
|
+
invalidMedia : "请输入有效的URL地址。\n只允许swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
|
2989
|
+
invalidWidth : "宽度必须为数字。",
|
2990
|
+
invalidHeight : "高度必须为数字。",
|
2991
|
+
invalidBorder : "边框必须为数字。",
|
2992
|
+
invalidUrl : "请输入有效的URL地址。",
|
2993
|
+
invalidRows : '行数为必选项,只允许输入大于0的数字。',
|
2994
|
+
invalidCols : '列数为必选项,只允许输入大于0的数字。',
|
2995
|
+
invalidPadding : '边距必须为数字。',
|
2996
|
+
invalidSpacing : '间距必须为数字。',
|
2997
|
+
invalidBorder : '边框必须为数字。',
|
2998
|
+
pleaseInput : "请输入内容。",
|
2999
|
+
invalidJson : '服务器发生故障。',
|
3000
|
+
cutError : '您的浏览器安全设置不允许使用剪切操作,请使用快捷键(Ctrl+X)来完成。',
|
3001
|
+
copyError : '您的浏览器安全设置不允许使用复制操作,请使用快捷键(Ctrl+C)来完成。',
|
3002
|
+
pasteError : '您的浏览器安全设置不允许使用粘贴操作,请使用快捷键(Ctrl+V)来完成。'
|
3003
|
+
};
|
3004
|
+
|
3005
|
+
var plugins = KE.lang.plugins = {};
|
3006
|
+
|
3007
|
+
plugins.about = {
|
3008
|
+
version : KE.version,
|
3009
|
+
title : 'HTML可视化编辑器'
|
3010
|
+
};
|
3011
|
+
|
3012
|
+
plugins.plainpaste = {
|
3013
|
+
comment : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。'
|
3014
|
+
};
|
3015
|
+
|
3016
|
+
plugins.wordpaste = {
|
3017
|
+
comment : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。'
|
3018
|
+
};
|
3019
|
+
|
3020
|
+
plugins.link = {
|
3021
|
+
url : 'URL地址',
|
3022
|
+
linkType : '打开类型',
|
3023
|
+
newWindow : '新窗口',
|
3024
|
+
selfWindow : '当前窗口'
|
3025
|
+
};
|
3026
|
+
|
3027
|
+
plugins.flash = {
|
3028
|
+
url : 'Flash地址',
|
3029
|
+
width : '宽度',
|
3030
|
+
height : '高度'
|
3031
|
+
};
|
3032
|
+
|
3033
|
+
plugins.media = {
|
3034
|
+
url : '媒体文件地址',
|
3035
|
+
width : '宽度',
|
3036
|
+
height : '高度',
|
3037
|
+
autostart : '自动播放'
|
3038
|
+
};
|
3039
|
+
|
3040
|
+
plugins.image = {
|
3041
|
+
remoteImage : '远程图片',
|
3042
|
+
localImage : '本地上传',
|
3043
|
+
remoteUrl : '图片地址',
|
3044
|
+
localUrl : '图片地址',
|
3045
|
+
size : '图片大小',
|
3046
|
+
width : '宽',
|
3047
|
+
height : '高',
|
3048
|
+
resetSize : '重置大小',
|
3049
|
+
align : '对齐方式',
|
3050
|
+
defaultAlign : '默认方式',
|
3051
|
+
leftAlign : '左对齐',
|
3052
|
+
rightAlign : '右对齐',
|
3053
|
+
imgTitle : '图片说明',
|
3054
|
+
viewServer : '浏览...'
|
3055
|
+
};
|
3056
|
+
|
3057
|
+
plugins.file_manager = {
|
3058
|
+
emptyFolder : '空文件夹',
|
3059
|
+
moveup : '移到上一级文件夹',
|
3060
|
+
viewType : '显示方式:',
|
3061
|
+
viewImage : '缩略图',
|
3062
|
+
listImage : '详细信息',
|
3063
|
+
orderType : '排序方式:',
|
3064
|
+
fileName : '名称',
|
3065
|
+
fileSize : '大小',
|
3066
|
+
fileType : '类型'
|
3067
|
+
};
|
3068
|
+
|
3069
|
+
plugins.advtable = {
|
3070
|
+
cells : '单元格数',
|
3071
|
+
rows : '行数',
|
3072
|
+
cols : '列数',
|
3073
|
+
size : '表格大小',
|
3074
|
+
width : '宽度',
|
3075
|
+
height : '高度',
|
3076
|
+
percent : '%',
|
3077
|
+
px : 'px',
|
3078
|
+
space : '边距间距',
|
3079
|
+
padding : '边距',
|
3080
|
+
spacing : '间距',
|
3081
|
+
align : '对齐方式',
|
3082
|
+
alignDefault : '默认',
|
3083
|
+
alignLeft : '左对齐',
|
3084
|
+
alignCenter : '居中',
|
3085
|
+
alignRight : '右对齐',
|
3086
|
+
border : '表格边框',
|
3087
|
+
borderWidth : '边框',
|
3088
|
+
borderColor : '颜色',
|
3089
|
+
backgroundColor : '背景颜色'
|
3090
|
+
};
|
3091
|
+
|
3092
|
+
plugins.title = {
|
3093
|
+
h1 : '标题 1',
|
3094
|
+
h2 : '标题 2',
|
3095
|
+
h3 : '标题 3',
|
3096
|
+
h4 : '标题 4',
|
3097
|
+
p : '正 文'
|
3098
|
+
};
|
3099
|
+
|
3100
|
+
plugins.fontname = {
|
3101
|
+
fontName : {
|
3102
|
+
'SimSun' : '宋体',
|
3103
|
+
'NSimSun' : '新宋体',
|
3104
|
+
'FangSong_GB2312' : '仿宋_GB2312',
|
3105
|
+
'KaiTi_GB2312' : '楷体_GB2312',
|
3106
|
+
'SimHei' : '黑体',
|
3107
|
+
'Microsoft YaHei' : '微软雅黑',
|
3108
|
+
'Arial' : 'Arial',
|
3109
|
+
'Arial Black' : 'Arial Black',
|
3110
|
+
'Times New Roman' : 'Times New Roman',
|
3111
|
+
'Courier New' : 'Courier New',
|
3112
|
+
'Tahoma' : 'Tahoma',
|
3113
|
+
'Verdana' : 'Verdana'
|
3114
|
+
}
|
3115
|
+
};
|
3116
|
+
|
3117
|
+
})(KindEditor);
|
3118
|
+
|
3119
|
+
(function (KE, undefined) {
|
3120
|
+
|
3121
|
+
KE.plugin['about'] = {
|
3122
|
+
click : function(id) {
|
3123
|
+
KE.util.selection(id);
|
3124
|
+
var dialog = new KE.dialog({
|
3125
|
+
id : id,
|
3126
|
+
cmd : 'about',
|
3127
|
+
file : 'about.html',
|
3128
|
+
width : 300,
|
3129
|
+
height : 70,
|
3130
|
+
loadingMode : true,
|
3131
|
+
title : KE.lang['about'],
|
3132
|
+
noButton : KE.lang['close']
|
3133
|
+
});
|
3134
|
+
dialog.show();
|
3135
|
+
}
|
3136
|
+
};
|
3137
|
+
|
3138
|
+
KE.plugin['undo'] = {
|
3139
|
+
init : function(id) {
|
3140
|
+
KE.event.ctrl(KE.g[id].iframeDoc, 'Z', function(e) {
|
3141
|
+
KE.plugin['undo'].click(id);
|
3142
|
+
KE.util.focus(id);
|
3143
|
+
}, id);
|
3144
|
+
KE.event.ctrl(KE.g[id].newTextarea, 'Z', function(e) {
|
3145
|
+
KE.plugin['undo'].click(id);
|
3146
|
+
KE.util.focus(id);
|
3147
|
+
}, id);
|
3148
|
+
},
|
3149
|
+
click : function(id) {
|
3150
|
+
KE.history.undo(id);
|
3151
|
+
KE.util.execOnchangeHandler(id);
|
3152
|
+
}
|
3153
|
+
};
|
3154
|
+
|
3155
|
+
KE.plugin['redo'] = {
|
3156
|
+
init : function(id) {
|
3157
|
+
KE.event.ctrl(KE.g[id].iframeDoc, 'Y', function(e) {
|
3158
|
+
KE.plugin['redo'].click(id);
|
3159
|
+
KE.util.focus(id);
|
3160
|
+
}, id);
|
3161
|
+
KE.event.ctrl(KE.g[id].newTextarea, 'Y', function(e) {
|
3162
|
+
KE.plugin['redo'].click(id);
|
3163
|
+
KE.util.focus(id);
|
3164
|
+
}, id);
|
3165
|
+
},
|
3166
|
+
click : function(id) {
|
3167
|
+
KE.history.redo(id);
|
3168
|
+
KE.util.execOnchangeHandler(id);
|
3169
|
+
}
|
3170
|
+
};
|
3171
|
+
|
3172
|
+
KE.plugin['cut'] = {
|
3173
|
+
click : function(id) {
|
3174
|
+
try {
|
3175
|
+
if (!KE.g[id].iframeDoc.queryCommandSupported('cut')) throw 'e';
|
3176
|
+
} catch(e) {
|
3177
|
+
alert(KE.lang.cutError);
|
3178
|
+
return;
|
3179
|
+
}
|
3180
|
+
KE.util.execCommand(id, 'cut', null);
|
3181
|
+
}
|
3182
|
+
};
|
3183
|
+
|
3184
|
+
KE.plugin['copy'] = {
|
3185
|
+
click : function(id) {
|
3186
|
+
try {
|
3187
|
+
if (!KE.g[id].iframeDoc.queryCommandSupported('copy')) throw 'e';
|
3188
|
+
} catch(e) {
|
3189
|
+
alert(KE.lang.copyError);
|
3190
|
+
return;
|
3191
|
+
}
|
3192
|
+
KE.util.execCommand(id, 'copy', null);
|
3193
|
+
}
|
3194
|
+
};
|
3195
|
+
|
3196
|
+
KE.plugin['paste'] = {
|
3197
|
+
click : function(id) {
|
3198
|
+
try {
|
3199
|
+
if (!KE.g[id].iframeDoc.queryCommandSupported('paste')) throw 'e';
|
3200
|
+
} catch(e) {
|
3201
|
+
alert(KE.lang.pasteError);
|
3202
|
+
return;
|
3203
|
+
}
|
3204
|
+
KE.util.execCommand(id, 'paste', null);
|
3205
|
+
}
|
3206
|
+
};
|
3207
|
+
|
3208
|
+
KE.plugin['plainpaste'] = {
|
3209
|
+
click : function(id) {
|
3210
|
+
KE.util.selection(id);
|
3211
|
+
this.dialog = new KE.dialog({
|
3212
|
+
id : id,
|
3213
|
+
cmd : 'plainpaste',
|
3214
|
+
file : 'plainpaste.html',
|
3215
|
+
width : 450,
|
3216
|
+
height : 300,
|
3217
|
+
loadingMode : true,
|
3218
|
+
title : KE.lang['plainpaste'],
|
3219
|
+
yesButton : KE.lang['yes'],
|
3220
|
+
noButton : KE.lang['no']
|
3221
|
+
});
|
3222
|
+
this.dialog.show();
|
3223
|
+
},
|
3224
|
+
exec : function(id) {
|
3225
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3226
|
+
var html = KE.$('textArea', dialogDoc).value;
|
3227
|
+
html = KE.util.escape(html);
|
3228
|
+
html = html.replace(/ /g, ' ');
|
3229
|
+
html = html.replace(/\r\n|\n|\r/g, "<br />$&");
|
3230
|
+
KE.util.insertHtml(id, html);
|
3231
|
+
this.dialog.hide();
|
3232
|
+
KE.util.focus(id);
|
3233
|
+
}
|
3234
|
+
};
|
3235
|
+
|
3236
|
+
KE.plugin['wordpaste'] = {
|
3237
|
+
click : function(id) {
|
3238
|
+
KE.util.selection(id);
|
3239
|
+
this.dialog = new KE.dialog({
|
3240
|
+
id : id,
|
3241
|
+
cmd : 'wordpaste',
|
3242
|
+
file : 'wordpaste.html',
|
3243
|
+
width : 450,
|
3244
|
+
height : 300,
|
3245
|
+
loadingMode : true,
|
3246
|
+
title : KE.lang['wordpaste'],
|
3247
|
+
yesButton : KE.lang['yes'],
|
3248
|
+
noButton : KE.lang['no']
|
3249
|
+
});
|
3250
|
+
this.dialog.show();
|
3251
|
+
},
|
3252
|
+
exec : function(id) {
|
3253
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3254
|
+
var wordIframe = KE.$('wordIframe', dialogDoc);
|
3255
|
+
var str = KE.util.getIframeDoc(wordIframe).body.innerHTML;
|
3256
|
+
str = str.replace(/<meta(\n|.)*?>/ig, "");
|
3257
|
+
str = str.replace(/<!(\n|.)*?>/ig, "");
|
3258
|
+
str = str.replace(/<style[^>]*>(\n|.)*?<\/style>/ig, "");
|
3259
|
+
str = str.replace(/<script[^>]*>(\n|.)*?<\/script>/ig, "");
|
3260
|
+
str = str.replace(/<w:[^>]+>(\n|.)*?<\/w:[^>]+>/ig, "");
|
3261
|
+
str = str.replace(/<xml>(\n|.)*?<\/xml>/ig, "");
|
3262
|
+
str = str.replace(/\r\n|\n|\r/ig, "");
|
3263
|
+
str = KE.util.execGetHtmlHooks(id, str);
|
3264
|
+
str = KE.format.getHtml(str, KE.g[id].htmlTags, KE.g[id].urlType);
|
3265
|
+
KE.util.insertHtml(id, str);
|
3266
|
+
this.dialog.hide();
|
3267
|
+
KE.util.focus(id);
|
3268
|
+
}
|
3269
|
+
};
|
3270
|
+
|
3271
|
+
KE.plugin['fullscreen'] = {
|
3272
|
+
click : function(id) {
|
3273
|
+
var g = KE.g[id];
|
3274
|
+
var self = this;
|
3275
|
+
var resetSize = function() {
|
3276
|
+
var el = KE.util.getDocumentElement();
|
3277
|
+
g.width = el.clientWidth + 'px';
|
3278
|
+
g.height = el.clientHeight + 'px';
|
3279
|
+
};
|
3280
|
+
var windowSize = '';
|
3281
|
+
var resizeListener = function() {
|
3282
|
+
if (!self.isSelected) return;
|
3283
|
+
var el = KE.util.getDocumentElement();
|
3284
|
+
var size = [el.clientWidth, el.clientHeight].join('');
|
3285
|
+
if (windowSize != size) {
|
3286
|
+
windowSize = size;
|
3287
|
+
resetSize();
|
3288
|
+
KE.util.resize(id, g.width, g.height);
|
3289
|
+
}
|
3290
|
+
}
|
3291
|
+
if (this.isSelected) {
|
3292
|
+
this.isSelected = false;
|
3293
|
+
KE.util.setData(id);
|
3294
|
+
KE.remove(id, 1);
|
3295
|
+
g.width = this.width;
|
3296
|
+
g.height = this.height;
|
3297
|
+
KE.create(id, 2);
|
3298
|
+
document.body.parentNode.style.overflow = 'auto';
|
3299
|
+
KE.event.remove(window, 'resize', resizeListener);
|
3300
|
+
g.resizeMode = g.config.resizeMode;
|
3301
|
+
KE.toolbar.unselect(id, "fullscreen");
|
3302
|
+
} else {
|
3303
|
+
this.isSelected = true;
|
3304
|
+
this.width = g.container.style.width;
|
3305
|
+
this.height = g.container.style.height;
|
3306
|
+
KE.util.setData(id);
|
3307
|
+
KE.remove(id, 2);
|
3308
|
+
document.body.parentNode.style.overflow = 'hidden';
|
3309
|
+
resetSize();
|
3310
|
+
KE.create(id, 1);
|
3311
|
+
var pos = KE.util.getScrollPos();
|
3312
|
+
var div = g.container;
|
3313
|
+
div.style.position = 'absolute';
|
3314
|
+
div.style.left = pos.x + 'px';
|
3315
|
+
div.style.top = pos.y + 'px';
|
3316
|
+
div.style.zIndex = 19811211;
|
3317
|
+
KE.event.add(window, 'resize', resizeListener);
|
3318
|
+
g.resizeMode = 0;
|
3319
|
+
KE.toolbar.select(id, "fullscreen");
|
3320
|
+
}
|
3321
|
+
}
|
3322
|
+
};
|
3323
|
+
|
3324
|
+
KE.plugin['bgcolor'] = {
|
3325
|
+
click : function(id) {
|
3326
|
+
KE.util.selection(id);
|
3327
|
+
var color = KE.queryCommandValue(KE.g[id].iframeDoc, 'bgcolor');
|
3328
|
+
this.menu = new KE.menu({
|
3329
|
+
id : id,
|
3330
|
+
cmd : 'bgcolor'
|
3331
|
+
});
|
3332
|
+
this.menu.picker(color);
|
3333
|
+
},
|
3334
|
+
exec : function(id, value) {
|
3335
|
+
var cmd = new KE.cmd(id);
|
3336
|
+
if (value == '') {
|
3337
|
+
cmd.remove({
|
3338
|
+
'span' : ['.background-color']
|
3339
|
+
});
|
3340
|
+
} else {
|
3341
|
+
cmd.wrap('span', [{'.background-color': value}]);
|
3342
|
+
}
|
3343
|
+
KE.util.execOnchangeHandler(id);
|
3344
|
+
this.menu.hide();
|
3345
|
+
KE.util.focus(id);
|
3346
|
+
}
|
3347
|
+
};
|
3348
|
+
|
3349
|
+
KE.plugin['fontname'] = {
|
3350
|
+
click : function(id) {
|
3351
|
+
var fontName = KE.lang.plugins.fontname.fontName;
|
3352
|
+
var cmd = 'fontname';
|
3353
|
+
KE.util.selection(id);
|
3354
|
+
var menu = new KE.menu({
|
3355
|
+
id : id,
|
3356
|
+
cmd : cmd,
|
3357
|
+
width : 150
|
3358
|
+
});
|
3359
|
+
var font = KE.queryCommandValue(KE.g[id].iframeDoc, cmd);
|
3360
|
+
KE.each(fontName, function(key, value) {
|
3361
|
+
var html = '<span class="ke-reset" style="font-family: ' + key + ';">' + value + '</span>';
|
3362
|
+
menu.add(
|
3363
|
+
html,
|
3364
|
+
function() { KE.plugin[cmd].exec(id, key); },
|
3365
|
+
{ checked : (font === key.toLowerCase() || font === value.toLowerCase()) }
|
3366
|
+
);
|
3367
|
+
});
|
3368
|
+
menu.show();
|
3369
|
+
this.menu = menu;
|
3370
|
+
},
|
3371
|
+
exec : function(id, value) {
|
3372
|
+
var cmd = new KE.cmd(id);
|
3373
|
+
cmd.wrap('span', [{'.font-family': value}]);
|
3374
|
+
KE.util.execOnchangeHandler(id);
|
3375
|
+
this.menu.hide();
|
3376
|
+
KE.util.focus(id);
|
3377
|
+
}
|
3378
|
+
};
|
3379
|
+
|
3380
|
+
KE.plugin['fontsize'] = {
|
3381
|
+
click : function(id) {
|
3382
|
+
var fontSize = ['9px', '10px', '12px', '14px', '16px', '18px', '24px', '32px'];
|
3383
|
+
var cmd = 'fontsize';
|
3384
|
+
KE.util.selection(id);
|
3385
|
+
var size = KE.queryCommandValue(KE.g[id].iframeDoc, 'fontsize');
|
3386
|
+
var menu = new KE.menu({
|
3387
|
+
id : id,
|
3388
|
+
cmd : cmd,
|
3389
|
+
width : 120
|
3390
|
+
});
|
3391
|
+
for (var i = 0, len = fontSize.length; i < len; i++) {
|
3392
|
+
var value = fontSize[i];
|
3393
|
+
var html = '<span class="ke-reset" style="font-size: ' + value + ';">' + value + '</span>';
|
3394
|
+
menu.add(
|
3395
|
+
html,
|
3396
|
+
(function(value) {
|
3397
|
+
return function() {
|
3398
|
+
KE.plugin[cmd].exec(id, value);
|
3399
|
+
};
|
3400
|
+
})(value),
|
3401
|
+
{
|
3402
|
+
height : (parseInt(value) + 12) + 'px',
|
3403
|
+
checked : (size === value)
|
3404
|
+
}
|
3405
|
+
);
|
3406
|
+
}
|
3407
|
+
menu.show();
|
3408
|
+
this.menu = menu;
|
3409
|
+
},
|
3410
|
+
exec : function(id, value) {
|
3411
|
+
var cmd = new KE.cmd(id);
|
3412
|
+
cmd.wrap('span', [{'.font-size': value}]);
|
3413
|
+
KE.util.execOnchangeHandler(id);
|
3414
|
+
this.menu.hide();
|
3415
|
+
KE.util.focus(id);
|
3416
|
+
}
|
3417
|
+
};
|
3418
|
+
|
3419
|
+
KE.plugin['hr'] = {
|
3420
|
+
click : function(id) {
|
3421
|
+
KE.util.selection(id);
|
3422
|
+
KE.util.insertHtml(id, '<hr />');
|
3423
|
+
KE.util.focus(id);
|
3424
|
+
}
|
3425
|
+
};
|
3426
|
+
|
3427
|
+
KE.plugin['print'] = {
|
3428
|
+
click : function(id) {
|
3429
|
+
KE.util.selection(id);
|
3430
|
+
KE.g[id].iframeWin.print();
|
3431
|
+
}
|
3432
|
+
};
|
3433
|
+
|
3434
|
+
KE.plugin['removeformat'] = {
|
3435
|
+
click : function(id) {
|
3436
|
+
KE.util.selection(id);
|
3437
|
+
var cmd = new KE.cmd(id);
|
3438
|
+
var tags = {
|
3439
|
+
'*' : ['class', 'style']
|
3440
|
+
};
|
3441
|
+
for (var i = 0, len = KE.g[id].inlineTags.length; i < len; i++) {
|
3442
|
+
tags[KE.g[id].inlineTags[i]] = ['*'];
|
3443
|
+
}
|
3444
|
+
cmd.remove(tags);
|
3445
|
+
KE.util.execOnchangeHandler(id);
|
3446
|
+
KE.toolbar.updateState(id);
|
3447
|
+
KE.util.focus(id);
|
3448
|
+
}
|
3449
|
+
};
|
3450
|
+
|
3451
|
+
KE.plugin['source'] = {
|
3452
|
+
click : function(id) {
|
3453
|
+
var g = KE.g[id];
|
3454
|
+
if (!g.wyswygMode) {
|
3455
|
+
KE.util.setFullHtml(id, g.newTextarea.value);
|
3456
|
+
g.iframe.style.display = 'block';
|
3457
|
+
g.newTextarea.style.display = 'none';
|
3458
|
+
KE.toolbar.able(id, ['source', 'fullscreen']);
|
3459
|
+
g.wyswygMode = true;
|
3460
|
+
this.isSelected = false;
|
3461
|
+
KE.toolbar.unselect(id, "source");
|
3462
|
+
} else {
|
3463
|
+
KE.hideMenu(id);
|
3464
|
+
g.newTextarea.value = KE.util.getData(id);
|
3465
|
+
g.iframe.style.display = 'none';
|
3466
|
+
g.newTextarea.style.display = 'block';
|
3467
|
+
KE.toolbar.disable(id, ['source', 'fullscreen']);
|
3468
|
+
g.wyswygMode = false;
|
3469
|
+
this.isSelected = true;
|
3470
|
+
KE.toolbar.select(id, "source");
|
3471
|
+
}
|
3472
|
+
KE.util.focus(id);
|
3473
|
+
}
|
3474
|
+
};
|
3475
|
+
|
3476
|
+
KE.plugin['textcolor'] = {
|
3477
|
+
click : function(id) {
|
3478
|
+
KE.util.selection(id);
|
3479
|
+
var color = KE.queryCommandValue(KE.g[id].iframeDoc, 'textcolor');
|
3480
|
+
this.menu = new KE.menu({
|
3481
|
+
id : id,
|
3482
|
+
cmd : 'textcolor'
|
3483
|
+
});
|
3484
|
+
this.menu.picker(color);
|
3485
|
+
},
|
3486
|
+
exec : function(id, value) {
|
3487
|
+
var cmd = new KE.cmd(id);
|
3488
|
+
if (value == '') {
|
3489
|
+
cmd.remove({
|
3490
|
+
'span' : ['.color'],
|
3491
|
+
'font' : ['color']
|
3492
|
+
});
|
3493
|
+
} else {
|
3494
|
+
cmd.wrap('span', [{'.color': value}]);
|
3495
|
+
}
|
3496
|
+
KE.util.execOnchangeHandler(id);
|
3497
|
+
this.menu.hide();
|
3498
|
+
KE.util.focus(id);
|
3499
|
+
}
|
3500
|
+
};
|
3501
|
+
|
3502
|
+
KE.plugin['title'] = {
|
3503
|
+
click : function(id) {
|
3504
|
+
var lang = KE.lang.plugins.title;
|
3505
|
+
var title = {
|
3506
|
+
'H1' : lang.h1,
|
3507
|
+
'H2' : lang.h2,
|
3508
|
+
'H3' : lang.h3,
|
3509
|
+
'H4' : lang.h4,
|
3510
|
+
'P' : lang.p
|
3511
|
+
};
|
3512
|
+
var sizeHash = {
|
3513
|
+
'H1' : 28,
|
3514
|
+
'H2' : 24,
|
3515
|
+
'H3' : 18,
|
3516
|
+
'H4' : 14,
|
3517
|
+
'P' : 12
|
3518
|
+
};
|
3519
|
+
var cmd = 'title';
|
3520
|
+
KE.util.selection(id);
|
3521
|
+
var block = KE.queryCommandValue(KE.g[id].iframeDoc, 'formatblock');
|
3522
|
+
var menu = new KE.menu({
|
3523
|
+
id : id,
|
3524
|
+
cmd : cmd,
|
3525
|
+
width : (KE.langType == 'en' ? 200 : 150)
|
3526
|
+
});
|
3527
|
+
KE.each(title, function(key, value) {
|
3528
|
+
var style = 'font-size:' + sizeHash[key] + 'px;'
|
3529
|
+
if (key !== 'P') style += 'font-weight:bold;';
|
3530
|
+
var html = '<span class="ke-reset" style="' + style + '">' + value + '</span>';
|
3531
|
+
menu.add(html, function() {
|
3532
|
+
KE.plugin[cmd].exec(id, '<' + key + '>'); },
|
3533
|
+
{
|
3534
|
+
height : (sizeHash[key] + 12) + 'px',
|
3535
|
+
checked : (block === key.toLowerCase() || block === value.toLowerCase() )
|
3536
|
+
}
|
3537
|
+
);
|
3538
|
+
});
|
3539
|
+
menu.show();
|
3540
|
+
this.menu = menu;
|
3541
|
+
},
|
3542
|
+
exec : function(id, value) {
|
3543
|
+
KE.util.select(id);
|
3544
|
+
KE.util.execCommand(id, 'formatblock', value);
|
3545
|
+
this.menu.hide();
|
3546
|
+
KE.util.focus(id);
|
3547
|
+
}
|
3548
|
+
};
|
3549
|
+
|
3550
|
+
KE.plugin['emoticons'] = {
|
3551
|
+
click : function(id) {
|
3552
|
+
var self = this,
|
3553
|
+
cmd = 'emoticons',
|
3554
|
+
rows = 5,
|
3555
|
+
cols = 9,
|
3556
|
+
total = 135,
|
3557
|
+
startNum = 0,
|
3558
|
+
cells = rows * cols,
|
3559
|
+
pages = Math.ceil(total / cells),
|
3560
|
+
colsHalf = Math.floor(cols / 2),
|
3561
|
+
g = KE.g[id],
|
3562
|
+
path = g.pluginsPath + 'emoticons/',
|
3563
|
+
allowPreview = (g.allowPreviewEmoticons === undefined) ? true : g.allowPreviewEmoticons;
|
3564
|
+
KE.util.selection(id);
|
3565
|
+
var wrapperDiv = KE.$$('div');
|
3566
|
+
wrapperDiv.className = 'ke-plugin-emoticons-wrapper';
|
3567
|
+
var previewDiv, previewImg;
|
3568
|
+
if (allowPreview) {
|
3569
|
+
previewDiv = KE.$$('div');
|
3570
|
+
previewDiv.className = 'ke-plugin-emoticons-preview';
|
3571
|
+
previewDiv.style.right = 0;
|
3572
|
+
var previewImg = KE.$$('img');
|
3573
|
+
previewImg.className = 'ke-reset';
|
3574
|
+
previewImg.src = path + '0.gif';
|
3575
|
+
previewImg.border = 0;
|
3576
|
+
previewDiv.appendChild(previewImg);
|
3577
|
+
wrapperDiv.appendChild(previewDiv);
|
3578
|
+
}
|
3579
|
+
function createEmoticonsTable(pageNum) {
|
3580
|
+
var table = KE.$$('table');
|
3581
|
+
if (previewDiv) {
|
3582
|
+
table.onmouseover = function() { previewDiv.style.display = 'block'; };
|
3583
|
+
table.onmouseout = function() { previewDiv.style.display = 'none'; };
|
3584
|
+
}
|
3585
|
+
table.className = 'ke-plugin-emoticons-table';
|
3586
|
+
table.cellPadding = 0;
|
3587
|
+
table.cellSpacing = 0;
|
3588
|
+
table.border = 0;
|
3589
|
+
var num = (pageNum - 1) * cells + startNum;
|
3590
|
+
for (var i = 0; i < rows; i++) {
|
3591
|
+
var row = table.insertRow(i);
|
3592
|
+
for (var j = 0; j < cols; j++) {
|
3593
|
+
var cell = row.insertCell(j);
|
3594
|
+
cell.className = 'ke-plugin-emoticons-cell';
|
3595
|
+
if (previewDiv) {
|
3596
|
+
cell.onmouseover = (function(j, num) {
|
3597
|
+
return function() {
|
3598
|
+
if (j > colsHalf) {
|
3599
|
+
previewDiv.style.left = 0;
|
3600
|
+
previewDiv.style.right = '';
|
3601
|
+
} else {
|
3602
|
+
previewDiv.style.left = '';
|
3603
|
+
previewDiv.style.right = 0;
|
3604
|
+
}
|
3605
|
+
previewImg.src = path + num + '.gif';;
|
3606
|
+
this.className = 'ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on';
|
3607
|
+
};
|
3608
|
+
})(j, num);
|
3609
|
+
} else {
|
3610
|
+
cell.onmouseover = function() {
|
3611
|
+
this.className = 'ke-plugin-emoticons-cell ke-plugin-emoticons-cell-on';
|
3612
|
+
};
|
3613
|
+
}
|
3614
|
+
cell.onmouseout = function() { this.className = 'ke-plugin-emoticons-cell'; };
|
3615
|
+
cell.onclick = (function(num) {
|
3616
|
+
return function() {
|
3617
|
+
self.exec(id, num);
|
3618
|
+
return false;
|
3619
|
+
};
|
3620
|
+
})(num);
|
3621
|
+
var span = KE.$$('span');
|
3622
|
+
span.className = 'ke-plugin-emoticons-img';
|
3623
|
+
span.style.backgroundPosition = '-' + (24 * num) + 'px 0px';
|
3624
|
+
cell.appendChild(span);
|
3625
|
+
num++;
|
3626
|
+
}
|
3627
|
+
}
|
3628
|
+
return table;
|
3629
|
+
}
|
3630
|
+
var table = createEmoticonsTable(1);
|
3631
|
+
wrapperDiv.appendChild(table);
|
3632
|
+
var pageDiv = KE.$$('div');
|
3633
|
+
pageDiv.className = 'ke-plugin-emoticons-page';
|
3634
|
+
wrapperDiv.appendChild(pageDiv);
|
3635
|
+
function createPageTable(currentPageNum) {
|
3636
|
+
for (var pageNum = 1; pageNum <= pages; pageNum++) {
|
3637
|
+
if (currentPageNum !== pageNum) {
|
3638
|
+
var a = KE.$$('a');
|
3639
|
+
a.href = 'javascript:;';
|
3640
|
+
a.innerHTML = '[' + pageNum + ']';
|
3641
|
+
a.onclick = (function(pageNum) {
|
3642
|
+
return function() {
|
3643
|
+
wrapperDiv.removeChild(table);
|
3644
|
+
var newTable = createEmoticonsTable(pageNum);
|
3645
|
+
wrapperDiv.insertBefore(newTable, pageDiv);
|
3646
|
+
table = newTable;
|
3647
|
+
pageDiv.innerHTML = '';
|
3648
|
+
createPageTable(pageNum);
|
3649
|
+
return false;
|
3650
|
+
};
|
3651
|
+
})(pageNum);
|
3652
|
+
pageDiv.appendChild(a);
|
3653
|
+
} else {
|
3654
|
+
pageDiv.appendChild(document.createTextNode('[' + pageNum + ']'));
|
3655
|
+
}
|
3656
|
+
pageDiv.appendChild(document.createTextNode(' '));
|
3657
|
+
}
|
3658
|
+
}
|
3659
|
+
createPageTable(1);
|
3660
|
+
var menu = new KE.menu({
|
3661
|
+
id : id,
|
3662
|
+
cmd : cmd
|
3663
|
+
});
|
3664
|
+
menu.append(wrapperDiv);
|
3665
|
+
menu.show();
|
3666
|
+
this.menu = menu;
|
3667
|
+
},
|
3668
|
+
exec : function(id, num) {
|
3669
|
+
var src = KE.g[id].pluginsPath + 'emoticons/' + num + '.gif';
|
3670
|
+
var html = '<img src="' + src + '" kesrc="' + src + '" border="0" alt="" />';
|
3671
|
+
KE.util.insertHtml(id, html);
|
3672
|
+
this.menu.hide();
|
3673
|
+
KE.util.focus(id);
|
3674
|
+
}
|
3675
|
+
};
|
3676
|
+
|
3677
|
+
KE.plugin['flash'] = {
|
3678
|
+
init : function(id) {
|
3679
|
+
var self = this;
|
3680
|
+
KE.g[id].getHtmlHooks.push(function(html) {
|
3681
|
+
return html.replace(/<img[^>]*class="?ke-flash"?[^>]*>/ig, function(imgStr) {
|
3682
|
+
var width = imgStr.match(/style="[^"]*;?\s*width:\s*(\d+)/i) ? RegExp.$1 : 0;
|
3683
|
+
var height = imgStr.match(/style="[^"]*;?\s*height:\s*(\d+)/i) ? RegExp.$1 : 0;
|
3684
|
+
width = width || (imgStr.match(/width="([^"]+)"/i) ? RegExp.$1 : 0);
|
3685
|
+
height = height || (imgStr.match(/height="([^"]+)"/i) ? RegExp.$1 : 0);
|
3686
|
+
if (imgStr.match(/kesrctag="([^"]+)"/i)) {
|
3687
|
+
var attrs = KE.util.getAttrList(unescape(RegExp.$1));
|
3688
|
+
attrs.width = width || attrs.width || 0;
|
3689
|
+
attrs.height = height || attrs.height || 0;
|
3690
|
+
attrs.kesrc = attrs.src;
|
3691
|
+
return KE.util.getMediaEmbed(attrs);
|
3692
|
+
}
|
3693
|
+
});
|
3694
|
+
});
|
3695
|
+
KE.g[id].setHtmlHooks.push(function(html) {
|
3696
|
+
return html.replace(/<embed[^>]*type="application\/x-shockwave-flash"[^>]*>(?:<\/embed>)?/ig, function($0) {
|
3697
|
+
var src = $0.match(/\s+src="([^"]+)"/i) ? RegExp.$1 : '';
|
3698
|
+
if ($0.match(/\s+kesrc="([^"]+)"/i)) src = RegExp.$1;
|
3699
|
+
var width = $0.match(/\s+width="([^"]+)"/i) ? RegExp.$1 : 0;
|
3700
|
+
var height = $0.match(/\s+height="([^"]+)"/i) ? RegExp.$1 : 0;
|
3701
|
+
var attrs = KE.util.getAttrList($0);
|
3702
|
+
attrs.src = src;
|
3703
|
+
attrs.width = width;
|
3704
|
+
attrs.height = height;
|
3705
|
+
return KE.util.getMediaImage(id, 'flash', attrs);
|
3706
|
+
});
|
3707
|
+
});
|
3708
|
+
},
|
3709
|
+
click : function(id) {
|
3710
|
+
KE.util.selection(id);
|
3711
|
+
this.dialog = new KE.dialog({
|
3712
|
+
id : id,
|
3713
|
+
cmd : 'flash',
|
3714
|
+
file : 'flash.html',
|
3715
|
+
width : 400,
|
3716
|
+
height : 140,
|
3717
|
+
loadingMode : true,
|
3718
|
+
title : KE.lang['flash'],
|
3719
|
+
yesButton : KE.lang['yes'],
|
3720
|
+
noButton : KE.lang['no']
|
3721
|
+
});
|
3722
|
+
this.dialog.show();
|
3723
|
+
},
|
3724
|
+
check : function(id, url, width, height) {
|
3725
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3726
|
+
if (!url.match(/^.{3,}$/)) {
|
3727
|
+
alert(KE.lang['invalidUrl']);
|
3728
|
+
KE.$('url', dialogDoc).focus();
|
3729
|
+
return false;
|
3730
|
+
}
|
3731
|
+
if (!width.match(/^\d*$/)) {
|
3732
|
+
alert(KE.lang['invalidWidth']);
|
3733
|
+
KE.$('width', dialogDoc).focus();
|
3734
|
+
return false;
|
3735
|
+
}
|
3736
|
+
if (!height.match(/^\d*$/)) {
|
3737
|
+
alert(KE.lang['invalidHeight']);
|
3738
|
+
KE.$('height', dialogDoc).focus();
|
3739
|
+
return false;
|
3740
|
+
}
|
3741
|
+
return true;
|
3742
|
+
},
|
3743
|
+
exec : function(id) {
|
3744
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3745
|
+
var url = KE.$('url', dialogDoc).value;
|
3746
|
+
var width = KE.$('width', dialogDoc).value;
|
3747
|
+
var height = KE.$('height', dialogDoc).value;
|
3748
|
+
if (!this.check(id, url, width, height)) return false;
|
3749
|
+
var html = KE.util.getMediaImage(id, 'flash', {
|
3750
|
+
src : url,
|
3751
|
+
type : KE.g[id].mediaTypes['flash'],
|
3752
|
+
width : width,
|
3753
|
+
height : height,
|
3754
|
+
quality : 'high'
|
3755
|
+
});
|
3756
|
+
KE.util.insertHtml(id, html);
|
3757
|
+
this.dialog.hide();
|
3758
|
+
KE.util.focus(id);
|
3759
|
+
}
|
3760
|
+
};
|
3761
|
+
|
3762
|
+
KE.plugin['image'] = {
|
3763
|
+
getSelectedNode : function(id) {
|
3764
|
+
var g = KE.g[id];
|
3765
|
+
var startNode = g.keRange.startNode;
|
3766
|
+
var endNode = g.keRange.endNode;
|
3767
|
+
if (!KE.browser.WEBKIT && !g.keSel.isControl) return;
|
3768
|
+
if (startNode.nodeType != 1) return;
|
3769
|
+
if (startNode.tagName.toLowerCase() != 'img') return;
|
3770
|
+
if (startNode != endNode) return;
|
3771
|
+
if (!startNode.className.match(/^ke-\w+/i)) return startNode;
|
3772
|
+
},
|
3773
|
+
init : function(id) {
|
3774
|
+
var self = this;
|
3775
|
+
var g = KE.g[id];
|
3776
|
+
g.contextmenuItems.push({
|
3777
|
+
text : KE.lang['editImage'],
|
3778
|
+
click : function(id, menu) {
|
3779
|
+
KE.util.select(id);
|
3780
|
+
menu.hide();
|
3781
|
+
self.click(id);
|
3782
|
+
},
|
3783
|
+
cond : function(id) {
|
3784
|
+
return self.getSelectedNode(id);
|
3785
|
+
},
|
3786
|
+
options : {
|
3787
|
+
width : '150px',
|
3788
|
+
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-image"></span>'
|
3789
|
+
}
|
3790
|
+
});
|
3791
|
+
g.contextmenuItems.push({
|
3792
|
+
text : KE.lang['deleteImage'],
|
3793
|
+
click : function(id, menu) {
|
3794
|
+
KE.util.select(id);
|
3795
|
+
menu.hide();
|
3796
|
+
var img = self.getSelectedNode(id);
|
3797
|
+
img.parentNode.removeChild(img);
|
3798
|
+
KE.util.execOnchangeHandler(id);
|
3799
|
+
},
|
3800
|
+
cond : function(id) {
|
3801
|
+
return self.getSelectedNode(id);
|
3802
|
+
},
|
3803
|
+
options : {
|
3804
|
+
width : '150px'
|
3805
|
+
}
|
3806
|
+
});
|
3807
|
+
g.contextmenuItems.push('-');
|
3808
|
+
},
|
3809
|
+
click : function(id) {
|
3810
|
+
KE.util.selection(id);
|
3811
|
+
this.dialog = new KE.dialog({
|
3812
|
+
id : id,
|
3813
|
+
cmd : 'image',
|
3814
|
+
file : 'image/image.html',
|
3815
|
+
width : 400,
|
3816
|
+
height : 220,
|
3817
|
+
loadingMode : true,
|
3818
|
+
title : KE.lang['image'],
|
3819
|
+
yesButton : KE.lang['yes'],
|
3820
|
+
noButton : KE.lang['no']
|
3821
|
+
});
|
3822
|
+
this.dialog.show();
|
3823
|
+
},
|
3824
|
+
check : function(id) {
|
3825
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3826
|
+
var type = KE.$('type', dialogDoc).value;
|
3827
|
+
var width = KE.$('imgWidth', dialogDoc).value;
|
3828
|
+
var height = KE.$('imgHeight', dialogDoc).value;
|
3829
|
+
var title = KE.$('imgTitle', dialogDoc).value;
|
3830
|
+
var urlBox;
|
3831
|
+
if (type == 2) {
|
3832
|
+
urlBox = KE.$('imgFile', dialogDoc);
|
3833
|
+
} else {
|
3834
|
+
urlBox = KE.$('url', dialogDoc);
|
3835
|
+
}
|
3836
|
+
if (!urlBox.value.match(/\.(jpg|jpeg|gif|bmp|png)(\s|\?|$)/i)) {
|
3837
|
+
alert(KE.lang['invalidImg']);
|
3838
|
+
urlBox.focus();
|
3839
|
+
return false;
|
3840
|
+
}
|
3841
|
+
if (!width.match(/^\d*$/)) {
|
3842
|
+
alert(KE.lang['invalidWidth']);
|
3843
|
+
KE.$('imgWidth', dialogDoc).focus();
|
3844
|
+
return false;
|
3845
|
+
}
|
3846
|
+
if (!height.match(/^\d*$/)) {
|
3847
|
+
alert(KE.lang['invalidHeight']);
|
3848
|
+
KE.$('imgHeight', dialogDoc).focus();
|
3849
|
+
return false;
|
3850
|
+
}
|
3851
|
+
return true;
|
3852
|
+
},
|
3853
|
+
exec : function(id) {
|
3854
|
+
var self = this;
|
3855
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3856
|
+
var type = KE.$('type', dialogDoc).value;
|
3857
|
+
var width = KE.$('imgWidth', dialogDoc).value;
|
3858
|
+
var height = KE.$('imgHeight', dialogDoc).value;
|
3859
|
+
var title = KE.$('imgTitle', dialogDoc).value;
|
3860
|
+
var alignElements = dialogDoc.getElementsByName('align');
|
3861
|
+
var align = '';
|
3862
|
+
for (var i = 0, len = alignElements.length; i < len; i++) {
|
3863
|
+
if (alignElements[i].checked) {
|
3864
|
+
align = alignElements[i].value;
|
3865
|
+
break;
|
3866
|
+
}
|
3867
|
+
}
|
3868
|
+
if (!this.check(id)) return false;
|
3869
|
+
if (type == 2) {
|
3870
|
+
KE.$('editorId', dialogDoc).value = id;
|
3871
|
+
var uploadIframe = KE.$('uploadIframe', dialogDoc);
|
3872
|
+
KE.util.showLoadingPage(id);
|
3873
|
+
var onloadFunc = function() {
|
3874
|
+
KE.event.remove(uploadIframe, 'load', onloadFunc);
|
3875
|
+
KE.util.hideLoadingPage(id);
|
3876
|
+
var uploadDoc = KE.util.getIframeDoc(uploadIframe);
|
3877
|
+
var data = '';
|
3878
|
+
try {
|
3879
|
+
data = KE.util.parseJson(uploadDoc.body.innerHTML);
|
3880
|
+
} catch(e) {
|
3881
|
+
alert(KE.lang.invalidJson);
|
3882
|
+
}
|
3883
|
+
if (typeof data === 'object' && 'error' in data) {
|
3884
|
+
if (data.error === 0) {
|
3885
|
+
self.insert(id, data.url, title, width, height, 0, align);
|
3886
|
+
} else {
|
3887
|
+
alert(data.message);
|
3888
|
+
return false;
|
3889
|
+
}
|
3890
|
+
}
|
3891
|
+
};
|
3892
|
+
KE.event.add(uploadIframe, 'load', onloadFunc);
|
3893
|
+
dialogDoc.uploadForm.submit();
|
3894
|
+
return;
|
3895
|
+
} else {
|
3896
|
+
var url = KE.$('url', dialogDoc).value;
|
3897
|
+
this.insert(id, url, title, width, height, 0, align);
|
3898
|
+
}
|
3899
|
+
},
|
3900
|
+
insert : function(id, url, title, width, height, border, align) {
|
3901
|
+
var html = '<img src="' + url + '" kesrc="' + url + '" ';
|
3902
|
+
if (width > 0) html += 'width="' + width + '" ';
|
3903
|
+
if (height > 0) html += 'height="' + height + '" ';
|
3904
|
+
if (title) html += 'title="' + title + '" ';
|
3905
|
+
if (align) html += 'align="' + align + '" ';
|
3906
|
+
html += 'alt="' + title + '" ';
|
3907
|
+
html += 'border="' + border + '" />';
|
3908
|
+
KE.util.insertHtml(id, html);
|
3909
|
+
this.dialog.hide();
|
3910
|
+
KE.util.focus(id);
|
3911
|
+
}
|
3912
|
+
};
|
3913
|
+
|
3914
|
+
KE.plugin['link'] = {
|
3915
|
+
getSelectedNode : function(id) {
|
3916
|
+
return KE.getCommonAncestor(KE.g[id].keSel, 'a');
|
3917
|
+
},
|
3918
|
+
init : function(id) {
|
3919
|
+
var self = this;
|
3920
|
+
KE.g[id].contextmenuItems.push({
|
3921
|
+
text : KE.lang['editLink'],
|
3922
|
+
click : function(id, menu) {
|
3923
|
+
KE.util.select(id);
|
3924
|
+
menu.hide();
|
3925
|
+
self.click(id);
|
3926
|
+
},
|
3927
|
+
cond : function(id) {
|
3928
|
+
return self.getSelectedNode(id);
|
3929
|
+
},
|
3930
|
+
options : {
|
3931
|
+
width : '150px',
|
3932
|
+
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-link"></span>'
|
3933
|
+
}
|
3934
|
+
});
|
3935
|
+
},
|
3936
|
+
click : function(id) {
|
3937
|
+
KE.util.selection(id);
|
3938
|
+
this.dialog = new KE.dialog({
|
3939
|
+
id : id,
|
3940
|
+
cmd : 'link',
|
3941
|
+
file : 'link/link.html',
|
3942
|
+
width : 400,
|
3943
|
+
height : 90,
|
3944
|
+
loadingMode : true,
|
3945
|
+
title : KE.lang['link'],
|
3946
|
+
yesButton : KE.lang['yes'],
|
3947
|
+
noButton : KE.lang['no']
|
3948
|
+
});
|
3949
|
+
this.dialog.show();
|
3950
|
+
},
|
3951
|
+
exec : function(id) {
|
3952
|
+
var g = KE.g[id];
|
3953
|
+
KE.util.select(id);
|
3954
|
+
var range = g.keRange;
|
3955
|
+
var startNode = range.startNode;
|
3956
|
+
var endNode = range.endNode;
|
3957
|
+
var iframeDoc = g.iframeDoc;
|
3958
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
3959
|
+
var url = KE.$('hyperLink', dialogDoc).value;
|
3960
|
+
var target = KE.$('linkType', dialogDoc).value;
|
3961
|
+
if (!url.match(/.+/) || url.match(/^\w+:\/\/\/?$/)) {
|
3962
|
+
alert(KE.lang['invalidUrl']);
|
3963
|
+
KE.$('hyperLink', dialogDoc).focus();
|
3964
|
+
return false;
|
3965
|
+
}
|
3966
|
+
var node = range.getParentElement();
|
3967
|
+
while (node) {
|
3968
|
+
if (node.tagName.toLowerCase() == 'a' || node.tagName.toLowerCase() == 'body') break;
|
3969
|
+
node = node.parentNode;
|
3970
|
+
}
|
3971
|
+
node = node.parentNode;
|
3972
|
+
var isItem;
|
3973
|
+
if (KE.browser.IE) {
|
3974
|
+
isItem = !!g.range.item;
|
3975
|
+
} else {
|
3976
|
+
isItem = (startNode.nodeType == 1 && startNode === endNode && startNode.nodeName.toLowerCase() != 'br');
|
3977
|
+
}
|
3978
|
+
var isEmpty = !isItem;
|
3979
|
+
if (!isItem) isEmpty = KE.browser.IE ? g.range.text === '' : g.range.toString() === '';
|
3980
|
+
if (isEmpty || KE.util.isEmpty(id)) {
|
3981
|
+
var html = '<a href="' + url + '"';
|
3982
|
+
if (target) html += ' target="' + target + '"';
|
3983
|
+
html += '>' + url + '</a>';
|
3984
|
+
KE.util.insertHtml(id, html);
|
3985
|
+
} else {
|
3986
|
+
iframeDoc.execCommand('createlink', false, '__ke_temp_url__');
|
3987
|
+
var arr = node.getElementsByTagName('a');
|
3988
|
+
for (var i = 0, l = arr.length; i < l; i++) {
|
3989
|
+
if (arr[i].href.match(/\/?__ke_temp_url__$/)) {
|
3990
|
+
arr[i].href = url;
|
3991
|
+
arr[i].setAttribute('kesrc', url);
|
3992
|
+
if (target) arr[i].target = target;
|
3993
|
+
else arr[i].removeAttribute('target');
|
3994
|
+
}
|
3995
|
+
}
|
3996
|
+
if (KE.browser.WEBKIT && isItem && startNode.tagName.toLowerCase() == 'img') {
|
3997
|
+
var parent = startNode.parentNode;
|
3998
|
+
if (parent.tagName.toLowerCase() != 'a') {
|
3999
|
+
var a = KE.$$('a', iframeDoc);
|
4000
|
+
parent.insertBefore(a, startNode);
|
4001
|
+
a.appendChild(startNode);
|
4002
|
+
parent = a;
|
4003
|
+
}
|
4004
|
+
parent.href = url;
|
4005
|
+
parent.setAttribute('kesrc', url);
|
4006
|
+
if (target) parent.target = target;
|
4007
|
+
else parent.removeAttribute('target');
|
4008
|
+
g.keSel.addRange(range);
|
4009
|
+
}
|
4010
|
+
}
|
4011
|
+
KE.util.execOnchangeHandler(id);
|
4012
|
+
this.dialog.hide();
|
4013
|
+
KE.util.focus(id);
|
4014
|
+
}
|
4015
|
+
};
|
4016
|
+
|
4017
|
+
KE.plugin['unlink'] = {
|
4018
|
+
init : function(id) {
|
4019
|
+
var self = this;
|
4020
|
+
KE.g[id].contextmenuItems.push({
|
4021
|
+
text : KE.lang['deleteLink'],
|
4022
|
+
click : function(id, menu) {
|
4023
|
+
KE.util.select(id);
|
4024
|
+
menu.hide();
|
4025
|
+
self.click(id);
|
4026
|
+
},
|
4027
|
+
cond : function(id) {
|
4028
|
+
return KE.plugin['link'].getSelectedNode(id);
|
4029
|
+
},
|
4030
|
+
options : {
|
4031
|
+
width : '150px',
|
4032
|
+
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-unlink"></span>'
|
4033
|
+
}
|
4034
|
+
});
|
4035
|
+
KE.g[id].contextmenuItems.push('-');
|
4036
|
+
},
|
4037
|
+
click : function(id) {
|
4038
|
+
var g = KE.g[id];
|
4039
|
+
var iframeDoc = g.iframeDoc;
|
4040
|
+
KE.util.selection(id);
|
4041
|
+
var range = g.keRange;
|
4042
|
+
var startNode = range.startNode;
|
4043
|
+
var endNode = range.endNode;
|
4044
|
+
var isItem = (startNode.nodeType == 1 && startNode === endNode);
|
4045
|
+
var isEmpty = !isItem;
|
4046
|
+
if (!isItem) isEmpty = KE.browser.IE ? g.range.text === '' : g.range.toString() === '';
|
4047
|
+
if (isEmpty) {
|
4048
|
+
var linkNode = KE.plugin['link'].getSelectedNode(id);
|
4049
|
+
if (!linkNode) return;
|
4050
|
+
var range = g.keRange;
|
4051
|
+
range.selectTextNode(linkNode);
|
4052
|
+
g.keSel.addRange(range);
|
4053
|
+
KE.util.select(id);
|
4054
|
+
iframeDoc.execCommand('unlink', false, null);
|
4055
|
+
if (KE.browser.WEBKIT && startNode.tagName.toLowerCase() == 'img') {
|
4056
|
+
var parent = startNode.parentNode;
|
4057
|
+
if (parent.tagName.toLowerCase() == 'a') {
|
4058
|
+
KE.util.removeParent(parent);
|
4059
|
+
g.keSel.addRange(range);
|
4060
|
+
}
|
4061
|
+
}
|
4062
|
+
} else {
|
4063
|
+
iframeDoc.execCommand('unlink', false, null);
|
4064
|
+
}
|
4065
|
+
KE.util.execOnchangeHandler(id);
|
4066
|
+
KE.toolbar.updateState(id);
|
4067
|
+
KE.util.focus(id);
|
4068
|
+
}
|
4069
|
+
};
|
4070
|
+
|
4071
|
+
KE.plugin['media'] = {
|
4072
|
+
init : function(id) {
|
4073
|
+
var self = this;
|
4074
|
+
var typeHash = {};
|
4075
|
+
KE.each(KE.g[id].mediaTypes, function(key, val) {
|
4076
|
+
typeHash[val] = key;
|
4077
|
+
});
|
4078
|
+
KE.g[id].getHtmlHooks.push(function(html) {
|
4079
|
+
return html.replace(/<img[^>]*class="?ke-\w+"?[^>]*>/ig, function($0) {
|
4080
|
+
var width = $0.match(/style="[^"]*;?\s*width:\s*(\d+)/i) ? RegExp.$1 : 0;
|
4081
|
+
var height = $0.match(/style="[^"]*;?\s*height:\s*(\d+)/i) ? RegExp.$1 : 0;
|
4082
|
+
width = width || ($0.match(/width="([^"]+)"/i) ? RegExp.$1 : 0);
|
4083
|
+
height = height || ($0.match(/height="([^"]+)"/i) ? RegExp.$1 : 0);
|
4084
|
+
if ($0.match(/\s+kesrctag="([^"]+)"/i)) {
|
4085
|
+
var attrs = KE.util.getAttrList(unescape(RegExp.$1));
|
4086
|
+
attrs.width = width || attrs.width || 0;
|
4087
|
+
attrs.height = height || attrs.height || 0;
|
4088
|
+
attrs.kesrc = attrs.src;
|
4089
|
+
return KE.util.getMediaEmbed(attrs);
|
4090
|
+
}
|
4091
|
+
});
|
4092
|
+
});
|
4093
|
+
KE.g[id].setHtmlHooks.push(function(html) {
|
4094
|
+
return html.replace(/<embed[^>]*type="([^"]+)"[^>]*>(?:<\/embed>)?/ig, function($0, $1) {
|
4095
|
+
if (typeof typeHash[$1] == 'undefined') return $0;
|
4096
|
+
var src = $0.match(/\s+src="([^"]+)"/i) ? RegExp.$1 : '';
|
4097
|
+
if ($0.match(/\s+kesrc="([^"]+)"/i)) src = RegExp.$1;
|
4098
|
+
var width = $0.match(/\s+width="([^"]+)"/i) ? RegExp.$1 : 0;
|
4099
|
+
var height = $0.match(/\s+height="([^"]+)"/i) ? RegExp.$1 : 0;
|
4100
|
+
var attrs = KE.util.getAttrList($0);
|
4101
|
+
attrs.src = src;
|
4102
|
+
attrs.width = width;
|
4103
|
+
attrs.height = height;
|
4104
|
+
return KE.util.getMediaImage(id, '', attrs);
|
4105
|
+
});
|
4106
|
+
});
|
4107
|
+
},
|
4108
|
+
click : function(id) {
|
4109
|
+
KE.util.selection(id);
|
4110
|
+
this.dialog = new KE.dialog({
|
4111
|
+
id : id,
|
4112
|
+
cmd : 'media',
|
4113
|
+
file : 'media.html',
|
4114
|
+
width : 400,
|
4115
|
+
height : 170,
|
4116
|
+
loadingMode : true,
|
4117
|
+
title : KE.lang['media'],
|
4118
|
+
yesButton : KE.lang['yes'],
|
4119
|
+
noButton : KE.lang['no']
|
4120
|
+
});
|
4121
|
+
this.dialog.show();
|
4122
|
+
},
|
4123
|
+
check : function(id, url, width, height) {
|
4124
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4125
|
+
if (!url.match(/^.{3,}\.(swf|flv|mp3|wav|wma|wmv|mid|avi|mpg|mpeg|asf|rm|rmvb)(\?|$)/i)) {
|
4126
|
+
alert(KE.lang['invalidMedia']);
|
4127
|
+
KE.$('url', dialogDoc).focus();
|
4128
|
+
return false;
|
4129
|
+
}
|
4130
|
+
if (!width.match(/^\d*$/)) {
|
4131
|
+
alert(KE.lang['invalidWidth']);
|
4132
|
+
KE.$('width', dialogDoc).focus();
|
4133
|
+
return false;
|
4134
|
+
}
|
4135
|
+
if (!height.match(/^\d*$/)) {
|
4136
|
+
alert(KE.lang['invalidHeight']);
|
4137
|
+
KE.$('height', dialogDoc).focus();
|
4138
|
+
return false;
|
4139
|
+
}
|
4140
|
+
return true;
|
4141
|
+
},
|
4142
|
+
exec : function(id) {
|
4143
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4144
|
+
var url = KE.$('url', dialogDoc).value;
|
4145
|
+
var width = KE.$('width', dialogDoc).value;
|
4146
|
+
var height = KE.$('height', dialogDoc).value;
|
4147
|
+
if (!this.check(id, url, width, height)) return false;
|
4148
|
+
var autostart = KE.$('autostart', dialogDoc).checked ? 'true' : 'false';
|
4149
|
+
var html = KE.util.getMediaImage(id, '', {
|
4150
|
+
src : url,
|
4151
|
+
type : KE.g[id].mediaTypes[KE.util.getMediaType(url)],
|
4152
|
+
width : width,
|
4153
|
+
height : height,
|
4154
|
+
autostart : autostart,
|
4155
|
+
loop : 'true'
|
4156
|
+
});
|
4157
|
+
KE.util.insertHtml(id, html);
|
4158
|
+
this.dialog.hide();
|
4159
|
+
KE.util.focus(id);
|
4160
|
+
}
|
4161
|
+
};
|
4162
|
+
|
4163
|
+
KE.plugin['advtable'] = {
|
4164
|
+
getSelectedTable : function(id) {
|
4165
|
+
return KE.getCommonAncestor(KE.g[id].keSel, 'table');
|
4166
|
+
},
|
4167
|
+
getSelectedRow : function(id) {
|
4168
|
+
return KE.getCommonAncestor(KE.g[id].keSel, 'tr');
|
4169
|
+
},
|
4170
|
+
getSelectedCell : function(id) {
|
4171
|
+
return KE.getCommonAncestor(KE.g[id].keSel, 'td');
|
4172
|
+
},
|
4173
|
+
tableprop : function(id) {
|
4174
|
+
this.click(id);
|
4175
|
+
},
|
4176
|
+
tableinsert : function(id) {
|
4177
|
+
this.click(id, 'insert');
|
4178
|
+
},
|
4179
|
+
tabledelete : function(id) {
|
4180
|
+
var table = this.getSelectedTable(id);
|
4181
|
+
table.parentNode.removeChild(table);
|
4182
|
+
},
|
4183
|
+
tablecolinsert : function(id, offset) {
|
4184
|
+
var table = this.getSelectedTable(id),
|
4185
|
+
cell = this.getSelectedCell(id),
|
4186
|
+
index = cell.cellIndex + offset;
|
4187
|
+
for (var i = 0, len = table.rows.length; i < len; i++) {
|
4188
|
+
var newCell = table.rows[i].insertCell(index);
|
4189
|
+
newCell.innerHTML = ' ';
|
4190
|
+
}
|
4191
|
+
},
|
4192
|
+
tablecolinsertleft : function(id) {
|
4193
|
+
this.tablecolinsert(id, 0);
|
4194
|
+
},
|
4195
|
+
tablecolinsertright : function(id) {
|
4196
|
+
this.tablecolinsert(id, 1);
|
4197
|
+
},
|
4198
|
+
tablerowinsert : function(id, offset) {
|
4199
|
+
var table = this.getSelectedTable(id),
|
4200
|
+
row = this.getSelectedRow(id),
|
4201
|
+
newRow = table.insertRow(row.rowIndex + offset);
|
4202
|
+
for (var i = 0, len = row.cells.length; i < len; i++) {
|
4203
|
+
var cell = newRow.insertCell(i);
|
4204
|
+
cell.innerHTML = ' ';
|
4205
|
+
}
|
4206
|
+
},
|
4207
|
+
tablerowinsertabove : function(id) {
|
4208
|
+
this.tablerowinsert(id, 0);
|
4209
|
+
},
|
4210
|
+
tablerowinsertbelow : function(id) {
|
4211
|
+
this.tablerowinsert(id, 1);
|
4212
|
+
},
|
4213
|
+
tablecoldelete : function(id) {
|
4214
|
+
var table = this.getSelectedTable(id);
|
4215
|
+
var cell = this.getSelectedCell(id);
|
4216
|
+
for (var i = 0, len = table.rows.length; i < len; i++) {
|
4217
|
+
table.rows[i].deleteCell(cell.cellIndex);
|
4218
|
+
}
|
4219
|
+
},
|
4220
|
+
tablerowdelete : function(id) {
|
4221
|
+
var table = this.getSelectedTable(id);
|
4222
|
+
var row = this.getSelectedRow(id);
|
4223
|
+
table.deleteRow(row.rowIndex);
|
4224
|
+
},
|
4225
|
+
init : function(id) {
|
4226
|
+
var self = this;
|
4227
|
+
var zeroborder = 'ke-zeroborder';
|
4228
|
+
var tableCmds = 'prop,colinsertleft,colinsertright,rowinsertabove,rowinsertbelow,coldelete,rowdelete,insert,delete'.split(',');
|
4229
|
+
for (var i = 0, len = tableCmds.length; i < len; i++) {
|
4230
|
+
var name = 'table' + tableCmds[i];
|
4231
|
+
KE.g[id].contextmenuItems.push({
|
4232
|
+
text : KE.lang[name],
|
4233
|
+
click : (function(name) {
|
4234
|
+
return function(id, menu) {
|
4235
|
+
KE.util.select(id);
|
4236
|
+
menu.hide();
|
4237
|
+
if (self[name] !== undefined) self[name](id);
|
4238
|
+
if (!/prop/.test(name)) {
|
4239
|
+
KE.util.execOnchangeHandler(id);
|
4240
|
+
}
|
4241
|
+
};
|
4242
|
+
})(name),
|
4243
|
+
cond : (function(name) {
|
4244
|
+
if (KE.util.inArray(name, ['tableprop', 'tabledelete'])) {
|
4245
|
+
return function(id) {
|
4246
|
+
return self.getSelectedTable(id);
|
4247
|
+
};
|
4248
|
+
} else {
|
4249
|
+
return function(id) {
|
4250
|
+
return self.getSelectedCell(id);
|
4251
|
+
};
|
4252
|
+
}
|
4253
|
+
})(name),
|
4254
|
+
options : {
|
4255
|
+
width : '170px',
|
4256
|
+
iconHtml : '<span class="ke-common-icon ke-common-icon-url ke-icon-' + name + '"></span>'
|
4257
|
+
}
|
4258
|
+
});
|
4259
|
+
}
|
4260
|
+
KE.g[id].contextmenuItems.push('-');
|
4261
|
+
KE.g[id].setHtmlHooks.push(function(html) {
|
4262
|
+
return html.replace(/<table([^>]*)>/ig, function($0, $1) {
|
4263
|
+
if ($1.match(/\s+border=["']?(\d*)["']?/ig)) {
|
4264
|
+
var border = RegExp.$1;
|
4265
|
+
if ($1.indexOf(zeroborder) < 0 && (border === '' || border === '0')) {
|
4266
|
+
return KE.addClass($0, zeroborder);
|
4267
|
+
} else {
|
4268
|
+
return $0;
|
4269
|
+
}
|
4270
|
+
} else {
|
4271
|
+
return KE.addClass($0, zeroborder);
|
4272
|
+
}
|
4273
|
+
});
|
4274
|
+
});
|
4275
|
+
},
|
4276
|
+
click : function(id, mode) {
|
4277
|
+
mode = mode || 'default';
|
4278
|
+
var cmd = 'advtable';
|
4279
|
+
KE.util.selection(id);
|
4280
|
+
this.dialog = new KE.dialog({
|
4281
|
+
id : id,
|
4282
|
+
cmd : cmd,
|
4283
|
+
file : 'advtable/advtable.html?mode=' + mode,
|
4284
|
+
width : 420,
|
4285
|
+
height : 220,
|
4286
|
+
loadingMode : true,
|
4287
|
+
title : KE.lang['advtable'],
|
4288
|
+
yesButton : KE.lang['yes'],
|
4289
|
+
noButton : KE.lang['no']
|
4290
|
+
});
|
4291
|
+
this.dialog.show();
|
4292
|
+
},
|
4293
|
+
exec : function(id) {
|
4294
|
+
var zeroborder = 'ke-zeroborder';
|
4295
|
+
var dialogDoc = KE.util.getIframeDoc(this.dialog.iframe);
|
4296
|
+
var modeBox = KE.$('mode', dialogDoc);
|
4297
|
+
var rowsBox = KE.$('rows', dialogDoc);
|
4298
|
+
var colsBox = KE.$('cols', dialogDoc);
|
4299
|
+
var widthBox = KE.$('width', dialogDoc);
|
4300
|
+
var heightBox = KE.$('height', dialogDoc);
|
4301
|
+
var widthTypeBox = KE.$('widthType', dialogDoc);
|
4302
|
+
var heightTypeBox = KE.$('heightType', dialogDoc);
|
4303
|
+
var paddingBox = KE.$('padding', dialogDoc);
|
4304
|
+
var spacingBox = KE.$('spacing', dialogDoc);
|
4305
|
+
var alignBox = KE.$('align', dialogDoc);
|
4306
|
+
var borderBox = KE.$('border', dialogDoc);
|
4307
|
+
var borderColorBox = KE.$('borderColor', dialogDoc);
|
4308
|
+
var backgroundColorBox = KE.$('backgroundColor', dialogDoc);
|
4309
|
+
var rows = rowsBox.value;
|
4310
|
+
var cols = colsBox.value;
|
4311
|
+
var width = widthBox.value;
|
4312
|
+
var height = heightBox.value;
|
4313
|
+
var widthType = widthTypeBox.value;
|
4314
|
+
var heightType = heightTypeBox.value;
|
4315
|
+
var padding = paddingBox.value;
|
4316
|
+
var spacing = spacingBox.value;
|
4317
|
+
var align = alignBox.value;
|
4318
|
+
var border = borderBox.value;
|
4319
|
+
var borderColor = borderColorBox.innerHTML;
|
4320
|
+
var backgroundColor = backgroundColorBox.innerHTML;
|
4321
|
+
if (rows == '' || rows == 0 || !rows.match(/^\d*$/)) {
|
4322
|
+
alert(KE.lang['invalidRows']);
|
4323
|
+
rowsBox.focus();
|
4324
|
+
return false;
|
4325
|
+
}
|
4326
|
+
if (cols == '' || cols == 0 || !cols.match(/^\d*$/)) {
|
4327
|
+
alert(KE.lang['invalidCols']);
|
4328
|
+
colsBox.focus();
|
4329
|
+
return false;
|
4330
|
+
}
|
4331
|
+
if (!width.match(/^\d*$/)) {
|
4332
|
+
alert(KE.lang['invalidWidth']);
|
4333
|
+
widthBox.focus();
|
4334
|
+
return false;
|
4335
|
+
}
|
4336
|
+
if (!height.match(/^\d*$/)) {
|
4337
|
+
alert(KE.lang['invalidHeight']);
|
4338
|
+
heightBox.focus();
|
4339
|
+
return false;
|
4340
|
+
}
|
4341
|
+
if (!padding.match(/^\d*$/)) {
|
4342
|
+
alert(KE.lang['invalidPadding']);
|
4343
|
+
paddingBox.focus();
|
4344
|
+
return false;
|
4345
|
+
}
|
4346
|
+
if (!spacing.match(/^\d*$/)) {
|
4347
|
+
alert(KE.lang['invalidSpacing']);
|
4348
|
+
spacingBox.focus();
|
4349
|
+
return false;
|
4350
|
+
}
|
4351
|
+
if (!border.match(/^\d*$/)) {
|
4352
|
+
alert(KE.lang['invalidBorder']);
|
4353
|
+
borderBox.focus();
|
4354
|
+
return false;
|
4355
|
+
}
|
4356
|
+
if (modeBox.value === 'update') {
|
4357
|
+
var table = this.getSelectedTable(id);
|
4358
|
+
if (width !== '') {
|
4359
|
+
table.style.width = width + widthType;
|
4360
|
+
} else if (table.style.width) {
|
4361
|
+
table.style.width = '';
|
4362
|
+
}
|
4363
|
+
if (table.width !== undefined) {
|
4364
|
+
table.removeAttribute('width');
|
4365
|
+
}
|
4366
|
+
if (height !== '') {
|
4367
|
+
table.style.height = height + heightType;
|
4368
|
+
} else if (table.style.height) {
|
4369
|
+
table.style.height = '';
|
4370
|
+
}
|
4371
|
+
if (table.height !== undefined) {
|
4372
|
+
table.removeAttribute('height');
|
4373
|
+
}
|
4374
|
+
if (backgroundColor !== '') {
|
4375
|
+
table.style.backgroundColor = backgroundColor;
|
4376
|
+
} else if (table.style.backgroundColor) {
|
4377
|
+
table.style.backgroundColor = '';
|
4378
|
+
}
|
4379
|
+
if (table.bgColor !== undefined) {
|
4380
|
+
table.removeAttribute('bgColor');
|
4381
|
+
}
|
4382
|
+
if (padding !== '') {
|
4383
|
+
table.cellPadding = padding;
|
4384
|
+
} else {
|
4385
|
+
table.removeAttribute('cellPadding');
|
4386
|
+
}
|
4387
|
+
if (spacing !== '') {
|
4388
|
+
table.cellSpacing = spacing;
|
4389
|
+
} else {
|
4390
|
+
table.removeAttribute('cellSpacing');
|
4391
|
+
}
|
4392
|
+
if (align !== '') {
|
4393
|
+
table.align = align;
|
4394
|
+
} else {
|
4395
|
+
table.removeAttribute('align');
|
4396
|
+
}
|
4397
|
+
if (border === '' || border === '0') {
|
4398
|
+
KE.addClass(table, zeroborder);
|
4399
|
+
} else {
|
4400
|
+
KE.removeClass(table, zeroborder);
|
4401
|
+
}
|
4402
|
+
if (border !== '') {
|
4403
|
+
table.setAttribute('border', border);
|
4404
|
+
} else {
|
4405
|
+
table.removeAttribute('border');
|
4406
|
+
}
|
4407
|
+
if (borderColor !== '') {
|
4408
|
+
table.setAttribute('borderColor', borderColor);
|
4409
|
+
} else {
|
4410
|
+
table.removeAttribute('borderColor');
|
4411
|
+
}
|
4412
|
+
KE.util.execOnchangeHandler(id);
|
4413
|
+
} else {
|
4414
|
+
var style = '';
|
4415
|
+
if (width !== '') style += 'width:' + width + widthType + ';';
|
4416
|
+
if (height !== '') style += 'height:' + height + heightType + ';';
|
4417
|
+
if (backgroundColor !== '') style += 'background-color:' + backgroundColor + ';';
|
4418
|
+
var html = '<table';
|
4419
|
+
if (style !== '') html += ' style="' + style + '"';
|
4420
|
+
if (padding !== '') html += ' cellpadding="' + padding + '"';
|
4421
|
+
if (spacing !== '') html += ' cellspacing="' + spacing + '"';
|
4422
|
+
if (align !== '') html += ' align="' + align + '"';
|
4423
|
+
if (border === '' || border === '0') html += ' class="' + zeroborder + '"';
|
4424
|
+
if (border !== '') html += ' border="' + border + '"';
|
4425
|
+
if (borderColor !== '') html += ' bordercolor="' + borderColor + '"';
|
4426
|
+
html += '>';
|
4427
|
+
for (var i = 0; i < rows; i++) {
|
4428
|
+
html += '<tr>';
|
4429
|
+
for (var j = 0; j < cols; j++) {
|
4430
|
+
html += '<td> </td>';
|
4431
|
+
}
|
4432
|
+
html += '</tr>';
|
4433
|
+
}
|
4434
|
+
html += '</table>';
|
4435
|
+
KE.util.insertHtml(id, html);
|
4436
|
+
}
|
4437
|
+
this.dialog.hide();
|
4438
|
+
KE.util.focus(id);
|
4439
|
+
}
|
4440
|
+
};
|
4441
|
+
|
4442
|
+
})(KindEditor);
|