rails_kindeditor 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -0
  3. data/lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb +10 -0
  4. data/lib/rails_kindeditor.rb +9 -3
  5. data/lib/rails_kindeditor/helper.rb +3 -1
  6. data/lib/rails_kindeditor/version.rb +1 -1
  7. data/vendor/assets/javascripts/kindeditor/kindeditor.js +3950 -11
  8. data/vendor/assets/javascripts/kindeditor/lang/ar.js +9 -0
  9. data/vendor/assets/javascripts/kindeditor/lang/en.js +9 -0
  10. data/vendor/assets/javascripts/kindeditor/lang/ko.js +246 -237
  11. data/vendor/assets/javascripts/kindeditor/lang/ru.js +242 -0
  12. data/vendor/assets/javascripts/kindeditor/lang/{zh_CN.js → zh-CN.js} +3 -1
  13. data/vendor/assets/javascripts/kindeditor/lang/{zh_TW.js → zh-TW.js} +243 -235
  14. data/vendor/assets/javascripts/kindeditor/plugins/anchor/anchor.js +46 -46
  15. data/vendor/assets/javascripts/kindeditor/plugins/autoheight/autoheight.js +54 -54
  16. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/baidumap.js +93 -93
  17. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/index.html +82 -82
  18. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/map.html +43 -43
  19. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.css +13 -13
  20. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.js +28 -28
  21. data/vendor/assets/javascripts/kindeditor/plugins/fixtoolbar/fixtoolbar.js +35 -0
  22. data/vendor/assets/javascripts/kindeditor/plugins/map/map.html +1 -1
  23. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/{select-files-zh_CN.png → select-files-zh-CN.png} +0 -0
  24. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/multiimage.js +1384 -1384
  25. data/vendor/assets/javascripts/kindeditor/plugins/template/html/1.html +13 -13
  26. data/vendor/assets/javascripts/kindeditor/plugins/template/html/2.html +41 -41
  27. data/vendor/assets/javascripts/kindeditor/plugins/template/html/3.html +35 -35
  28. data/vendor/assets/javascripts/kindeditor/themes/default/background.png +0 -0
  29. data/vendor/assets/javascripts/kindeditor/themes/default/default.css +1147 -1149
  30. data/vendor/assets/javascripts/kindeditor/themes/qq/qq.css +143 -143
  31. data/vendor/assets/javascripts/kindeditor/themes/simple/simple.css +100 -100
  32. metadata +15 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adc58562fa6e23f4a3950d6265c474596ffeb061
4
- data.tar.gz: fc1df1f4d38711ed2c3a756a41886866daac53a3
3
+ metadata.gz: 34a1caa64fbe3191d4baf1d8e46e0c534ae01515
4
+ data.tar.gz: 161088b41104740736b8de6c40e020651e046b34
5
5
  SHA512:
6
- metadata.gz: ca79e861074bc168e3c00e38dd84792e695f296c1414a13d1833fc29f849abe4868fddf359fec9aa08473f99f0092f4b65c23aef055355eb4633e01a425b1f02
7
- data.tar.gz: e6719f9e2dfc9ea3ac456e91891a5062bd879e1ff16e14701a5e0428cb7f73ab3b36949ebdb331ec23029a5685b2e5617f5fe2847d87dfbb7e334f8a6558ee95
6
+ metadata.gz: 622feef63934646240973a3c750bb0591ab63763c5ddab7de72fb5c9c8a813c0877725d9904faefc94134c84d73a720f3c88e94ebf606f47f3fb7497c05028fe
7
+ data.tar.gz: e39d0698e0c0191d5ee179458db002be90a0e3c24d4f17cb01237908fed1922dfb12943061adb4bd8b22783a2c5f3ab483d66cd359e6fc3c927f2249943cb1cf
data/README.md CHANGED
@@ -184,6 +184,19 @@ You can customize some option for uploading.
184
184
  # config.image_resize_to_limit = [800, 800]
185
185
  ```
186
186
 
187
+ ## Asset host options configuration
188
+
189
+ ```ruby
190
+ # if you have config in your rails application like this:
191
+ # /config/enviroments/production.rb
192
+ # # config.action_controller.asset_host = "http://asset.example.com"
193
+ # # config.assets.prefix = "assets_prefx"
194
+ # then you should:
195
+ #
196
+ config.asset_url_prefix = "http://asset.example.com/assets_prefx/" if Rails.env.production?
197
+ ```
198
+
199
+
187
200
  ## Save upload file information into database(optional)
188
201
 
189
202
  rails_kindeditor can save upload file information into database.
@@ -431,6 +444,19 @@ f.kindeditor :content, owner_id: @article.id, data: {upload: kindeditor_upload_j
431
444
  # config.image_resize_to_limit = [800, 800]
432
445
  ```
433
446
 
447
+ ## 静态资源地址配置
448
+
449
+ ```ruby
450
+ # if you have config in your rails application like this:
451
+ # /config/enviroments/production.rb
452
+ # # config.action_controller.asset_host = "http://asset.example.com"
453
+ # # config.assets.prefix = "assets_prefx"
454
+ # then you should:
455
+ #
456
+ config.asset_url_prefix = "http://asset.example.com/assets_prefx/" if Rails.env.production?
457
+ ```
458
+
459
+
434
460
  ## 将上传文件信息记录入数据库(可选)
435
461
 
436
462
  rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应用.
@@ -16,4 +16,14 @@ RailsKindeditor.setup do |config|
16
16
  # 400x400 => 400x400 # No Change
17
17
  # config.image_resize_to_limit = [800, 800]
18
18
 
19
+ # if you have config in your rails application like this:
20
+ # /config/enviroments/production.rb
21
+ # # config.action_controller.asset_host = "http://asset.example.com"
22
+ # # config.assets.prefix = "assets_prefx"
23
+ # then you should:
24
+ #
25
+ # config.asset_url_prefix = "http://asset.example.com/assets_prefx/" if Rails.env.production?
26
+
27
+
28
+
19
29
  end
@@ -22,14 +22,20 @@ module RailsKindeditor
22
22
  @@upload_file_ext = %w[doc docx xls xlsx ppt htm html txt zip rar gz bz2]
23
23
 
24
24
  mattr_accessor :image_resize_to_limit
25
-
25
+
26
+ mattr_accessor :asset_url_prefix
27
+
28
+ def self.base_path
29
+ self.asset_url_prefix ? "#{self.asset_url_prefix}/kindeditor/" : '/assets/kindeditor/'
30
+ end
31
+
26
32
  def self.root_path
27
33
  @root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
28
34
  end
29
-
35
+
30
36
  def self.assets
31
37
  Dir[root_path.join('vendor/assets/javascripts/kindeditor/**', '*.{js,css}')].inject([]) do |assets, path|
32
- assets << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts'))
38
+ assets << Pathname.new(path).relative_path_from(root_path.join('vendor/assets/javascripts')).to_s
33
39
  end
34
40
  end
35
41
 
@@ -44,11 +44,13 @@ module RailsKindeditor
44
44
  "var old_onload_#{random_name};
45
45
  if(typeof window.onload == 'function') old_onload_#{random_name} = window.onload;
46
46
  window.onload = function() {
47
+ KindEditor.basePath='#{RailsKindeditor.base_path}';
47
48
  #{editor_id}KindEditor.create('##{dom_id}', #{get_options(options).to_json});
48
49
  if(old_onload_#{random_name}) old_onload_#{random_name}();
49
50
  }"
50
51
  else
51
- "KindEditor.ready(function(K){
52
+ "KindEditor.basePath='#{RailsKindeditor.base_path}';
53
+ KindEditor.ready(function(K){
52
54
  #{editor_id}K.create('##{dom_id}', #{get_options(options).to_json});
53
55
  });"
54
56
  end
@@ -1,4 +1,4 @@
1
1
  module RailsKindeditor
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
4
4
 
@@ -1,23 +1,25 @@
1
1
  /*******************************************************************************
2
2
  * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2013 kindsoft.net
3
+ * Copyright (C) 2006-2016 kindsoft.net
4
4
  *
5
5
  * @author Roddy <luolonghao@gmail.com>
6
6
  * @website http://www.kindsoft.net/
7
7
  * @licence http://www.kindsoft.net/license.php
8
- * @version 4.1.10 (2013-11-23)
8
+ * @version 4.1.11 (2016-03-31)
9
9
  *******************************************************************************/
10
10
  (function (window, undefined) {
11
11
  if (window.KindEditor) {
12
12
  return;
13
13
  }
14
+
15
+
14
16
  if (!window.console) {
15
17
  window.console = {};
16
18
  }
17
19
  if (!console.log) {
18
20
  console.log = function () {};
19
21
  }
20
- var _VERSION = '4.1.10 (2013-11-23)',
22
+ var _VERSION = '4.1.11 (2016-03-31)',
21
23
  _ua = navigator.userAgent.toLowerCase(),
22
24
  _IE = _ua.indexOf('msie') > -1 && _ua.indexOf('opera') == -1,
23
25
  _NEWIE = _ua.indexOf('msie') == -1 && _ua.indexOf('trident') > -1,
@@ -77,7 +79,7 @@ function _inString(val, str, delimiter) {
77
79
  }
78
80
  function _addUnit(val, unit) {
79
81
  unit = unit || 'px';
80
- return val && /^\d+$/.test(val) ? val + unit : val;
82
+ return val && /^-?\d+(?:\.\d+)?$/.test(val) ? val + unit : val;
81
83
  }
82
84
  function _removeUnit(val) {
83
85
  var match;
@@ -154,6 +156,8 @@ function _extend(child, parent, proto) {
154
156
  child.prototype = childProto;
155
157
  child.parent = parent ? parent.prototype : null;
156
158
  }
159
+
160
+
157
161
  function _json(text) {
158
162
  var match;
159
163
  if ((match = /\{[\s\S]*\}|\[[\s\S]*\]/.exec(text))) {
@@ -214,6 +218,7 @@ var _INLINE_TAG_MAP = _toMap('a,abbr,acronym,b,basefont,bdo,big,br,button,cite,c
214
218
  _AUTOCLOSE_TAG_MAP = _toMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'),
215
219
  _FILL_ATTR_MAP = _toMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'),
216
220
  _VALUE_TAG_MAP = _toMap('input,button,textarea,select');
221
+
217
222
  // Begining of modification by Macrow
218
223
  function _getBasePath() {
219
224
  var refPath = '/assets/kindeditor/';
@@ -240,7 +245,7 @@ K.options = {
240
245
  langPath : K.basePath + 'lang/',
241
246
  pluginsPath : K.basePath + 'plugins/',
242
247
  themeType : 'default',
243
- langType : 'zh_CN',
248
+ langType : 'zh-CN',
244
249
  urlType : '',
245
250
  newlineTag : 'p',
246
251
  resizeType : 2,
@@ -298,7 +303,7 @@ K.options = {
298
303
  '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
299
304
  ],
300
305
  a : ['id', 'class', 'href', 'target', 'name'],
301
- embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
306
+ embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess', 'wmode'],
302
307
  img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
303
308
  'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
304
309
  'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background',
@@ -311,9 +316,15 @@ K.options = {
311
316
  },
312
317
  layout : '<div class="container"><div class="toolbar"></div><div class="edit"></div><div class="statusbar"></div></div>'
313
318
  };
319
+
320
+
314
321
  var _useCapture = false;
322
+
323
+
315
324
  var _INPUT_KEY_MAP = _toMap('8,9,13,32,46,48..57,59,61,65..90,106,109..111,188,190..192,219..222');
325
+
316
326
  var _CURSORMOVE_KEY_MAP = _toMap('33..40');
327
+
317
328
  var _CHANGE_KEY_MAP = {};
318
329
  _each(_INPUT_KEY_MAP, function(key, val) {
319
330
  _CHANGE_KEY_MAP[key] = val;
@@ -321,6 +332,8 @@ _each(_INPUT_KEY_MAP, function(key, val) {
321
332
  _each(_CURSORMOVE_KEY_MAP, function(key, val) {
322
333
  _CHANGE_KEY_MAP[key] = val;
323
334
  });
335
+
336
+
324
337
  function _bindEvent(el, type, fn) {
325
338
  if (el.addEventListener){
326
339
  el.addEventListener(type, fn, _useCapture);
@@ -328,6 +341,7 @@ function _bindEvent(el, type, fn) {
328
341
  el.attachEvent('on' + type, fn);
329
342
  }
330
343
  }
344
+
331
345
  function _unbindEvent(el, type, fn) {
332
346
  if (el.removeEventListener){
333
347
  el.removeEventListener(type, fn, _useCapture);
@@ -338,6 +352,8 @@ function _unbindEvent(el, type, fn) {
338
352
  var _EVENT_PROPS = ('altKey,attrChange,attrName,bubbles,button,cancelable,charCode,clientX,clientY,ctrlKey,currentTarget,' +
339
353
  'data,detail,eventPhase,fromElement,handler,keyCode,metaKey,newValue,offsetX,offsetY,originalTarget,pageX,' +
340
354
  'pageY,prevValue,relatedNode,relatedTarget,screenX,screenY,shiftKey,srcElement,target,toElement,view,wheelDelta,which').split(',');
355
+
356
+
341
357
  function KEvent(el, event) {
342
358
  this.init(el, event);
343
359
  }
@@ -595,7 +611,7 @@ function _ready(fn) {
595
611
  }
596
612
  _bind(window, 'load', readyFunc);
597
613
  }
598
- if (_IE) {
614
+ if (window.attachEvent) {
599
615
  window.attachEvent('onunload', function() {
600
616
  _each(_eventData, function(key, events) {
601
617
  if (events.el) {
@@ -606,6 +622,7 @@ if (_IE) {
606
622
  }
607
623
  K.ctrl = _ctrl;
608
624
  K.ready = _ready;
625
+
609
626
  function _getCssList(css) {
610
627
  var list = {},
611
628
  reg = /\s*([\w\-]+)\s*:([^;]*)(;|$)/g,
@@ -734,6 +751,8 @@ function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
734
751
  html = html.replace(/\u200B/g, '');
735
752
  html = html.replace(/\u00A9/g, '&copy;');
736
753
  html = html.replace(/\u00AE/g, '&reg;');
754
+ html = html.replace(/\u2003/g, '&emsp;');
755
+ html = html.replace(/\u3000/g, '&emsp;');
737
756
  html = html.replace(/<[^>]+/g, function($0) {
738
757
  return $0.replace(/\s+/g, ' ');
739
758
  });
@@ -892,6 +911,7 @@ function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
892
911
  html = html.replace(/<span id="__kindeditor_pre_newline__">\n/g, '\n');
893
912
  return _trim(html);
894
913
  }
914
+
895
915
  function _clearMsWord(html, htmlTags) {
896
916
  html = html.replace(/<meta[\s\S]*?>/ig, '')
897
917
  .replace(/<![\s\S]*?>/ig, '')
@@ -905,6 +925,7 @@ function _clearMsWord(html, htmlTags) {
905
925
  });
906
926
  return _formatHtml(html, htmlTags);
907
927
  }
928
+
908
929
  function _mediaType(src) {
909
930
  if (/\.(rm|rmvb)(\?|$)/i.test(src)) {
910
931
  return 'audio/x-pn-realaudio-plugin';
@@ -914,6 +935,7 @@ function _mediaType(src) {
914
935
  }
915
936
  return 'video/x-ms-asf-plugin';
916
937
  }
938
+
917
939
  function _mediaClass(type) {
918
940
  if (/realaudio/i.test(type)) {
919
941
  return 'ke-rm';
@@ -957,6 +979,10 @@ function _mediaImg(blankPath, attrs) {
957
979
  html += 'data-ke-tag="' + escape(srcTag) + '" alt="" />';
958
980
  return html;
959
981
  }
982
+
983
+
984
+
985
+
960
986
  function _tmpl(str, data) {
961
987
  var fn = new Function("obj",
962
988
  "var p=[],print=function(){p.push.apply(p,arguments);};" +
@@ -980,6 +1006,8 @@ K.mediaEmbed = _mediaEmbed;
980
1006
  K.mediaImg = _mediaImg;
981
1007
  K.clearMsWord = _clearMsWord;
982
1008
  K.tmpl = _tmpl;
1009
+
1010
+
983
1011
  function _contains(nodeA, nodeB) {
984
1012
  if (nodeA.nodeType == 9 && nodeB.nodeType != 9) {
985
1013
  return true;
@@ -1198,6 +1226,8 @@ function _query(expr, root) {
1198
1226
  }
1199
1227
  K.query = _query;
1200
1228
  K.queryAll = _queryAll;
1229
+
1230
+
1201
1231
  function _get(val) {
1202
1232
  return K(val)[0];
1203
1233
  }
@@ -1289,6 +1319,8 @@ function _getScrollPos(doc) {
1289
1319
  }
1290
1320
  return {x : x, y : y};
1291
1321
  }
1322
+
1323
+
1292
1324
  function KNode(node) {
1293
1325
  this.init(node);
1294
1326
  }
@@ -1795,6 +1827,8 @@ _each(_K, function(key, val) {
1795
1827
  });
1796
1828
  K.NodeClass = KNode;
1797
1829
  window.KindEditor = K;
1830
+
1831
+
1798
1832
  var _START_TO_START = 0,
1799
1833
  _START_TO_END = 1,
1800
1834
  _END_TO_END = 2,
@@ -1923,6 +1957,7 @@ function _copyAndDelete(range, isCopy, isDelete) {
1923
1957
  }
1924
1958
  return isCopy ? frag : range;
1925
1959
  }
1960
+
1926
1961
  function _moveToElementText(range, el) {
1927
1962
  var node = el;
1928
1963
  while (node) {
@@ -1936,6 +1971,7 @@ function _moveToElementText(range, el) {
1936
1971
  range.moveToElementText(el);
1937
1972
  } catch(e) {}
1938
1973
  }
1974
+
1939
1975
  function _getStartEnd(rng, isStart) {
1940
1976
  var doc = rng.parentElement().ownerDocument,
1941
1977
  pointRange = rng.duplicate();
@@ -2001,6 +2037,7 @@ function _getStartEnd(rng, isStart) {
2001
2037
  }
2002
2038
  return {node: startNode, offset: startPos};
2003
2039
  }
2040
+
2004
2041
  function _getEndRange(node, offset) {
2005
2042
  var doc = node.ownerDocument || node,
2006
2043
  range = doc.body.createTextRange();
@@ -2058,6 +2095,7 @@ function _getEndRange(node, offset) {
2058
2095
  K(dummy).remove();
2059
2096
  return range;
2060
2097
  }
2098
+
2061
2099
  function _toRange(rng) {
2062
2100
  var doc, range;
2063
2101
  function tr2td(start) {
@@ -2090,6 +2128,8 @@ function _toRange(rng) {
2090
2128
  range.setEnd(rng.endContainer, rng.endOffset);
2091
2129
  return range;
2092
2130
  }
2131
+
2132
+
2093
2133
  function KRange(doc) {
2094
2134
  this.init(doc);
2095
2135
  }
@@ -2506,11 +2546,15 @@ K.START_TO_START = _START_TO_START;
2506
2546
  K.START_TO_END = _START_TO_END;
2507
2547
  K.END_TO_END = _END_TO_END;
2508
2548
  K.END_TO_START = _END_TO_START;
2549
+
2550
+
2551
+
2509
2552
  function _nativeCommand(doc, key, val) {
2510
2553
  try {
2511
2554
  doc.execCommand(key, false, val);
2512
2555
  } catch(e) {}
2513
2556
  }
2557
+
2514
2558
  function _nativeCommandValue(doc, key) {
2515
2559
  var val = '';
2516
2560
  try {
@@ -2521,10 +2565,12 @@ function _nativeCommandValue(doc, key) {
2521
2565
  }
2522
2566
  return val;
2523
2567
  }
2568
+
2524
2569
  function _getSel(doc) {
2525
2570
  var win = _getWin(doc);
2526
2571
  return _IERANGE ? doc.selection : win.getSelection();
2527
2572
  }
2573
+
2528
2574
  function _getRng(doc) {
2529
2575
  var sel = _getSel(doc), rng;
2530
2576
  try {
@@ -2539,6 +2585,7 @@ function _getRng(doc) {
2539
2585
  }
2540
2586
  return rng;
2541
2587
  }
2588
+
2542
2589
  function _singleKeyMap(map) {
2543
2590
  var newMap = {}, arr, v;
2544
2591
  _each(map, function(key, val) {
@@ -2550,6 +2597,7 @@ function _singleKeyMap(map) {
2550
2597
  });
2551
2598
  return newMap;
2552
2599
  }
2600
+
2553
2601
  function _hasAttrOrCss(knode, map) {
2554
2602
  return _hasAttrOrCssByKey(knode, map, '*') || _hasAttrOrCssByKey(knode, map);
2555
2603
  }
@@ -2581,6 +2629,7 @@ function _hasAttrOrCssByKey(knode, map, mapKey) {
2581
2629
  }
2582
2630
  return false;
2583
2631
  }
2632
+
2584
2633
  function _removeAttrOrCss(knode, map) {
2585
2634
  if (knode.type != 1) {
2586
2635
  return;
@@ -2619,6 +2668,7 @@ function _removeAttrOrCssByKey(knode, map, mapKey) {
2619
2668
  knode.remove(true);
2620
2669
  }
2621
2670
  }
2671
+
2622
2672
  function _getInnerNode(knode) {
2623
2673
  var inner = knode;
2624
2674
  while (inner.first()) {
@@ -2626,12 +2676,17 @@ function _getInnerNode(knode) {
2626
2676
  }
2627
2677
  return inner;
2628
2678
  }
2679
+
2629
2680
  function _isEmptyNode(knode) {
2630
2681
  if (knode.type != 1 || knode.isSingle()) {
2631
2682
  return false;
2632
2683
  }
2633
2684
  return knode.html().replace(/<[^>]+>/g, '') === '';
2634
2685
  }
2686
+
2687
+
2688
+
2689
+
2635
2690
  function _mergeWrapper(a, b) {
2636
2691
  a = a.clone(true);
2637
2692
  var lastA = _getInnerNode(a), childA = a, merged = false;
@@ -2651,6 +2706,7 @@ function _mergeWrapper(a, b) {
2651
2706
  }
2652
2707
  return a;
2653
2708
  }
2709
+
2654
2710
  function _wrapNode(knode, wrapper) {
2655
2711
  wrapper = wrapper.clone(true);
2656
2712
  if (knode.type == 3) {
@@ -2675,6 +2731,7 @@ function _wrapNode(knode, wrapper) {
2675
2731
  nodeWrapper.replaceWith(wrapper);
2676
2732
  return wrapper;
2677
2733
  }
2734
+
2678
2735
  function _mergeAttrs(knode, attrs, styles) {
2679
2736
  _each(attrs, function(key, val) {
2680
2737
  if (key !== 'style') {
@@ -2685,6 +2742,7 @@ function _mergeAttrs(knode, attrs, styles) {
2685
2742
  knode.css(key, val);
2686
2743
  });
2687
2744
  }
2745
+
2688
2746
  function _inPreElement(knode) {
2689
2747
  while (knode && knode.name != 'body') {
2690
2748
  if (_PRE_TAG_MAP[knode.name] || knode.name == 'div' && knode.hasClass('ke-script')) {
@@ -2694,6 +2752,7 @@ function _inPreElement(knode) {
2694
2752
  }
2695
2753
  return false;
2696
2754
  }
2755
+
2697
2756
  function KCmd(range) {
2698
2757
  this.init(range);
2699
2758
  }
@@ -3308,6 +3367,8 @@ function _cmd(mixed) {
3308
3367
  }
3309
3368
  K.CmdClass = KCmd;
3310
3369
  K.cmd = _cmd;
3370
+
3371
+
3311
3372
  function _drag(options) {
3312
3373
  var moveEl = options.moveEl,
3313
3374
  moveFn = options.moveFn,
@@ -3334,6 +3395,9 @@ function _drag(options) {
3334
3395
  });
3335
3396
  }
3336
3397
  clickEl.mousedown(function(e) {
3398
+ if(e.button !== 0 && e.button !== 1) {
3399
+ return;
3400
+ }
3337
3401
  e.stopPropagation();
3338
3402
  var self = clickEl.get(),
3339
3403
  x = _removeUnit(moveEl.css('left')),
@@ -3372,6 +3436,8 @@ function _drag(options) {
3372
3436
  }
3373
3437
  });
3374
3438
  }
3439
+
3440
+
3375
3441
  function KWidget(options) {
3376
3442
  this.init(options);
3377
3443
  }
@@ -3520,6 +3586,8 @@ function _widget(options) {
3520
3586
  }
3521
3587
  K.WidgetClass = KWidget;
3522
3588
  K.widget = _widget;
3589
+
3590
+
3523
3591
  function _iframeDoc(iframe) {
3524
3592
  iframe = _get(iframe);
3525
3593
  return iframe.contentDocument || iframe.contentWindow.document;
@@ -3609,6 +3677,8 @@ function _elementVal(knode, val) {
3609
3677
  }
3610
3678
  return knode.html(val);
3611
3679
  }
3680
+
3681
+
3612
3682
  function KEdit(options) {
3613
3683
  this.init(options);
3614
3684
  }
@@ -3748,7 +3818,6 @@ _extend(KEdit, KWidget, {
3748
3818
  }
3749
3819
  _elementVal(self.srcElement, self.html());
3750
3820
  self.srcElement.show();
3751
- doc.write('');
3752
3821
  self.iframe.unbind();
3753
3822
  self.textarea.unbind();
3754
3823
  KEdit.parent.remove.call(self);
@@ -3795,9 +3864,15 @@ _extend(KEdit, KWidget, {
3795
3864
  if (!self.designMode) {
3796
3865
  val = self.html();
3797
3866
  self.designMode = true;
3798
- self.html(val);
3799
3867
  self.textarea.hide();
3800
- self.iframe.show();
3868
+ self.html(val);
3869
+ var iframe = self.iframe;
3870
+ var height = _removeUnit(self.height);
3871
+ iframe.height(height - 2);
3872
+ iframe.show();
3873
+ setTimeout(function() {
3874
+ iframe.height(height);
3875
+ }, 0);
3801
3876
  }
3802
3877
  } else {
3803
3878
  if (self.designMode) {
@@ -3852,6 +3927,8 @@ function _edit(options) {
3852
3927
  K.EditClass = KEdit;
3853
3928
  K.edit = _edit;
3854
3929
  K.iframeDoc = _iframeDoc;
3930
+
3931
+
3855
3932
  function _selectToolbar(name, fn) {
3856
3933
  var self = this,
3857
3934
  knode = self.get(name);
@@ -3862,6 +3939,8 @@ function _selectToolbar(name, fn) {
3862
3939
  fn(knode);
3863
3940
  }
3864
3941
  }
3942
+
3943
+
3865
3944
  function KToolbar(options) {
3866
3945
  this.init(options);
3867
3946
  }
@@ -3980,6 +4059,9 @@ function _toolbar(options) {
3980
4059
  }
3981
4060
  K.ToolbarClass = KToolbar;
3982
4061
  K.toolbar = _toolbar;
4062
+
4063
+
4064
+
3983
4065
  function KMenu(options) {
3984
4066
  this.init(options);
3985
4067
  }
@@ -4061,6 +4143,9 @@ function _menu(options) {
4061
4143
  }
4062
4144
  K.MenuClass = KMenu;
4063
4145
  K.menu = _menu;
4146
+
4147
+
4148
+
4064
4149
  function KColorPicker(options) {
4065
4150
  this.init(options);
4066
4151
  }
@@ -4136,6 +4221,8 @@ function _colorpicker(options) {
4136
4221
  }
4137
4222
  K.ColorPickerClass = KColorPicker;
4138
4223
  K.colorpicker = _colorpicker;
4224
+
4225
+
4139
4226
  function KUploadButton(options) {
4140
4227
  this.init(options);
4141
4228
  }
@@ -4227,6 +4314,8 @@ function _uploadbutton(options) {
4227
4314
  }
4228
4315
  K.UploadButtonClass = KUploadButton;
4229
4316
  K.uploadbutton = _uploadbutton;
4317
+
4318
+
4230
4319
  function _createButton(arg) {
4231
4320
  arg = arg || {};
4232
4321
  var name = arg.name || '',
@@ -4238,6 +4327,8 @@ function _createButton(arg) {
4238
4327
  span.append(btn);
4239
4328
  return span;
4240
4329
  }
4330
+
4331
+
4241
4332
  function KDialog(options) {
4242
4333
  this.init(options);
4243
4334
  }
@@ -4362,6 +4453,8 @@ function _dialog(options) {
4362
4453
  }
4363
4454
  K.DialogClass = KDialog;
4364
4455
  K.dialog = _dialog;
4456
+
4457
+
4365
4458
  function _tabs(options) {
4366
4459
  var self = _widget(options),
4367
4460
  remove = self.remove,
@@ -4416,6 +4509,8 @@ function _tabs(options) {
4416
4509
  return self;
4417
4510
  }
4418
4511
  K.tabs = _tabs;
4512
+
4513
+
4419
4514
  function _loadScript(url, fn) {
4420
4515
  var head = document.getElementsByTagName('head')[0] || (_QUIRKS ? document.body : document.documentElement),
4421
4516
  script = document.createElement('script');
@@ -4432,6 +4527,8 @@ function _loadScript(url, fn) {
4432
4527
  }
4433
4528
  };
4434
4529
  }
4530
+
4531
+
4435
4532
  function _chopQuery(url) {
4436
4533
  var index = url.indexOf('?');
4437
4534
  return index > 0 ? url.substr(0, index) : url;
@@ -4482,6 +4579,8 @@ function _ajax(url, fn, method, param, dataType) {
4482
4579
  K.loadScript = _loadScript;
4483
4580
  K.loadStyle = _loadStyle;
4484
4581
  K.ajax = _ajax;
4582
+
4583
+
4485
4584
  var _plugins = {};
4486
4585
  function _plugin(name, fn) {
4487
4586
  if (name === undefined) {
@@ -4525,6 +4624,8 @@ function _lang(mixed, langType) {
4525
4624
  _language[langType][obj.ns][obj.key] = val;
4526
4625
  });
4527
4626
  }
4627
+
4628
+
4528
4629
  function _getImageFromRange(range, fn) {
4529
4630
  if (range.collapsed) {
4530
4631
  return;
@@ -4735,6 +4836,9 @@ function _addBookmarkToStack(stack, bookmark) {
4735
4836
  stack.push(bookmark);
4736
4837
  }
4737
4838
  }
4839
+
4840
+
4841
+
4738
4842
  function _undoToRedo(fromStack, toStack) {
4739
4843
  var self = this, edit = self.edit,
4740
4844
  body = edit.doc.body,
@@ -4816,6 +4920,10 @@ KEditor.prototype = {
4816
4920
  },
4817
4921
  loadPlugin : function(name, fn) {
4818
4922
  var self = this;
4923
+ var _pluginStatus = this._pluginStatus;
4924
+ if (!_pluginStatus) {
4925
+ _pluginStatus = this._pluginStatus = {};
4926
+ }
4819
4927
  if (_plugins[name]) {
4820
4928
  if (!_isFunction(_plugins[name])) {
4821
4929
  setTimeout(function() {
@@ -4823,7 +4931,10 @@ KEditor.prototype = {
4823
4931
  }, 100);
4824
4932
  return self;
4825
4933
  }
4826
- _plugins[name].call(self, KindEditor);
4934
+ if(!_pluginStatus[name]) {
4935
+ _plugins[name].call(self, KindEditor);
4936
+ _pluginStatus[name] = 'inited';
4937
+ }
4827
4938
  if (fn) {
4828
4939
  fn.call(self);
4829
4940
  }
@@ -5421,6 +5532,10 @@ function _create(expr, options) {
5421
5532
  _each(_plugins, function(name, fn) {
5422
5533
  if (_isFunction(fn)) {
5423
5534
  fn.call(editor, KindEditor);
5535
+ if (!editor._pluginStatus) {
5536
+ editor._pluginStatus = {};
5537
+ }
5538
+ editor._pluginStatus[name] = 'inited';
5424
5539
  }
5425
5540
  });
5426
5541
  return editor.create();
@@ -5482,6 +5597,8 @@ K.appendHtml = function(expr, val) {
5482
5597
  this.appendHtml(val);
5483
5598
  });
5484
5599
  };
5600
+
5601
+
5485
5602
  if (_IE && _V < 7) {
5486
5603
  _nativeCommand(document, 'BackgroundImageCache', true);
5487
5604
  }
@@ -5491,6 +5608,8 @@ K.create = _create;
5491
5608
  K.instances = _instances;
5492
5609
  K.plugin = _plugin;
5493
5610
  K.lang = _lang;
5611
+
5612
+
5494
5613
  _plugin('core', function(K) {
5495
5614
  var self = this,
5496
5615
  shortcutKeys = {
@@ -5852,6 +5971,8 @@ _plugin('core', function(K) {
5852
5971
  } else {
5853
5972
  cmd.range.selectNodeContents(div[0]);
5854
5973
  cmd.select();
5974
+ div[0].tabIndex = -1;
5975
+ div[0].focus();
5855
5976
  }
5856
5977
  setTimeout(function() {
5857
5978
  movePastedData();
@@ -5960,4 +6081,3822 @@ _plugin('core', function(K) {
5960
6081
  });
5961
6082
  });
5962
6083
  });
6084
+
6085
+
5963
6086
  })(window);
6087
+
6088
+ /*******************************************************************************
6089
+ * KindEditor - WYSIWYG HTML Editor for Internet
6090
+ * Copyright (C) 2006-2011 kindsoft.net
6091
+ *
6092
+ * @author Roddy <luolonghao@gmail.com>
6093
+ * @site http://www.kindsoft.net/
6094
+ * @licence http://www.kindsoft.net/license.php
6095
+ *******************************************************************************/
6096
+ KindEditor.lang({
6097
+ source : 'HTML代码',
6098
+ preview : '预览',
6099
+ undo : '后退(Ctrl+Z)',
6100
+ redo : '前进(Ctrl+Y)',
6101
+ cut : '剪切(Ctrl+X)',
6102
+ copy : '复制(Ctrl+C)',
6103
+ paste : '粘贴(Ctrl+V)',
6104
+ plainpaste : '粘贴为无格式文本',
6105
+ wordpaste : '从Word粘贴',
6106
+ selectall : '全选(Ctrl+A)',
6107
+ justifyleft : '左对齐',
6108
+ justifycenter : '居中',
6109
+ justifyright : '右对齐',
6110
+ justifyfull : '两端对齐',
6111
+ insertorderedlist : '编号',
6112
+ insertunorderedlist : '项目符号',
6113
+ indent : '增加缩进',
6114
+ outdent : '减少缩进',
6115
+ subscript : '下标',
6116
+ superscript : '上标',
6117
+ formatblock : '段落',
6118
+ fontname : '字体',
6119
+ fontsize : '文字大小',
6120
+ forecolor : '文字颜色',
6121
+ hilitecolor : '文字背景',
6122
+ bold : '粗体(Ctrl+B)',
6123
+ italic : '斜体(Ctrl+I)',
6124
+ underline : '下划线(Ctrl+U)',
6125
+ strikethrough : '删除线',
6126
+ removeformat : '删除格式',
6127
+ image : '图片',
6128
+ multiimage : '批量图片上传',
6129
+ flash : 'Flash',
6130
+ media : '视音频',
6131
+ table : '表格',
6132
+ tablecell : '单元格',
6133
+ hr : '插入横线',
6134
+ emoticons : '插入表情',
6135
+ link : '超级链接',
6136
+ unlink : '取消超级链接',
6137
+ fullscreen : '全屏显示',
6138
+ about : '关于',
6139
+ print : '打印(Ctrl+P)',
6140
+ filemanager : '文件空间',
6141
+ code : '插入程序代码',
6142
+ map : 'Google地图',
6143
+ baidumap : '百度地图',
6144
+ lineheight : '行距',
6145
+ clearhtml : '清理HTML代码',
6146
+ pagebreak : '插入分页符',
6147
+ quickformat : '一键排版',
6148
+ insertfile : '插入文件',
6149
+ template : '插入模板',
6150
+ anchor : '锚点',
6151
+ yes : '确定',
6152
+ no : '取消',
6153
+ close : '关闭',
6154
+ editImage : '图片属性',
6155
+ deleteImage : '删除图片',
6156
+ editFlash : 'Flash属性',
6157
+ deleteFlash : '删除Flash',
6158
+ editMedia : '视音频属性',
6159
+ deleteMedia : '删除视音频',
6160
+ editLink : '超级链接属性',
6161
+ deleteLink : '取消超级链接',
6162
+ editAnchor : '锚点属性',
6163
+ deleteAnchor : '删除锚点',
6164
+ tableprop : '表格属性',
6165
+ tablecellprop : '单元格属性',
6166
+ tableinsert : '插入表格',
6167
+ tabledelete : '删除表格',
6168
+ tablecolinsertleft : '左侧插入列',
6169
+ tablecolinsertright : '右侧插入列',
6170
+ tablerowinsertabove : '上方插入行',
6171
+ tablerowinsertbelow : '下方插入行',
6172
+ tablerowmerge : '向下合并单元格',
6173
+ tablecolmerge : '向右合并单元格',
6174
+ tablerowsplit : '拆分行',
6175
+ tablecolsplit : '拆分列',
6176
+ tablecoldelete : '删除列',
6177
+ tablerowdelete : '删除行',
6178
+ noColor : '无颜色',
6179
+ pleaseSelectFile : '请选择文件。',
6180
+ invalidImg : "请输入有效的URL地址。\n只允许jpg,gif,bmp,png格式。",
6181
+ invalidMedia : "请输入有效的URL地址。\n只允许swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb格式。",
6182
+ invalidWidth : "宽度必须为数字。",
6183
+ invalidHeight : "高度必须为数字。",
6184
+ invalidBorder : "边框必须为数字。",
6185
+ invalidUrl : "请输入有效的URL地址。",
6186
+ invalidRows : '行数为必选项,只允许输入大于0的数字。',
6187
+ invalidCols : '列数为必选项,只允许输入大于0的数字。',
6188
+ invalidPadding : '边距必须为数字。',
6189
+ invalidSpacing : '间距必须为数字。',
6190
+ invalidJson : '服务器发生故障。',
6191
+ uploadSuccess : '上传成功。',
6192
+ cutError : '您的浏览器安全设置不允许使用剪切操作,请使用快捷键(Ctrl+X)来完成。',
6193
+ copyError : '您的浏览器安全设置不允许使用复制操作,请使用快捷键(Ctrl+C)来完成。',
6194
+ pasteError : '您的浏览器安全设置不允许使用粘贴操作,请使用快捷键(Ctrl+V)来完成。',
6195
+ ajaxLoading : '加载中,请稍候 ...',
6196
+ uploadLoading : '上传中,请稍候 ...',
6197
+ uploadError : '上传错误',
6198
+ 'plainpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
6199
+ 'wordpaste.comment' : '请使用快捷键(Ctrl+V)把内容粘贴到下面的方框里。',
6200
+ 'code.pleaseInput' : '请输入程序代码。',
6201
+ 'link.url' : 'URL',
6202
+ 'link.linkType' : '打开类型',
6203
+ 'link.newWindow' : '新窗口',
6204
+ 'link.selfWindow' : '当前窗口',
6205
+ 'flash.url' : 'URL',
6206
+ 'flash.width' : '宽度',
6207
+ 'flash.height' : '高度',
6208
+ 'flash.upload' : '上传',
6209
+ 'flash.viewServer' : '文件空间',
6210
+ 'media.url' : 'URL',
6211
+ 'media.width' : '宽度',
6212
+ 'media.height' : '高度',
6213
+ 'media.autostart' : '自动播放',
6214
+ 'media.upload' : '上传',
6215
+ 'media.viewServer' : '文件空间',
6216
+ 'image.remoteImage' : '网络图片',
6217
+ 'image.localImage' : '本地上传',
6218
+ 'image.remoteUrl' : '图片地址',
6219
+ 'image.localUrl' : '上传文件',
6220
+ 'image.size' : '图片大小',
6221
+ 'image.width' : '宽',
6222
+ 'image.height' : '高',
6223
+ 'image.resetSize' : '重置大小',
6224
+ 'image.align' : '对齐方式',
6225
+ 'image.defaultAlign' : '默认方式',
6226
+ 'image.leftAlign' : '左对齐',
6227
+ 'image.rightAlign' : '右对齐',
6228
+ 'image.imgTitle' : '图片说明',
6229
+ 'image.upload' : '浏览...',
6230
+ 'image.viewServer' : '图片空间',
6231
+ 'multiimage.uploadDesc' : '允许用户同时上传<%=uploadLimit%>张图片,单张图片容量不超过<%=sizeLimit%>',
6232
+ 'multiimage.startUpload' : '开始上传',
6233
+ 'multiimage.clearAll' : '全部清空',
6234
+ 'multiimage.insertAll' : '全部插入',
6235
+ 'multiimage.queueLimitExceeded' : '文件数量超过限制。',
6236
+ 'multiimage.fileExceedsSizeLimit' : '文件大小超过限制。',
6237
+ 'multiimage.zeroByteFile' : '无法上传空文件。',
6238
+ 'multiimage.invalidFiletype' : '文件类型不正确。',
6239
+ 'multiimage.unknownError' : '发生异常,无法上传。',
6240
+ 'multiimage.pending' : '等待上传',
6241
+ 'multiimage.uploadError' : '上传失败',
6242
+ 'filemanager.emptyFolder' : '空文件夹',
6243
+ 'filemanager.moveup' : '移到上一级文件夹',
6244
+ 'filemanager.viewType' : '显示方式:',
6245
+ 'filemanager.viewImage' : '缩略图',
6246
+ 'filemanager.listImage' : '详细信息',
6247
+ 'filemanager.orderType' : '排序方式:',
6248
+ 'filemanager.fileName' : '名称',
6249
+ 'filemanager.fileSize' : '大小',
6250
+ 'filemanager.fileType' : '类型',
6251
+ 'insertfile.url' : 'URL',
6252
+ 'insertfile.title' : '文件说明',
6253
+ 'insertfile.upload' : '上传',
6254
+ 'insertfile.viewServer' : '文件空间',
6255
+ 'table.cells' : '单元格数',
6256
+ 'table.rows' : '行数',
6257
+ 'table.cols' : '列数',
6258
+ 'table.size' : '大小',
6259
+ 'table.width' : '宽度',
6260
+ 'table.height' : '高度',
6261
+ 'table.percent' : '%',
6262
+ 'table.px' : 'px',
6263
+ 'table.space' : '边距间距',
6264
+ 'table.padding' : '边距',
6265
+ 'table.spacing' : '间距',
6266
+ 'table.align' : '对齐方式',
6267
+ 'table.textAlign' : '水平对齐',
6268
+ 'table.verticalAlign' : '垂直对齐',
6269
+ 'table.alignDefault' : '默认',
6270
+ 'table.alignLeft' : '左对齐',
6271
+ 'table.alignCenter' : '居中',
6272
+ 'table.alignRight' : '右对齐',
6273
+ 'table.alignTop' : '顶部',
6274
+ 'table.alignMiddle' : '中部',
6275
+ 'table.alignBottom' : '底部',
6276
+ 'table.alignBaseline' : '基线',
6277
+ 'table.border' : '边框',
6278
+ 'table.borderWidth' : '边框',
6279
+ 'table.borderColor' : '颜色',
6280
+ 'table.backgroundColor' : '背景颜色',
6281
+ 'map.address' : '地址: ',
6282
+ 'map.search' : '搜索',
6283
+ 'baidumap.address' : '地址: ',
6284
+ 'baidumap.search' : '搜索',
6285
+ 'baidumap.insertDynamicMap' : '插入动态地图',
6286
+ 'anchor.name' : '锚点名称',
6287
+ 'formatblock.formatBlock' : {
6288
+ h1 : '标题 1',
6289
+ h2 : '标题 2',
6290
+ h3 : '标题 3',
6291
+ h4 : '标题 4',
6292
+ p : '正 文'
6293
+ },
6294
+ 'fontname.fontName' : {
6295
+ 'SimSun' : '宋体',
6296
+ 'NSimSun' : '新宋体',
6297
+ 'FangSong_GB2312' : '仿宋_GB2312',
6298
+ 'KaiTi_GB2312' : '楷体_GB2312',
6299
+ 'SimHei' : '黑体',
6300
+ 'Microsoft YaHei' : '微软雅黑',
6301
+ 'Arial' : 'Arial',
6302
+ 'Arial Black' : 'Arial Black',
6303
+ 'Times New Roman' : 'Times New Roman',
6304
+ 'Courier New' : 'Courier New',
6305
+ 'Tahoma' : 'Tahoma',
6306
+ 'Verdana' : 'Verdana'
6307
+ },
6308
+ 'lineheight.lineHeight' : [
6309
+ {'1' : '单倍行距'},
6310
+ {'1.5' : '1.5倍行距'},
6311
+ {'2' : '2倍行距'},
6312
+ {'2.5' : '2.5倍行距'},
6313
+ {'3' : '3倍行距'}
6314
+ ],
6315
+ 'template.selectTemplate' : '可选模板',
6316
+ 'template.replaceContent' : '替换当前内容',
6317
+ 'template.fileList' : {
6318
+ '1.html' : '图片和文字',
6319
+ '2.html' : '表格',
6320
+ '3.html' : '项目编号'
6321
+ }
6322
+ }, 'zh-CN');
6323
+ KindEditor.options.langType = 'zh-CN';
6324
+ /*******************************************************************************
6325
+ * KindEditor - WYSIWYG HTML Editor for Internet
6326
+ * Copyright (C) 2006-2011 kindsoft.net
6327
+ *
6328
+ * @author Roddy <luolonghao@gmail.com>
6329
+ * @site http://www.kindsoft.net/
6330
+ * @licence http://www.kindsoft.net/license.php
6331
+ *******************************************************************************/
6332
+ KindEditor.plugin('anchor', function(K) {
6333
+ var self = this, name = 'anchor', lang = self.lang(name + '.');
6334
+ self.plugin.anchor = {
6335
+ edit : function() {
6336
+ var html = ['<div style="padding:20px;">',
6337
+ '<div class="ke-dialog-row">',
6338
+ '<label for="keName">' + lang.name + '</label>',
6339
+ '<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />',
6340
+ '</div>',
6341
+ '</div>'].join('');
6342
+ var dialog = self.createDialog({
6343
+ name : name,
6344
+ width : 300,
6345
+ title : self.lang(name),
6346
+ body : html,
6347
+ yesBtn : {
6348
+ name : self.lang('yes'),
6349
+ click : function(e) {
6350
+ self.insertHtml('<a name="' + nameBox.val() + '">').hideDialog().focus();
6351
+ }
6352
+ }
6353
+ });
6354
+ var div = dialog.div,
6355
+ nameBox = K('input[name="name"]', div);
6356
+ var img = self.plugin.getSelectedAnchor();
6357
+ if (img) {
6358
+ nameBox.val(unescape(img.attr('data-ke-name')));
6359
+ }
6360
+ nameBox[0].focus();
6361
+ nameBox[0].select();
6362
+ },
6363
+ 'delete' : function() {
6364
+ self.plugin.getSelectedAnchor().remove();
6365
+ }
6366
+ };
6367
+ self.clickToolbar(name, self.plugin.anchor.edit);
6368
+ });
6369
+
6370
+ /*******************************************************************************
6371
+ * KindEditor - WYSIWYG HTML Editor for Internet
6372
+ * Copyright (C) 2006-2011 kindsoft.net
6373
+ *
6374
+ * @author Roddy <luolonghao@gmail.com>
6375
+ * @site http://www.kindsoft.net/
6376
+ * @licence http://www.kindsoft.net/license.php
6377
+ *******************************************************************************/
6378
+ KindEditor.plugin('autoheight', function(K) {
6379
+ var self = this;
6380
+ if (!self.autoHeightMode) {
6381
+ return;
6382
+ }
6383
+ var minHeight;
6384
+ function hideScroll() {
6385
+ var edit = self.edit;
6386
+ var body = edit.doc.body;
6387
+ edit.iframe[0].scroll = 'no';
6388
+ body.style.overflowY = 'hidden';
6389
+ }
6390
+ function resetHeight() {
6391
+ var edit = self.edit;
6392
+ var body = edit.doc.body;
6393
+ edit.iframe.height(minHeight);
6394
+ self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 76, minHeight));
6395
+ }
6396
+ function init() {
6397
+ minHeight = K.removeUnit(self.height);
6398
+ self.edit.afterChange(resetHeight);
6399
+ hideScroll();
6400
+ resetHeight();
6401
+ }
6402
+ if (self.isCreated) {
6403
+ init();
6404
+ } else {
6405
+ self.afterCreate(init);
6406
+ }
6407
+ });
6408
+ /*
6409
+ * 如何实现真正的自动高度?
6410
+ * 修改编辑器高度之后,再次获取body内容高度时,最小值只会是当前iframe的设置高度,这样就导致高度只增不减。
6411
+ * 所以每次获取body内容高度之前,先将iframe的高度重置为最小高度,这样就能获取body的实际高度。
6412
+ * 由此就实现了真正的自动高度
6413
+ * 测试:chrome、firefox、IE9、IE8
6414
+ * */
6415
+
6416
+ /*******************************************************************************
6417
+ * KindEditor - WYSIWYG HTML Editor for Internet
6418
+ * Copyright (C) 2006-2011 kindsoft.net
6419
+ *
6420
+ * @author Roddy <luolonghao@gmail.com>
6421
+ * @site http://www.kindsoft.net/
6422
+ * @licence http://www.kindsoft.net/license.php
6423
+ *******************************************************************************/
6424
+ KindEditor.plugin('baidumap', function(K) {
6425
+ var self = this, name = 'baidumap', lang = self.lang(name + '.');
6426
+ var mapWidth = K.undef(self.mapWidth, 558);
6427
+ var mapHeight = K.undef(self.mapHeight, 360);
6428
+ self.clickToolbar(name, function() {
6429
+ var html = ['<div style="padding:10px 20px;">',
6430
+ '<div class="ke-header">',
6431
+ '<div class="ke-left">',
6432
+ lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
6433
+ '<span class="ke-button-common ke-button-outer">',
6434
+ '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
6435
+ '</span>',
6436
+ '</div>',
6437
+ '<div class="ke-right">',
6438
+ '<input type="checkbox" id="keInsertDynamicMap" name="insertDynamicMap" value="1" /> <label for="keInsertDynamicMap">' + lang.insertDynamicMap + '</label>',
6439
+ '</div>',
6440
+ '<div class="ke-clearfix"></div>',
6441
+ '</div>',
6442
+ '<div class="ke-map" style="width:' + mapWidth + 'px;height:' + mapHeight + 'px;"></div>',
6443
+ '</div>'].join('');
6444
+ var dialog = self.createDialog({
6445
+ name : name,
6446
+ width : mapWidth + 42,
6447
+ title : self.lang(name),
6448
+ body : html,
6449
+ yesBtn : {
6450
+ name : self.lang('yes'),
6451
+ click : function(e) {
6452
+ var map = win.map;
6453
+ var centerObj = map.getCenter();
6454
+ var center = centerObj.lng + ',' + centerObj.lat;
6455
+ var zoom = map.getZoom();
6456
+ var url = [checkbox[0].checked ? self.pluginsPath + 'baidumap/index.html' : 'http://api.map.baidu.com/staticimage',
6457
+ '?center=' + encodeURIComponent(center),
6458
+ '&zoom=' + encodeURIComponent(zoom),
6459
+ '&width=' + mapWidth,
6460
+ '&height=' + mapHeight,
6461
+ '&markers=' + encodeURIComponent(center),
6462
+ '&markerStyles=' + encodeURIComponent('l,A')].join('');
6463
+ if (checkbox[0].checked) {
6464
+ self.insertHtml('<iframe src="' + url + '" frameborder="0" style="width:' + (mapWidth + 2) + 'px;height:' + (mapHeight + 2) + 'px;"></iframe>');
6465
+ } else {
6466
+ self.exec('insertimage', url);
6467
+ }
6468
+ self.hideDialog().focus();
6469
+ }
6470
+ },
6471
+ beforeRemove : function() {
6472
+ searchBtn.remove();
6473
+ if (doc) {
6474
+ doc.write('');
6475
+ }
6476
+ iframe.remove();
6477
+ }
6478
+ });
6479
+ var div = dialog.div,
6480
+ addressBox = K('[name="address"]', div),
6481
+ searchBtn = K('[name="searchBtn"]', div),
6482
+ checkbox = K('[name="insertDynamicMap"]', dialog.div),
6483
+ win, doc;
6484
+ var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'baidumap/map.html" style="width:' + mapWidth + 'px;height:' + mapHeight + 'px;"></iframe>');
6485
+ function ready() {
6486
+ win = iframe[0].contentWindow;
6487
+ doc = K.iframeDoc(iframe);
6488
+ }
6489
+ iframe.bind('load', function() {
6490
+ iframe.unbind('load');
6491
+ if (K.IE) {
6492
+ ready();
6493
+ } else {
6494
+ setTimeout(ready, 0);
6495
+ }
6496
+ });
6497
+ K('.ke-map', div).replaceWith(iframe);
6498
+ searchBtn.click(function() {
6499
+ win.search(addressBox.val());
6500
+ });
6501
+ });
6502
+ });
6503
+
6504
+ /*******************************************************************************
6505
+ * KindEditor - WYSIWYG HTML Editor for Internet
6506
+ * Copyright (C) 2006-2011 kindsoft.net
6507
+ *
6508
+ * @author Roddy <luolonghao@gmail.com>
6509
+ * @site http://www.kindsoft.net/
6510
+ * @licence http://www.kindsoft.net/license.php
6511
+ *******************************************************************************/
6512
+
6513
+
6514
+ KindEditor.plugin('map', function(K) {
6515
+ var self = this, name = 'map', lang = self.lang(name + '.');
6516
+ self.clickToolbar(name, function() {
6517
+ var html = ['<div style="padding:10px 20px;">',
6518
+ '<div class="ke-dialog-row">',
6519
+ lang.address + ' <input id="kindeditor_plugin_map_address" name="address" class="ke-input-text" value="" style="width:200px;" /> ',
6520
+ '<span class="ke-button-common ke-button-outer">',
6521
+ '<input type="button" name="searchBtn" class="ke-button-common ke-button" value="' + lang.search + '" />',
6522
+ '</span>',
6523
+ '</div>',
6524
+ '<div class="ke-map" style="width:558px;height:360px;"></div>',
6525
+ '</div>'].join('');
6526
+ var dialog = self.createDialog({
6527
+ name : name,
6528
+ width : 600,
6529
+ title : self.lang(name),
6530
+ body : html,
6531
+ yesBtn : {
6532
+ name : self.lang('yes'),
6533
+ click : function(e) {
6534
+ var geocoder = win.geocoder,
6535
+ map = win.map,
6536
+ center = map.getCenter().lat() + ',' + map.getCenter().lng(),
6537
+ zoom = map.getZoom(),
6538
+ maptype = map.getMapTypeId(),
6539
+ url = 'http://maps.googleapis.com/maps/api/staticmap';
6540
+ url += '?center=' + encodeURIComponent(center);
6541
+ url += '&zoom=' + encodeURIComponent(zoom);
6542
+ url += '&size=558x360';
6543
+ url += '&maptype=' + encodeURIComponent(maptype);
6544
+ url += '&markers=' + encodeURIComponent(center);
6545
+ url += '&language=' + self.langType;
6546
+ url += '&sensor=false';
6547
+ self.exec('insertimage', url).hideDialog().focus();
6548
+ }
6549
+ },
6550
+ beforeRemove : function() {
6551
+ searchBtn.remove();
6552
+ if (doc) {
6553
+ doc.write('');
6554
+ }
6555
+ iframe.remove();
6556
+ }
6557
+ });
6558
+ var div = dialog.div,
6559
+ addressBox = K('[name="address"]', div),
6560
+ searchBtn = K('[name="searchBtn"]', div),
6561
+ win, doc;
6562
+ var iframeHtml = ['<!doctype html><html><head>',
6563
+ '<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />',
6564
+ '<style>',
6565
+ ' html { height: 100% }',
6566
+ ' body { height: 100%; margin: 0; padding: 0; background-color: #FFF }',
6567
+ ' #map_canvas { height: 100% }',
6568
+ '</style>',
6569
+ '<script src="http://maps.googleapis.com/maps/api/js?sensor=false&language=' + self.langType + '"></script>',
6570
+ '<script>',
6571
+ 'var map, geocoder;',
6572
+ 'function initialize() {',
6573
+ ' var latlng = new google.maps.LatLng(31.230393, 121.473704);',
6574
+ ' var options = {',
6575
+ ' zoom: 11,',
6576
+ ' center: latlng,',
6577
+ ' disableDefaultUI: true,',
6578
+ ' panControl: true,',
6579
+ ' zoomControl: true,',
6580
+ ' mapTypeControl: true,',
6581
+ ' scaleControl: true,',
6582
+ ' streetViewControl: false,',
6583
+ ' overviewMapControl: true,',
6584
+ ' mapTypeId: google.maps.MapTypeId.ROADMAP',
6585
+ ' };',
6586
+ ' map = new google.maps.Map(document.getElementById("map_canvas"), options);',
6587
+ ' geocoder = new google.maps.Geocoder();',
6588
+ ' geocoder.geocode({latLng: latlng}, function(results, status) {',
6589
+ ' if (status == google.maps.GeocoderStatus.OK) {',
6590
+ ' if (results[3]) {',
6591
+ ' parent.document.getElementById("kindeditor_plugin_map_address").value = results[3].formatted_address;',
6592
+ ' }',
6593
+ ' }',
6594
+ ' });',
6595
+ '}',
6596
+ 'function search(address) {',
6597
+ ' if (!map) return;',
6598
+ ' geocoder.geocode({address : address}, function(results, status) {',
6599
+ ' if (status == google.maps.GeocoderStatus.OK) {',
6600
+ ' map.setZoom(11);',
6601
+ ' map.setCenter(results[0].geometry.location);',
6602
+ ' var marker = new google.maps.Marker({',
6603
+ ' map: map,',
6604
+ ' position: results[0].geometry.location',
6605
+ ' });',
6606
+ ' } else {',
6607
+ ' alert("Invalid address: " + address);',
6608
+ ' }',
6609
+ ' });',
6610
+ '}',
6611
+ '</script>',
6612
+ '</head>',
6613
+ '<body onload="initialize();">',
6614
+ '<div id="map_canvas" style="width:100%; height:100%"></div>',
6615
+ '</body></html>'].join('\n');
6616
+ var iframe = K('<iframe class="ke-textarea" frameborder="0" src="' + self.pluginsPath + 'map/map.html" style="width:558px;height:360px;"></iframe>');
6617
+ function ready() {
6618
+ win = iframe[0].contentWindow;
6619
+ doc = K.iframeDoc(iframe);
6620
+ }
6621
+ iframe.bind('load', function() {
6622
+ iframe.unbind('load');
6623
+ if (K.IE) {
6624
+ ready();
6625
+ } else {
6626
+ setTimeout(ready, 0);
6627
+ }
6628
+ });
6629
+ K('.ke-map', div).replaceWith(iframe);
6630
+ searchBtn.click(function() {
6631
+ win.search(addressBox.val());
6632
+ });
6633
+ });
6634
+ });
6635
+
6636
+ /*******************************************************************************
6637
+ * KindEditor - WYSIWYG HTML Editor for Internet
6638
+ * Copyright (C) 2006-2011 kindsoft.net
6639
+ *
6640
+ * @author Roddy <luolonghao@gmail.com>
6641
+ * @site http://www.kindsoft.net/
6642
+ * @licence http://www.kindsoft.net/license.php
6643
+ *******************************************************************************/
6644
+ KindEditor.plugin('clearhtml', function(K) {
6645
+ var self = this, name = 'clearhtml';
6646
+ self.clickToolbar(name, function() {
6647
+ self.focus();
6648
+ var html = self.html();
6649
+ html = html.replace(/(<script[^>]*>)([\s\S]*?)(<\/script>)/ig, '');
6650
+ html = html.replace(/(<style[^>]*>)([\s\S]*?)(<\/style>)/ig, '');
6651
+ html = K.formatHtml(html, {
6652
+ a : ['href', 'target'],
6653
+ embed : ['src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'],
6654
+ img : ['src', 'width', 'height', 'border', 'alt', 'title', '.width', '.height'],
6655
+ table : ['border'],
6656
+ 'td,th' : ['rowspan', 'colspan'],
6657
+ 'div,hr,br,tbody,tr,p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : []
6658
+ });
6659
+ self.html(html);
6660
+ self.cmd.selection(true);
6661
+ self.addBookmark();
6662
+ });
6663
+ });
6664
+
6665
+ /*******************************************************************************
6666
+ * KindEditor - WYSIWYG HTML Editor for Internet
6667
+ * Copyright (C) 2006-2011 kindsoft.net
6668
+ *
6669
+ * @author Roddy <luolonghao@gmail.com>
6670
+ * @site http://www.kindsoft.net/
6671
+ * @licence http://www.kindsoft.net/license.php
6672
+ *******************************************************************************/
6673
+
6674
+
6675
+
6676
+ KindEditor.plugin('code', function(K) {
6677
+ var self = this, name = 'code';
6678
+ self.clickToolbar(name, function() {
6679
+ var lang = self.lang(name + '.'),
6680
+ html = ['<div style="padding:10px 20px;">',
6681
+ '<div class="ke-dialog-row">',
6682
+ '<select class="ke-code-type">',
6683
+ '<option value="js">JavaScript</option>',
6684
+ '<option value="html">HTML</option>',
6685
+ '<option value="css">CSS</option>',
6686
+ '<option value="php">PHP</option>',
6687
+ '<option value="pl">Perl</option>',
6688
+ '<option value="py">Python</option>',
6689
+ '<option value="rb">Ruby</option>',
6690
+ '<option value="java">Java</option>',
6691
+ '<option value="vb">ASP/VB</option>',
6692
+ '<option value="cpp">C/C++</option>',
6693
+ '<option value="cs">C#</option>',
6694
+ '<option value="xml">XML</option>',
6695
+ '<option value="bsh">Shell</option>',
6696
+ '<option value="">Other</option>',
6697
+ '</select>',
6698
+ '</div>',
6699
+ '<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>',
6700
+ '</div>'].join(''),
6701
+ dialog = self.createDialog({
6702
+ name : name,
6703
+ width : 450,
6704
+ title : self.lang(name),
6705
+ body : html,
6706
+ yesBtn : {
6707
+ name : self.lang('yes'),
6708
+ click : function(e) {
6709
+ var type = K('.ke-code-type', dialog.div).val(),
6710
+ code = textarea.val(),
6711
+ cls = type === '' ? '' : ' lang-' + type,
6712
+ html = '<pre class="prettyprint' + cls + '">\n' + K.escape(code) + '</pre> ';
6713
+ if (K.trim(code) === '') {
6714
+ alert(lang.pleaseInput);
6715
+ textarea[0].focus();
6716
+ return;
6717
+ }
6718
+ self.insertHtml(html).hideDialog().focus();
6719
+ }
6720
+ }
6721
+ }),
6722
+ textarea = K('textarea', dialog.div);
6723
+ textarea[0].focus();
6724
+ });
6725
+ });
6726
+
6727
+ /*******************************************************************************
6728
+ * KindEditor - WYSIWYG HTML Editor for Internet
6729
+ * Copyright (C) 2006-2011 kindsoft.net
6730
+ *
6731
+ * @author Roddy <luolonghao@gmail.com>
6732
+ * @site http://www.kindsoft.net/
6733
+ * @licence http://www.kindsoft.net/license.php
6734
+ *******************************************************************************/
6735
+ KindEditor.plugin('emoticons', function(K) {
6736
+ var self = this, name = 'emoticons',
6737
+ path = (self.emoticonsPath || self.pluginsPath + 'emoticons/images/'),
6738
+ allowPreview = self.allowPreviewEmoticons === undefined ? true : self.allowPreviewEmoticons,
6739
+ currentPageNum = 1;
6740
+ self.clickToolbar(name, function() {
6741
+ var rows = 5, cols = 9, total = 135, startNum = 0,
6742
+ cells = rows * cols, pages = Math.ceil(total / cells),
6743
+ colsHalf = Math.floor(cols / 2),
6744
+ wrapperDiv = K('<div class="ke-plugin-emoticons"></div>'),
6745
+ elements = [],
6746
+ menu = self.createMenu({
6747
+ name : name,
6748
+ beforeRemove : function() {
6749
+ removeEvent();
6750
+ }
6751
+ });
6752
+ menu.div.append(wrapperDiv);
6753
+ var previewDiv, previewImg;
6754
+ if (allowPreview) {
6755
+ previewDiv = K('<div class="ke-preview"></div>').css('right', 0);
6756
+ previewImg = K('<img class="ke-preview-img" src="' + path + startNum + '.gif" />');
6757
+ wrapperDiv.append(previewDiv);
6758
+ previewDiv.append(previewImg);
6759
+ }
6760
+ function bindCellEvent(cell, j, num) {
6761
+ if (previewDiv) {
6762
+ cell.mouseover(function() {
6763
+ if (j > colsHalf) {
6764
+ previewDiv.css('left', 0);
6765
+ previewDiv.css('right', '');
6766
+ } else {
6767
+ previewDiv.css('left', '');
6768
+ previewDiv.css('right', 0);
6769
+ }
6770
+ previewImg.attr('src', path + num + '.gif');
6771
+ K(this).addClass('ke-on');
6772
+ });
6773
+ } else {
6774
+ cell.mouseover(function() {
6775
+ K(this).addClass('ke-on');
6776
+ });
6777
+ }
6778
+ cell.mouseout(function() {
6779
+ K(this).removeClass('ke-on');
6780
+ });
6781
+ cell.click(function(e) {
6782
+ self.insertHtml('<img src="' + path + num + '.gif" border="0" alt="" />').hideMenu().focus();
6783
+ e.stop();
6784
+ });
6785
+ }
6786
+ function createEmoticonsTable(pageNum, parentDiv) {
6787
+ var table = document.createElement('table');
6788
+ parentDiv.append(table);
6789
+ if (previewDiv) {
6790
+ K(table).mouseover(function() {
6791
+ previewDiv.show('block');
6792
+ });
6793
+ K(table).mouseout(function() {
6794
+ previewDiv.hide();
6795
+ });
6796
+ elements.push(K(table));
6797
+ }
6798
+ table.className = 'ke-table';
6799
+ table.cellPadding = 0;
6800
+ table.cellSpacing = 0;
6801
+ table.border = 0;
6802
+ var num = (pageNum - 1) * cells + startNum;
6803
+ for (var i = 0; i < rows; i++) {
6804
+ var row = table.insertRow(i);
6805
+ for (var j = 0; j < cols; j++) {
6806
+ var cell = K(row.insertCell(j));
6807
+ cell.addClass('ke-cell');
6808
+ bindCellEvent(cell, j, num);
6809
+ var span = K('<span class="ke-img"></span>')
6810
+ .css('background-position', '-' + (24 * num) + 'px 0px')
6811
+ .css('background-image', 'url(' + path + 'static.gif)');
6812
+ cell.append(span);
6813
+ elements.push(cell);
6814
+ num++;
6815
+ }
6816
+ }
6817
+ return table;
6818
+ }
6819
+ var table = createEmoticonsTable(currentPageNum, wrapperDiv);
6820
+ function removeEvent() {
6821
+ K.each(elements, function() {
6822
+ this.unbind();
6823
+ });
6824
+ }
6825
+ var pageDiv;
6826
+ function bindPageEvent(el, pageNum) {
6827
+ el.click(function(e) {
6828
+ removeEvent();
6829
+ table.parentNode.removeChild(table);
6830
+ pageDiv.remove();
6831
+ table = createEmoticonsTable(pageNum, wrapperDiv);
6832
+ createPageTable(pageNum);
6833
+ currentPageNum = pageNum;
6834
+ e.stop();
6835
+ });
6836
+ }
6837
+ function createPageTable(currentPageNum) {
6838
+ pageDiv = K('<div class="ke-page"></div>');
6839
+ wrapperDiv.append(pageDiv);
6840
+ for (var pageNum = 1; pageNum <= pages; pageNum++) {
6841
+ if (currentPageNum !== pageNum) {
6842
+ var a = K('<a href="javascript:;">[' + pageNum + ']</a>');
6843
+ bindPageEvent(a, pageNum);
6844
+ pageDiv.append(a);
6845
+ elements.push(a);
6846
+ } else {
6847
+ pageDiv.append(K('@[' + pageNum + ']'));
6848
+ }
6849
+ pageDiv.append(K('@&nbsp;'));
6850
+ }
6851
+ }
6852
+ createPageTable(currentPageNum);
6853
+ });
6854
+ });
6855
+
6856
+ /*******************************************************************************
6857
+ * KindEditor - WYSIWYG HTML Editor for Internet
6858
+ * Copyright (C) 2006-2011 kindsoft.net
6859
+ *
6860
+ * @author Roddy <luolonghao@gmail.com>
6861
+ * @site http://www.kindsoft.net/
6862
+ * @licence http://www.kindsoft.net/license.php
6863
+ *******************************************************************************/
6864
+ KindEditor.plugin('filemanager', function(K) {
6865
+ var self = this, name = 'filemanager',
6866
+ fileManagerJson = K.undef(self.fileManagerJson, self.basePath + 'php/file_manager_json.php'),
6867
+ imgPath = self.pluginsPath + name + '/images/',
6868
+ lang = self.lang(name + '.');
6869
+ function makeFileTitle(filename, filesize, datetime) {
6870
+ return filename + ' (' + Math.ceil(filesize / 1024) + 'KB, ' + datetime + ')';
6871
+ }
6872
+ function bindTitle(el, data) {
6873
+ if (data.is_dir) {
6874
+ el.attr('title', data.filename);
6875
+ } else {
6876
+ el.attr('title', makeFileTitle(data.filename, data.filesize, data.datetime));
6877
+ }
6878
+ }
6879
+ self.plugin.filemanagerDialog = function(options) {
6880
+ var width = K.undef(options.width, 650),
6881
+ height = K.undef(options.height, 510),
6882
+ dirName = K.undef(options.dirName, ''),
6883
+ viewType = K.undef(options.viewType, 'VIEW').toUpperCase(),
6884
+ clickFn = options.clickFn;
6885
+ var html = [
6886
+ '<div style="padding:10px 20px;">',
6887
+ '<div class="ke-plugin-filemanager-header">',
6888
+ '<div class="ke-left">',
6889
+ '<img class="ke-inline-block" name="moveupImg" src="' + imgPath + 'go-up.gif" width="16" height="16" border="0" alt="" /> ',
6890
+ '<a class="ke-inline-block" name="moveupLink" href="javascript:;">' + lang.moveup + '</a>',
6891
+ '</div>',
6892
+ '<div class="ke-right">',
6893
+ lang.viewType + ' <select class="ke-inline-block" name="viewType">',
6894
+ '<option value="VIEW">' + lang.viewImage + '</option>',
6895
+ '<option value="LIST">' + lang.listImage + '</option>',
6896
+ '</select> ',
6897
+ lang.orderType + ' <select class="ke-inline-block" name="orderType">',
6898
+ '<option value="NAME">' + lang.fileName + '</option>',
6899
+ '<option value="SIZE">' + lang.fileSize + '</option>',
6900
+ '<option value="TYPE">' + lang.fileType + '</option>',
6901
+ '</select>',
6902
+ '</div>',
6903
+ '<div class="ke-clearfix"></div>',
6904
+ '</div>',
6905
+ '<div class="ke-plugin-filemanager-body"></div>',
6906
+ '</div>'
6907
+ ].join('');
6908
+ var dialog = self.createDialog({
6909
+ name : name,
6910
+ width : width,
6911
+ height : height,
6912
+ title : self.lang(name),
6913
+ body : html
6914
+ }),
6915
+ div = dialog.div,
6916
+ bodyDiv = K('.ke-plugin-filemanager-body', div),
6917
+ moveupImg = K('[name="moveupImg"]', div),
6918
+ moveupLink = K('[name="moveupLink"]', div),
6919
+ viewServerBtn = K('[name="viewServer"]', div),
6920
+ viewTypeBox = K('[name="viewType"]', div),
6921
+ orderTypeBox = K('[name="orderType"]', div);
6922
+ function reloadPage(path, order, func) {
6923
+ var param = 'path=' + path + '&order=' + order + '&dir=' + dirName;
6924
+ dialog.showLoading(self.lang('ajaxLoading'));
6925
+ K.ajax(K.addParam(fileManagerJson, param + '&' + new Date().getTime()), function(data) {
6926
+ dialog.hideLoading();
6927
+ func(data);
6928
+ });
6929
+ }
6930
+ var elList = [];
6931
+ function bindEvent(el, result, data, createFunc) {
6932
+ var fileUrl = K.formatUrl(result.current_url + data.filename, 'absolute'),
6933
+ dirPath = encodeURIComponent(result.current_dir_path + data.filename + '/');
6934
+ if (data.is_dir) {
6935
+ el.click(function(e) {
6936
+ reloadPage(dirPath, orderTypeBox.val(), createFunc);
6937
+ });
6938
+ } else if (data.is_photo) {
6939
+ el.click(function(e) {
6940
+ clickFn.call(this, fileUrl, data.filename);
6941
+ });
6942
+ } else {
6943
+ el.click(function(e) {
6944
+ clickFn.call(this, fileUrl, data.filename);
6945
+ });
6946
+ }
6947
+ elList.push(el);
6948
+ }
6949
+ function createCommon(result, createFunc) {
6950
+ K.each(elList, function() {
6951
+ this.unbind();
6952
+ });
6953
+ moveupLink.unbind();
6954
+ viewTypeBox.unbind();
6955
+ orderTypeBox.unbind();
6956
+ if (result.current_dir_path) {
6957
+ moveupLink.click(function(e) {
6958
+ reloadPage(result.moveup_dir_path, orderTypeBox.val(), createFunc);
6959
+ });
6960
+ }
6961
+ function changeFunc() {
6962
+ if (viewTypeBox.val() == 'VIEW') {
6963
+ reloadPage(result.current_dir_path, orderTypeBox.val(), createView);
6964
+ } else {
6965
+ reloadPage(result.current_dir_path, orderTypeBox.val(), createList);
6966
+ }
6967
+ }
6968
+ viewTypeBox.change(changeFunc);
6969
+ orderTypeBox.change(changeFunc);
6970
+ bodyDiv.html('');
6971
+ }
6972
+ function createList(result) {
6973
+ createCommon(result, createList);
6974
+ var table = document.createElement('table');
6975
+ table.className = 'ke-table';
6976
+ table.cellPadding = 0;
6977
+ table.cellSpacing = 0;
6978
+ table.border = 0;
6979
+ bodyDiv.append(table);
6980
+ var fileList = result.file_list;
6981
+ for (var i = 0, len = fileList.length; i < len; i++) {
6982
+ var data = fileList[i], row = K(table.insertRow(i));
6983
+ row.mouseover(function(e) {
6984
+ K(this).addClass('ke-on');
6985
+ })
6986
+ .mouseout(function(e) {
6987
+ K(this).removeClass('ke-on');
6988
+ });
6989
+ var iconUrl = imgPath + (data.is_dir ? 'folder-16.gif' : 'file-16.gif'),
6990
+ img = K('<img src="' + iconUrl + '" width="16" height="16" alt="' + data.filename + '" align="absmiddle" />'),
6991
+ cell0 = K(row[0].insertCell(0)).addClass('ke-cell ke-name').append(img).append(document.createTextNode(' ' + data.filename));
6992
+ if (!data.is_dir || data.has_file) {
6993
+ row.css('cursor', 'pointer');
6994
+ cell0.attr('title', data.filename);
6995
+ bindEvent(cell0, result, data, createList);
6996
+ } else {
6997
+ cell0.attr('title', lang.emptyFolder);
6998
+ }
6999
+ K(row[0].insertCell(1)).addClass('ke-cell ke-size').html(data.is_dir ? '-' : Math.ceil(data.filesize / 1024) + 'KB');
7000
+ K(row[0].insertCell(2)).addClass('ke-cell ke-datetime').html(data.datetime);
7001
+ }
7002
+ }
7003
+ function createView(result) {
7004
+ createCommon(result, createView);
7005
+ var fileList = result.file_list;
7006
+ for (var i = 0, len = fileList.length; i < len; i++) {
7007
+ var data = fileList[i],
7008
+ div = K('<div class="ke-inline-block ke-item"></div>');
7009
+ bodyDiv.append(div);
7010
+ var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
7011
+ .mouseover(function(e) {
7012
+ K(this).addClass('ke-on');
7013
+ })
7014
+ .mouseout(function(e) {
7015
+ K(this).removeClass('ke-on');
7016
+ });
7017
+ div.append(photoDiv);
7018
+ var fileUrl = result.current_url + data.filename,
7019
+ iconUrl = data.is_dir ? imgPath + 'folder-64.gif' : (data.is_photo ? fileUrl : imgPath + 'file-64.gif');
7020
+ var img = K('<img src="' + iconUrl + '" width="80" height="80" alt="' + data.filename + '" />');
7021
+ if (!data.is_dir || data.has_file) {
7022
+ photoDiv.css('cursor', 'pointer');
7023
+ bindTitle(photoDiv, data);
7024
+ bindEvent(photoDiv, result, data, createView);
7025
+ } else {
7026
+ photoDiv.attr('title', lang.emptyFolder);
7027
+ }
7028
+ photoDiv.append(img);
7029
+ div.append('<div class="ke-name" title="' + data.filename + '">' + data.filename + '</div>');
7030
+ }
7031
+ }
7032
+ viewTypeBox.val(viewType);
7033
+ reloadPage('', orderTypeBox.val(), viewType == 'VIEW' ? createView : createList);
7034
+ return dialog;
7035
+ }
7036
+ });
7037
+
7038
+ /*******************************************************************************
7039
+ * KindEditor - WYSIWYG HTML Editor for Internet
7040
+ * Copyright (C) 2006-2011 kindsoft.net
7041
+ *
7042
+ * @author Roddy <luolonghao@gmail.com>
7043
+ * @site http://www.kindsoft.net/
7044
+ * @licence http://www.kindsoft.net/license.php
7045
+ *******************************************************************************/
7046
+ KindEditor.plugin('flash', function(K) {
7047
+ var self = this, name = 'flash', lang = self.lang(name + '.'),
7048
+ allowFlashUpload = K.undef(self.allowFlashUpload, true),
7049
+ allowFileManager = K.undef(self.allowFileManager, false),
7050
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
7051
+ extraParams = K.undef(self.extraFileUploadParams, {}),
7052
+ filePostName = K.undef(self.filePostName, 'imgFile'),
7053
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
7054
+ self.plugin.flash = {
7055
+ edit : function() {
7056
+ var html = [
7057
+ '<div style="padding:20px;">',
7058
+ '<div class="ke-dialog-row">',
7059
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
7060
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
7061
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
7062
+ '<span class="ke-button-common ke-button-outer">',
7063
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
7064
+ '</span>',
7065
+ '</div>',
7066
+ '<div class="ke-dialog-row">',
7067
+ '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
7068
+ '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ',
7069
+ '</div>',
7070
+ '<div class="ke-dialog-row">',
7071
+ '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
7072
+ '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ',
7073
+ '</div>',
7074
+ '</div>'
7075
+ ].join('');
7076
+ var dialog = self.createDialog({
7077
+ name : name,
7078
+ width : 450,
7079
+ title : self.lang(name),
7080
+ body : html,
7081
+ yesBtn : {
7082
+ name : self.lang('yes'),
7083
+ click : function(e) {
7084
+ var url = K.trim(urlBox.val()),
7085
+ width = widthBox.val(),
7086
+ height = heightBox.val();
7087
+ if (url == 'http://' || K.invalidUrl(url)) {
7088
+ alert(self.lang('invalidUrl'));
7089
+ urlBox[0].focus();
7090
+ return;
7091
+ }
7092
+ if (!/^\d*$/.test(width)) {
7093
+ alert(self.lang('invalidWidth'));
7094
+ widthBox[0].focus();
7095
+ return;
7096
+ }
7097
+ if (!/^\d*$/.test(height)) {
7098
+ alert(self.lang('invalidHeight'));
7099
+ heightBox[0].focus();
7100
+ return;
7101
+ }
7102
+ var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
7103
+ src : url,
7104
+ type : K.mediaType('.swf'),
7105
+ width : width,
7106
+ height : height,
7107
+ quality : 'high'
7108
+ });
7109
+ self.insertHtml(html).hideDialog().focus();
7110
+ }
7111
+ }
7112
+ }),
7113
+ div = dialog.div,
7114
+ urlBox = K('[name="url"]', div),
7115
+ viewServerBtn = K('[name="viewServer"]', div),
7116
+ widthBox = K('[name="width"]', div),
7117
+ heightBox = K('[name="height"]', div);
7118
+ urlBox.val('http://');
7119
+ if (allowFlashUpload) {
7120
+ var uploadbutton = K.uploadbutton({
7121
+ button : K('.ke-upload-button', div)[0],
7122
+ fieldName : filePostName,
7123
+ extraParams : extraParams,
7124
+ url : K.addParam(uploadJson, 'dir=flash'),
7125
+ afterUpload : function(data) {
7126
+ dialog.hideLoading();
7127
+ if (data.error === 0) {
7128
+ var url = data.url;
7129
+ if (formatUploadUrl) {
7130
+ url = K.formatUrl(url, 'absolute');
7131
+ }
7132
+ urlBox.val(url);
7133
+ if (self.afterUpload) {
7134
+ self.afterUpload.call(self, url, data, name);
7135
+ }
7136
+ alert(self.lang('uploadSuccess'));
7137
+ } else {
7138
+ alert(data.message);
7139
+ }
7140
+ },
7141
+ afterError : function(html) {
7142
+ dialog.hideLoading();
7143
+ self.errorDialog(html);
7144
+ }
7145
+ });
7146
+ uploadbutton.fileBox.change(function(e) {
7147
+ dialog.showLoading(self.lang('uploadLoading'));
7148
+ uploadbutton.submit();
7149
+ });
7150
+ } else {
7151
+ K('.ke-upload-button', div).hide();
7152
+ }
7153
+ if (allowFileManager) {
7154
+ viewServerBtn.click(function(e) {
7155
+ self.loadPlugin('filemanager', function() {
7156
+ self.plugin.filemanagerDialog({
7157
+ viewType : 'LIST',
7158
+ dirName : 'flash',
7159
+ clickFn : function(url, title) {
7160
+ if (self.dialogs.length > 1) {
7161
+ K('[name="url"]', div).val(url);
7162
+ if (self.afterSelectFile) {
7163
+ self.afterSelectFile.call(self, url);
7164
+ }
7165
+ self.hideDialog();
7166
+ }
7167
+ }
7168
+ });
7169
+ });
7170
+ });
7171
+ } else {
7172
+ viewServerBtn.hide();
7173
+ }
7174
+ var img = self.plugin.getSelectedFlash();
7175
+ if (img) {
7176
+ var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
7177
+ urlBox.val(attrs.src);
7178
+ widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
7179
+ heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
7180
+ }
7181
+ urlBox[0].focus();
7182
+ urlBox[0].select();
7183
+ },
7184
+ 'delete' : function() {
7185
+ self.plugin.getSelectedFlash().remove();
7186
+ self.addBookmark();
7187
+ }
7188
+ };
7189
+ self.clickToolbar(name, self.plugin.flash.edit);
7190
+ });
7191
+
7192
+ /*******************************************************************************
7193
+ * KindEditor - WYSIWYG HTML Editor for Internet
7194
+ * Copyright (C) 2006-2011 kindsoft.net
7195
+ *
7196
+ * @author Roddy <luolonghao@gmail.com>
7197
+ * @site http://www.kindsoft.net/
7198
+ * @licence http://www.kindsoft.net/license.php
7199
+ *******************************************************************************/
7200
+ KindEditor.plugin('image', function(K) {
7201
+ var self = this, name = 'image',
7202
+ allowImageUpload = K.undef(self.allowImageUpload, true),
7203
+ allowImageRemote = K.undef(self.allowImageRemote, true),
7204
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
7205
+ allowFileManager = K.undef(self.allowFileManager, false),
7206
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
7207
+ imageTabIndex = K.undef(self.imageTabIndex, 0),
7208
+ imgPath = self.pluginsPath + 'image/images/',
7209
+ extraParams = K.undef(self.extraFileUploadParams, {}),
7210
+ filePostName = K.undef(self.filePostName, 'imgFile'),
7211
+ fillDescAfterUploadImage = K.undef(self.fillDescAfterUploadImage, false),
7212
+ lang = self.lang(name + '.');
7213
+ self.plugin.imageDialog = function(options) {
7214
+ var imageUrl = options.imageUrl,
7215
+ imageWidth = K.undef(options.imageWidth, ''),
7216
+ imageHeight = K.undef(options.imageHeight, ''),
7217
+ imageTitle = K.undef(options.imageTitle, ''),
7218
+ imageAlign = K.undef(options.imageAlign, ''),
7219
+ showRemote = K.undef(options.showRemote, true),
7220
+ showLocal = K.undef(options.showLocal, true),
7221
+ tabIndex = K.undef(options.tabIndex, 0),
7222
+ clickFn = options.clickFn;
7223
+ var target = 'kindeditor_upload_iframe_' + new Date().getTime();
7224
+ var hiddenElements = [];
7225
+ for(var k in extraParams){
7226
+ hiddenElements.push('<input type="hidden" name="' + k + '" value="' + extraParams[k] + '" />');
7227
+ }
7228
+ var html = [
7229
+ '<div style="padding:20px;">',
7230
+ '<div class="tabs"></div>',
7231
+ '<div class="tab1" style="display:none;">',
7232
+ '<div class="ke-dialog-row">',
7233
+ '<label for="remoteUrl" style="width:60px;">' + lang.remoteUrl + '</label>',
7234
+ '<input type="text" id="remoteUrl" class="ke-input-text" name="url" value="" style="width:200px;" /> &nbsp;',
7235
+ '<span class="ke-button-common ke-button-outer">',
7236
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
7237
+ '</span>',
7238
+ '</div>',
7239
+ '<div class="ke-dialog-row">',
7240
+ '<label for="remoteWidth" style="width:60px;">' + lang.size + '</label>',
7241
+ lang.width + ' <input type="text" id="remoteWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> ',
7242
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> ',
7243
+ '<img class="ke-refresh-btn" src="' + imgPath + 'refresh.png" width="16" height="16" alt="" style="cursor:pointer;" title="' + lang.resetSize + '" />',
7244
+ '</div>',
7245
+ '<div class="ke-dialog-row">',
7246
+ '<label style="width:60px;">' + lang.align + '</label>',
7247
+ '<input type="radio" name="align" class="ke-inline-block" value="" checked="checked" /> <img name="defaultImg" src="' + imgPath + 'align_top.gif" width="23" height="25" alt="" />',
7248
+ ' <input type="radio" name="align" class="ke-inline-block" value="left" /> <img name="leftImg" src="' + imgPath + 'align_left.gif" width="23" height="25" alt="" />',
7249
+ ' <input type="radio" name="align" class="ke-inline-block" value="right" /> <img name="rightImg" src="' + imgPath + 'align_right.gif" width="23" height="25" alt="" />',
7250
+ '</div>',
7251
+ '<div class="ke-dialog-row">',
7252
+ '<label for="remoteTitle" style="width:60px;">' + lang.imgTitle + '</label>',
7253
+ '<input type="text" id="remoteTitle" class="ke-input-text" name="title" value="" style="width:200px;" />',
7254
+ '</div>',
7255
+ '</div>',
7256
+ '<div class="tab2" style="display:none;">',
7257
+ '<iframe name="' + target + '" style="display:none;"></iframe>',
7258
+ '<form class="ke-upload-area ke-form" method="post" enctype="multipart/form-data" target="' + target + '" action="' + K.addParam(uploadJson, 'dir=image') + '">',
7259
+ '<div class="ke-dialog-row">',
7260
+ hiddenElements.join(''),
7261
+ '<label style="width:60px;">' + lang.localUrl + '</label>',
7262
+ '<input type="text" name="localUrl" class="ke-input-text" tabindex="-1" style="width:200px;" readonly="true" /> &nbsp;',
7263
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" />',
7264
+ '</div>',
7265
+ '</form>',
7266
+ '</div>',
7267
+ '</div>'
7268
+ ].join('');
7269
+ var dialogWidth = showLocal || allowFileManager ? 450 : 400,
7270
+ dialogHeight = showLocal && showRemote ? 300 : 250;
7271
+ var dialog = self.createDialog({
7272
+ name : name,
7273
+ width : dialogWidth,
7274
+ height : dialogHeight,
7275
+ title : self.lang(name),
7276
+ body : html,
7277
+ yesBtn : {
7278
+ name : self.lang('yes'),
7279
+ click : function(e) {
7280
+ if (dialog.isLoading) {
7281
+ return;
7282
+ }
7283
+ if (showLocal && showRemote && tabs && tabs.selectedIndex === 1 || !showRemote) {
7284
+ if (uploadbutton.fileBox.val() == '') {
7285
+ alert(self.lang('pleaseSelectFile'));
7286
+ return;
7287
+ }
7288
+ dialog.showLoading(self.lang('uploadLoading'));
7289
+ uploadbutton.submit();
7290
+ localUrlBox.val('');
7291
+ return;
7292
+ }
7293
+ var url = K.trim(urlBox.val()),
7294
+ width = widthBox.val(),
7295
+ height = heightBox.val(),
7296
+ title = titleBox.val(),
7297
+ align = '';
7298
+ alignBox.each(function() {
7299
+ if (this.checked) {
7300
+ align = this.value;
7301
+ return false;
7302
+ }
7303
+ });
7304
+ if (url == 'http://' || K.invalidUrl(url)) {
7305
+ alert(self.lang('invalidUrl'));
7306
+ urlBox[0].focus();
7307
+ return;
7308
+ }
7309
+ if (!/^\d*$/.test(width)) {
7310
+ alert(self.lang('invalidWidth'));
7311
+ widthBox[0].focus();
7312
+ return;
7313
+ }
7314
+ if (!/^\d*$/.test(height)) {
7315
+ alert(self.lang('invalidHeight'));
7316
+ heightBox[0].focus();
7317
+ return;
7318
+ }
7319
+ clickFn.call(self, url, title, width, height, 0, align);
7320
+ }
7321
+ },
7322
+ beforeRemove : function() {
7323
+ viewServerBtn.unbind();
7324
+ widthBox.unbind();
7325
+ heightBox.unbind();
7326
+ refreshBtn.unbind();
7327
+ }
7328
+ }),
7329
+ div = dialog.div;
7330
+ var urlBox = K('[name="url"]', div),
7331
+ localUrlBox = K('[name="localUrl"]', div),
7332
+ viewServerBtn = K('[name="viewServer"]', div),
7333
+ widthBox = K('.tab1 [name="width"]', div),
7334
+ heightBox = K('.tab1 [name="height"]', div),
7335
+ refreshBtn = K('.ke-refresh-btn', div),
7336
+ titleBox = K('.tab1 [name="title"]', div),
7337
+ alignBox = K('.tab1 [name="align"]', div);
7338
+ var tabs;
7339
+ if (showRemote && showLocal) {
7340
+ tabs = K.tabs({
7341
+ src : K('.tabs', div),
7342
+ afterSelect : function(i) {}
7343
+ });
7344
+ tabs.add({
7345
+ title : lang.remoteImage,
7346
+ panel : K('.tab1', div)
7347
+ });
7348
+ tabs.add({
7349
+ title : lang.localImage,
7350
+ panel : K('.tab2', div)
7351
+ });
7352
+ tabs.select(tabIndex);
7353
+ } else if (showRemote) {
7354
+ K('.tab1', div).show();
7355
+ } else if (showLocal) {
7356
+ K('.tab2', div).show();
7357
+ }
7358
+ var uploadbutton = K.uploadbutton({
7359
+ button : K('.ke-upload-button', div)[0],
7360
+ fieldName : filePostName,
7361
+ form : K('.ke-form', div),
7362
+ target : target,
7363
+ width: 60,
7364
+ afterUpload : function(data) {
7365
+ dialog.hideLoading();
7366
+ if (data.error === 0) {
7367
+ var url = data.url;
7368
+ if (formatUploadUrl) {
7369
+ url = K.formatUrl(url, 'absolute');
7370
+ }
7371
+ if (self.afterUpload) {
7372
+ self.afterUpload.call(self, url, data, name);
7373
+ }
7374
+ if (!fillDescAfterUploadImage) {
7375
+ clickFn.call(self, url, data.title, data.width, data.height, data.border, data.align);
7376
+ } else {
7377
+ K(".ke-dialog-row #remoteUrl", div).val(url);
7378
+ K(".ke-tabs-li", div)[0].click();
7379
+ K(".ke-refresh-btn", div).click();
7380
+ }
7381
+ } else {
7382
+ alert(data.message);
7383
+ }
7384
+ },
7385
+ afterError : function(html) {
7386
+ dialog.hideLoading();
7387
+ self.errorDialog(html);
7388
+ }
7389
+ });
7390
+ uploadbutton.fileBox.change(function(e) {
7391
+ localUrlBox.val(uploadbutton.fileBox.val());
7392
+ });
7393
+ if (allowFileManager) {
7394
+ viewServerBtn.click(function(e) {
7395
+ self.loadPlugin('filemanager', function() {
7396
+ self.plugin.filemanagerDialog({
7397
+ viewType : 'VIEW',
7398
+ dirName : 'image',
7399
+ clickFn : function(url, title) {
7400
+ if (self.dialogs.length > 1) {
7401
+ K('[name="url"]', div).val(url);
7402
+ if (self.afterSelectFile) {
7403
+ self.afterSelectFile.call(self, url);
7404
+ }
7405
+ self.hideDialog();
7406
+ }
7407
+ }
7408
+ });
7409
+ });
7410
+ });
7411
+ } else {
7412
+ viewServerBtn.hide();
7413
+ }
7414
+ var originalWidth = 0, originalHeight = 0;
7415
+ function setSize(width, height) {
7416
+ widthBox.val(width);
7417
+ heightBox.val(height);
7418
+ originalWidth = width;
7419
+ originalHeight = height;
7420
+ }
7421
+ refreshBtn.click(function(e) {
7422
+ var tempImg = K('<img src="' + urlBox.val() + '" />', document).css({
7423
+ position : 'absolute',
7424
+ visibility : 'hidden',
7425
+ top : 0,
7426
+ left : '-1000px'
7427
+ });
7428
+ tempImg.bind('load', function() {
7429
+ setSize(tempImg.width(), tempImg.height());
7430
+ tempImg.remove();
7431
+ });
7432
+ K(document.body).append(tempImg);
7433
+ });
7434
+ widthBox.change(function(e) {
7435
+ if (originalWidth > 0) {
7436
+ heightBox.val(Math.round(originalHeight / originalWidth * parseInt(this.value, 10)));
7437
+ }
7438
+ });
7439
+ heightBox.change(function(e) {
7440
+ if (originalHeight > 0) {
7441
+ widthBox.val(Math.round(originalWidth / originalHeight * parseInt(this.value, 10)));
7442
+ }
7443
+ });
7444
+ urlBox.val(options.imageUrl);
7445
+ setSize(options.imageWidth, options.imageHeight);
7446
+ titleBox.val(options.imageTitle);
7447
+ alignBox.each(function() {
7448
+ if (this.value === options.imageAlign) {
7449
+ this.checked = true;
7450
+ return false;
7451
+ }
7452
+ });
7453
+ if (showRemote && tabIndex === 0) {
7454
+ urlBox[0].focus();
7455
+ urlBox[0].select();
7456
+ }
7457
+ return dialog;
7458
+ };
7459
+ self.plugin.image = {
7460
+ edit : function() {
7461
+ var img = self.plugin.getSelectedImage();
7462
+ self.plugin.imageDialog({
7463
+ imageUrl : img ? img.attr('data-ke-src') : 'http://',
7464
+ imageWidth : img ? img.width() : '',
7465
+ imageHeight : img ? img.height() : '',
7466
+ imageTitle : img ? img.attr('title') : '',
7467
+ imageAlign : img ? img.attr('align') : '',
7468
+ showRemote : allowImageRemote,
7469
+ showLocal : allowImageUpload,
7470
+ tabIndex: img ? 0 : imageTabIndex,
7471
+ clickFn : function(url, title, width, height, border, align) {
7472
+ if (img) {
7473
+ img.attr('src', url);
7474
+ img.attr('data-ke-src', url);
7475
+ img.attr('width', width);
7476
+ img.attr('height', height);
7477
+ img.attr('title', title);
7478
+ img.attr('align', align);
7479
+ img.attr('alt', title);
7480
+ } else {
7481
+ self.exec('insertimage', url, title, width, height, border, align);
7482
+ }
7483
+ setTimeout(function() {
7484
+ self.hideDialog().focus();
7485
+ }, 0);
7486
+ }
7487
+ });
7488
+ },
7489
+ 'delete' : function() {
7490
+ var target = self.plugin.getSelectedImage();
7491
+ if (target.parent().name == 'a') {
7492
+ target = target.parent();
7493
+ }
7494
+ target.remove();
7495
+ self.addBookmark();
7496
+ }
7497
+ };
7498
+ self.clickToolbar(name, self.plugin.image.edit);
7499
+ });
7500
+
7501
+ /*******************************************************************************
7502
+ * KindEditor - WYSIWYG HTML Editor for Internet
7503
+ * Copyright (C) 2006-2011 kindsoft.net
7504
+ *
7505
+ * @author Roddy <luolonghao@gmail.com>
7506
+ * @site http://www.kindsoft.net/
7507
+ * @licence http://www.kindsoft.net/license.php
7508
+ *******************************************************************************/
7509
+ KindEditor.plugin('insertfile', function(K) {
7510
+ var self = this, name = 'insertfile',
7511
+ allowFileUpload = K.undef(self.allowFileUpload, true),
7512
+ allowFileManager = K.undef(self.allowFileManager, false),
7513
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
7514
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
7515
+ extraParams = K.undef(self.extraFileUploadParams, {}),
7516
+ filePostName = K.undef(self.filePostName, 'imgFile'),
7517
+ lang = self.lang(name + '.');
7518
+ self.plugin.fileDialog = function(options) {
7519
+ var fileUrl = K.undef(options.fileUrl, 'http://'),
7520
+ fileTitle = K.undef(options.fileTitle, ''),
7521
+ clickFn = options.clickFn;
7522
+ var html = [
7523
+ '<div style="padding:20px;">',
7524
+ '<div class="ke-dialog-row">',
7525
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
7526
+ '<input type="text" id="keUrl" name="url" class="ke-input-text" style="width:160px;" /> &nbsp;',
7527
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
7528
+ '<span class="ke-button-common ke-button-outer">',
7529
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
7530
+ '</span>',
7531
+ '</div>',
7532
+ '<div class="ke-dialog-row">',
7533
+ '<label for="keTitle" style="width:60px;">' + lang.title + '</label>',
7534
+ '<input type="text" id="keTitle" class="ke-input-text" name="title" value="" style="width:160px;" /></div>',
7535
+ '</div>',
7536
+ '</form>',
7537
+ '</div>'
7538
+ ].join('');
7539
+ var dialog = self.createDialog({
7540
+ name : name,
7541
+ width : 450,
7542
+ title : self.lang(name),
7543
+ body : html,
7544
+ yesBtn : {
7545
+ name : self.lang('yes'),
7546
+ click : function(e) {
7547
+ var url = K.trim(urlBox.val()),
7548
+ title = titleBox.val();
7549
+ if (url == 'http://' || K.invalidUrl(url)) {
7550
+ alert(self.lang('invalidUrl'));
7551
+ urlBox[0].focus();
7552
+ return;
7553
+ }
7554
+ if (K.trim(title) === '') {
7555
+ title = url;
7556
+ }
7557
+ clickFn.call(self, url, title);
7558
+ }
7559
+ }
7560
+ }),
7561
+ div = dialog.div;
7562
+ var urlBox = K('[name="url"]', div),
7563
+ viewServerBtn = K('[name="viewServer"]', div),
7564
+ titleBox = K('[name="title"]', div);
7565
+ if (allowFileUpload) {
7566
+ var uploadbutton = K.uploadbutton({
7567
+ button : K('.ke-upload-button', div)[0],
7568
+ fieldName : filePostName,
7569
+ url : K.addParam(uploadJson, 'dir=file'),
7570
+ extraParams : extraParams,
7571
+ afterUpload : function(data) {
7572
+ dialog.hideLoading();
7573
+ if (data.error === 0) {
7574
+ var url = data.url;
7575
+ if (formatUploadUrl) {
7576
+ url = K.formatUrl(url, 'absolute');
7577
+ }
7578
+ urlBox.val(url);
7579
+ if (self.afterUpload) {
7580
+ self.afterUpload.call(self, url, data, name);
7581
+ }
7582
+ alert(self.lang('uploadSuccess'));
7583
+ } else {
7584
+ alert(data.message);
7585
+ }
7586
+ },
7587
+ afterError : function(html) {
7588
+ dialog.hideLoading();
7589
+ self.errorDialog(html);
7590
+ }
7591
+ });
7592
+ uploadbutton.fileBox.change(function(e) {
7593
+ dialog.showLoading(self.lang('uploadLoading'));
7594
+ uploadbutton.submit();
7595
+ });
7596
+ } else {
7597
+ K('.ke-upload-button', div).hide();
7598
+ }
7599
+ if (allowFileManager) {
7600
+ viewServerBtn.click(function(e) {
7601
+ self.loadPlugin('filemanager', function() {
7602
+ self.plugin.filemanagerDialog({
7603
+ viewType : 'LIST',
7604
+ dirName : 'file',
7605
+ clickFn : function(url, title) {
7606
+ if (self.dialogs.length > 1) {
7607
+ K('[name="url"]', div).val(url);
7608
+ if (self.afterSelectFile) {
7609
+ self.afterSelectFile.call(self, url);
7610
+ }
7611
+ self.hideDialog();
7612
+ }
7613
+ }
7614
+ });
7615
+ });
7616
+ });
7617
+ } else {
7618
+ viewServerBtn.hide();
7619
+ }
7620
+ urlBox.val(fileUrl);
7621
+ titleBox.val(fileTitle);
7622
+ urlBox[0].focus();
7623
+ urlBox[0].select();
7624
+ };
7625
+ self.clickToolbar(name, function() {
7626
+ self.plugin.fileDialog({
7627
+ clickFn : function(url, title) {
7628
+ var html = '<a class="ke-insertfile" href="' + url + '" data-ke-src="' + url + '" target="_blank">' + title + '</a>';
7629
+ self.insertHtml(html).hideDialog().focus();
7630
+ }
7631
+ });
7632
+ });
7633
+ });
7634
+
7635
+ /*******************************************************************************
7636
+ * KindEditor - WYSIWYG HTML Editor for Internet
7637
+ * Copyright (C) 2006-2011 kindsoft.net
7638
+ *
7639
+ * @author Roddy <luolonghao@gmail.com>
7640
+ * @site http://www.kindsoft.net/
7641
+ * @licence http://www.kindsoft.net/license.php
7642
+ *******************************************************************************/
7643
+ KindEditor.plugin('lineheight', function(K) {
7644
+ var self = this, name = 'lineheight', lang = self.lang(name + '.');
7645
+ self.clickToolbar(name, function() {
7646
+ var curVal = '', commonNode = self.cmd.commonNode({'*' : '.line-height'});
7647
+ if (commonNode) {
7648
+ curVal = commonNode.css('line-height');
7649
+ }
7650
+ var menu = self.createMenu({
7651
+ name : name,
7652
+ width : 150
7653
+ });
7654
+ K.each(lang.lineHeight, function(i, row) {
7655
+ K.each(row, function(key, val) {
7656
+ menu.addItem({
7657
+ title : val,
7658
+ checked : curVal === key,
7659
+ click : function() {
7660
+ self.cmd.toggle('<span style="line-height:' + key + ';"></span>', {
7661
+ span : '.line-height=' + key
7662
+ });
7663
+ self.updateState();
7664
+ self.addBookmark();
7665
+ self.hideMenu();
7666
+ }
7667
+ });
7668
+ });
7669
+ });
7670
+ });
7671
+ });
7672
+
7673
+ /*******************************************************************************
7674
+ * KindEditor - WYSIWYG HTML Editor for Internet
7675
+ * Copyright (C) 2006-2011 kindsoft.net
7676
+ *
7677
+ * @author Roddy <luolonghao@gmail.com>
7678
+ * @site http://www.kindsoft.net/
7679
+ * @licence http://www.kindsoft.net/license.php
7680
+ *******************************************************************************/
7681
+ KindEditor.plugin('link', function(K) {
7682
+ var self = this, name = 'link';
7683
+ self.plugin.link = {
7684
+ edit : function() {
7685
+ var lang = self.lang(name + '.'),
7686
+ html = '<div style="padding:20px;">' +
7687
+ '<div class="ke-dialog-row">' +
7688
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>' +
7689
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:260px;" /></div>' +
7690
+ '<div class="ke-dialog-row"">' +
7691
+ '<label for="keType" style="width:60px;">' + lang.linkType + '</label>' +
7692
+ '<select id="keType" name="type"></select>' +
7693
+ '</div>' +
7694
+ '</div>',
7695
+ dialog = self.createDialog({
7696
+ name : name,
7697
+ width : 450,
7698
+ title : self.lang(name),
7699
+ body : html,
7700
+ yesBtn : {
7701
+ name : self.lang('yes'),
7702
+ click : function(e) {
7703
+ var url = K.trim(urlBox.val());
7704
+ if (url == 'http://' || K.invalidUrl(url)) {
7705
+ alert(self.lang('invalidUrl'));
7706
+ urlBox[0].focus();
7707
+ return;
7708
+ }
7709
+ self.exec('createlink', url, typeBox.val()).hideDialog().focus();
7710
+ }
7711
+ }
7712
+ }),
7713
+ div = dialog.div,
7714
+ urlBox = K('input[name="url"]', div),
7715
+ typeBox = K('select[name="type"]', div);
7716
+ urlBox.val('http://');
7717
+ typeBox[0].options[0] = new Option(lang.newWindow, '_blank');
7718
+ typeBox[0].options[1] = new Option(lang.selfWindow, '');
7719
+ self.cmd.selection();
7720
+ var a = self.plugin.getSelectedLink();
7721
+ if (a) {
7722
+ self.cmd.range.selectNode(a[0]);
7723
+ self.cmd.select();
7724
+ urlBox.val(a.attr('data-ke-src'));
7725
+ typeBox.val(a.attr('target'));
7726
+ }
7727
+ urlBox[0].focus();
7728
+ urlBox[0].select();
7729
+ },
7730
+ 'delete' : function() {
7731
+ self.exec('unlink', null);
7732
+ }
7733
+ };
7734
+ self.clickToolbar(name, self.plugin.link.edit);
7735
+ });
7736
+
7737
+ /*******************************************************************************
7738
+ * KindEditor - WYSIWYG HTML Editor for Internet
7739
+ * Copyright (C) 2006-2011 kindsoft.net
7740
+ *
7741
+ * @author Roddy <luolonghao@gmail.com>
7742
+ * @site http://www.kindsoft.net/
7743
+ * @licence http://www.kindsoft.net/license.php
7744
+ *******************************************************************************/
7745
+ KindEditor.plugin('media', function(K) {
7746
+ var self = this, name = 'media', lang = self.lang(name + '.'),
7747
+ allowMediaUpload = K.undef(self.allowMediaUpload, true),
7748
+ allowFileManager = K.undef(self.allowFileManager, false),
7749
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
7750
+ extraParams = K.undef(self.extraFileUploadParams, {}),
7751
+ filePostName = K.undef(self.filePostName, 'imgFile'),
7752
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
7753
+ self.plugin.media = {
7754
+ edit : function() {
7755
+ var html = [
7756
+ '<div style="padding:20px;">',
7757
+ '<div class="ke-dialog-row">',
7758
+ '<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
7759
+ '<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> &nbsp;',
7760
+ '<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> &nbsp;',
7761
+ '<span class="ke-button-common ke-button-outer">',
7762
+ '<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
7763
+ '</span>',
7764
+ '</div>',
7765
+ '<div class="ke-dialog-row">',
7766
+ '<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
7767
+ '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />',
7768
+ '</div>',
7769
+ '<div class="ke-dialog-row">',
7770
+ '<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
7771
+ '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
7772
+ '</div>',
7773
+ '<div class="ke-dialog-row">',
7774
+ '<label for="keAutostart">' + lang.autostart + '</label>',
7775
+ '<input type="checkbox" id="keAutostart" name="autostart" value="" /> ',
7776
+ '</div>',
7777
+ '</div>'
7778
+ ].join('');
7779
+ var dialog = self.createDialog({
7780
+ name : name,
7781
+ width : 450,
7782
+ height : 230,
7783
+ title : self.lang(name),
7784
+ body : html,
7785
+ yesBtn : {
7786
+ name : self.lang('yes'),
7787
+ click : function(e) {
7788
+ var url = K.trim(urlBox.val()),
7789
+ width = widthBox.val(),
7790
+ height = heightBox.val();
7791
+ if (url == 'http://' || K.invalidUrl(url)) {
7792
+ alert(self.lang('invalidUrl'));
7793
+ urlBox[0].focus();
7794
+ return;
7795
+ }
7796
+ if (!/^\d*$/.test(width)) {
7797
+ alert(self.lang('invalidWidth'));
7798
+ widthBox[0].focus();
7799
+ return;
7800
+ }
7801
+ if (!/^\d*$/.test(height)) {
7802
+ alert(self.lang('invalidHeight'));
7803
+ heightBox[0].focus();
7804
+ return;
7805
+ }
7806
+ var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
7807
+ src : url,
7808
+ type : K.mediaType(url),
7809
+ width : width,
7810
+ height : height,
7811
+ autostart : autostartBox[0].checked ? 'true' : 'false',
7812
+ loop : 'true'
7813
+ });
7814
+ self.insertHtml(html).hideDialog().focus();
7815
+ }
7816
+ }
7817
+ }),
7818
+ div = dialog.div,
7819
+ urlBox = K('[name="url"]', div),
7820
+ viewServerBtn = K('[name="viewServer"]', div),
7821
+ widthBox = K('[name="width"]', div),
7822
+ heightBox = K('[name="height"]', div),
7823
+ autostartBox = K('[name="autostart"]', div);
7824
+ urlBox.val('http://');
7825
+ if (allowMediaUpload) {
7826
+ var uploadbutton = K.uploadbutton({
7827
+ button : K('.ke-upload-button', div)[0],
7828
+ fieldName : filePostName,
7829
+ extraParams : extraParams,
7830
+ url : K.addParam(uploadJson, 'dir=media'),
7831
+ afterUpload : function(data) {
7832
+ dialog.hideLoading();
7833
+ if (data.error === 0) {
7834
+ var url = data.url;
7835
+ if (formatUploadUrl) {
7836
+ url = K.formatUrl(url, 'absolute');
7837
+ }
7838
+ urlBox.val(url);
7839
+ if (self.afterUpload) {
7840
+ self.afterUpload.call(self, url, data, name);
7841
+ }
7842
+ alert(self.lang('uploadSuccess'));
7843
+ } else {
7844
+ alert(data.message);
7845
+ }
7846
+ },
7847
+ afterError : function(html) {
7848
+ dialog.hideLoading();
7849
+ self.errorDialog(html);
7850
+ }
7851
+ });
7852
+ uploadbutton.fileBox.change(function(e) {
7853
+ dialog.showLoading(self.lang('uploadLoading'));
7854
+ uploadbutton.submit();
7855
+ });
7856
+ } else {
7857
+ K('.ke-upload-button', div).hide();
7858
+ }
7859
+ if (allowFileManager) {
7860
+ viewServerBtn.click(function(e) {
7861
+ self.loadPlugin('filemanager', function() {
7862
+ self.plugin.filemanagerDialog({
7863
+ viewType : 'LIST',
7864
+ dirName : 'media',
7865
+ clickFn : function(url, title) {
7866
+ if (self.dialogs.length > 1) {
7867
+ K('[name="url"]', div).val(url);
7868
+ if (self.afterSelectFile) {
7869
+ self.afterSelectFile.call(self, url);
7870
+ }
7871
+ self.hideDialog();
7872
+ }
7873
+ }
7874
+ });
7875
+ });
7876
+ });
7877
+ } else {
7878
+ viewServerBtn.hide();
7879
+ }
7880
+ var img = self.plugin.getSelectedMedia();
7881
+ if (img) {
7882
+ var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
7883
+ urlBox.val(attrs.src);
7884
+ widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
7885
+ heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
7886
+ autostartBox[0].checked = (attrs.autostart === 'true');
7887
+ }
7888
+ urlBox[0].focus();
7889
+ urlBox[0].select();
7890
+ },
7891
+ 'delete' : function() {
7892
+ self.plugin.getSelectedMedia().remove();
7893
+ self.addBookmark();
7894
+ }
7895
+ };
7896
+ self.clickToolbar(name, self.plugin.media.edit);
7897
+ });
7898
+
7899
+ /*******************************************************************************
7900
+ * KindEditor - WYSIWYG HTML Editor for Internet
7901
+ * Copyright (C) 2006-2011 kindsoft.net
7902
+ *
7903
+ * @author Roddy <luolonghao@gmail.com>
7904
+ * @site http://www.kindsoft.net/
7905
+ * @licence http://www.kindsoft.net/license.php
7906
+ *******************************************************************************/
7907
+ (function(K) {
7908
+ function KSWFUpload(options) {
7909
+ this.init(options);
7910
+ }
7911
+ K.extend(KSWFUpload, {
7912
+ init : function(options) {
7913
+ var self = this;
7914
+ options.afterError = options.afterError || function(str) {
7915
+ alert(str);
7916
+ };
7917
+ self.options = options;
7918
+ self.progressbars = {};
7919
+ self.div = K(options.container).html([
7920
+ '<div class="ke-swfupload">',
7921
+ '<div class="ke-swfupload-top">',
7922
+ '<div class="ke-inline-block ke-swfupload-button">',
7923
+ '<input type="button" value="Browse" />',
7924
+ '</div>',
7925
+ '<div class="ke-inline-block ke-swfupload-desc">' + options.uploadDesc + '</div>',
7926
+ '<span class="ke-button-common ke-button-outer ke-swfupload-startupload">',
7927
+ '<input type="button" class="ke-button-common ke-button" value="' + options.startButtonValue + '" />',
7928
+ '</span>',
7929
+ '</div>',
7930
+ '<div class="ke-swfupload-body"></div>',
7931
+ '</div>'
7932
+ ].join(''));
7933
+ self.bodyDiv = K('.ke-swfupload-body', self.div);
7934
+ function showError(itemDiv, msg) {
7935
+ K('.ke-status > div', itemDiv).hide();
7936
+ K('.ke-message', itemDiv).addClass('ke-error').show().html(K.escape(msg));
7937
+ }
7938
+ var settings = {
7939
+ debug : false,
7940
+ upload_url : options.uploadUrl,
7941
+ flash_url : options.flashUrl,
7942
+ file_post_name : options.filePostName,
7943
+ button_placeholder : K('.ke-swfupload-button > input', self.div)[0],
7944
+ button_image_url: options.buttonImageUrl,
7945
+ button_width: options.buttonWidth,
7946
+ button_height: options.buttonHeight,
7947
+ button_cursor : SWFUpload.CURSOR.HAND,
7948
+ file_types : options.fileTypes,
7949
+ file_types_description : options.fileTypesDesc,
7950
+ file_upload_limit : options.fileUploadLimit,
7951
+ file_size_limit : options.fileSizeLimit,
7952
+ post_params : options.postParams,
7953
+ file_queued_handler : function(file) {
7954
+ file.url = self.options.fileIconUrl;
7955
+ self.appendFile(file);
7956
+ },
7957
+ file_queue_error_handler : function(file, errorCode, message) {
7958
+ var errorName = '';
7959
+ switch (errorCode) {
7960
+ case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
7961
+ errorName = options.queueLimitExceeded;
7962
+ break;
7963
+ case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
7964
+ errorName = options.fileExceedsSizeLimit;
7965
+ break;
7966
+ case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
7967
+ errorName = options.zeroByteFile;
7968
+ break;
7969
+ case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
7970
+ errorName = options.invalidFiletype;
7971
+ break;
7972
+ default:
7973
+ errorName = options.unknownError;
7974
+ break;
7975
+ }
7976
+ K.DEBUG && alert(errorName);
7977
+ },
7978
+ upload_start_handler : function(file) {
7979
+ var self = this;
7980
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv);
7981
+ K('.ke-status > div', itemDiv).hide();
7982
+ K('.ke-progressbar', itemDiv).show();
7983
+ },
7984
+ upload_progress_handler : function(file, bytesLoaded, bytesTotal) {
7985
+ var percent = Math.round(bytesLoaded * 100 / bytesTotal);
7986
+ var progressbar = self.progressbars[file.id];
7987
+ progressbar.bar.css('width', Math.round(percent * 80 / 100) + 'px');
7988
+ progressbar.percent.html(percent + '%');
7989
+ },
7990
+ upload_error_handler : function(file, errorCode, message) {
7991
+ if (file && file.filestatus == SWFUpload.FILE_STATUS.ERROR) {
7992
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
7993
+ showError(itemDiv, self.options.errorMessage);
7994
+ }
7995
+ },
7996
+ upload_success_handler : function(file, serverData) {
7997
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
7998
+ var data = {};
7999
+ try {
8000
+ data = K.json(serverData);
8001
+ } catch (e) {
8002
+ self.options.afterError.call(this, '<!doctype html><html>' + serverData + '</html>');
8003
+ }
8004
+ if (data.error !== 0) {
8005
+ showError(itemDiv, K.DEBUG ? data.message : self.options.errorMessage);
8006
+ return;
8007
+ }
8008
+ file.url = data.url;
8009
+ K('.ke-img', itemDiv).attr('src', file.url).attr('data-status', file.filestatus).data('data', data);
8010
+ K('.ke-status > div', itemDiv).hide();
8011
+ }
8012
+ };
8013
+ self.swfu = new SWFUpload(settings);
8014
+ K('.ke-swfupload-startupload input', self.div).click(function() {
8015
+ self.swfu.startUpload();
8016
+ });
8017
+ },
8018
+ getUrlList : function() {
8019
+ var list = [];
8020
+ K('.ke-img', self.bodyDiv).each(function() {
8021
+ var img = K(this);
8022
+ var status = img.attr('data-status');
8023
+ if (status == SWFUpload.FILE_STATUS.COMPLETE) {
8024
+ list.push(img.data('data'));
8025
+ }
8026
+ });
8027
+ return list;
8028
+ },
8029
+ removeFile : function(fileId) {
8030
+ var self = this;
8031
+ self.swfu.cancelUpload(fileId);
8032
+ var itemDiv = K('div[data-id="' + fileId + '"]', self.bodyDiv);
8033
+ K('.ke-photo', itemDiv).unbind();
8034
+ K('.ke-delete', itemDiv).unbind();
8035
+ itemDiv.remove();
8036
+ },
8037
+ removeFiles : function() {
8038
+ var self = this;
8039
+ K('.ke-item', self.bodyDiv).each(function() {
8040
+ self.removeFile(K(this).attr('data-id'));
8041
+ });
8042
+ },
8043
+ appendFile : function(file) {
8044
+ var self = this;
8045
+ var itemDiv = K('<div class="ke-inline-block ke-item" data-id="' + file.id + '"></div>');
8046
+ self.bodyDiv.append(itemDiv);
8047
+ var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
8048
+ .mouseover(function(e) {
8049
+ K(this).addClass('ke-on');
8050
+ })
8051
+ .mouseout(function(e) {
8052
+ K(this).removeClass('ke-on');
8053
+ });
8054
+ itemDiv.append(photoDiv);
8055
+ var img = K('<img src="' + file.url + '" class="ke-img" data-status="' + file.filestatus + '" width="80" height="80" alt="' + file.name + '" />');
8056
+ photoDiv.append(img);
8057
+ K('<span class="ke-delete"></span>').appendTo(photoDiv).click(function() {
8058
+ self.removeFile(file.id);
8059
+ });
8060
+ var statusDiv = K('<div class="ke-status"></div>').appendTo(photoDiv);
8061
+ K(['<div class="ke-progressbar">',
8062
+ '<div class="ke-progressbar-bar"><div class="ke-progressbar-bar-inner"></div></div>',
8063
+ '<div class="ke-progressbar-percent">0%</div></div>'].join('')).hide().appendTo(statusDiv);
8064
+ K('<div class="ke-message">' + self.options.pendingMessage + '</div>').appendTo(statusDiv);
8065
+ itemDiv.append('<div class="ke-name">' + file.name + '</div>');
8066
+ self.progressbars[file.id] = {
8067
+ bar : K('.ke-progressbar-bar-inner', photoDiv),
8068
+ percent : K('.ke-progressbar-percent', photoDiv)
8069
+ };
8070
+ },
8071
+ remove : function() {
8072
+ this.removeFiles();
8073
+ this.swfu.destroy();
8074
+ this.div.html('');
8075
+ }
8076
+ });
8077
+ K.swfupload = function(element, options) {
8078
+ return new KSWFUpload(element, options);
8079
+ };
8080
+ })(KindEditor);
8081
+ KindEditor.plugin('multiimage', function(K) {
8082
+ var self = this, name = 'multiimage',
8083
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
8084
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
8085
+ imgPath = self.pluginsPath + 'multiimage/images/',
8086
+ imageSizeLimit = K.undef(self.imageSizeLimit, '1MB'),
8087
+ imageFileTypes = K.undef(self.imageFileTypes, '*.jpg;*.gif;*.png'),
8088
+ imageUploadLimit = K.undef(self.imageUploadLimit, 20),
8089
+ filePostName = K.undef(self.filePostName, 'imgFile'),
8090
+ lang = self.lang(name + '.');
8091
+ self.plugin.multiImageDialog = function(options) {
8092
+ var clickFn = options.clickFn,
8093
+ uploadDesc = K.tmpl(lang.uploadDesc, {uploadLimit : imageUploadLimit, sizeLimit : imageSizeLimit});
8094
+ var html = [
8095
+ '<div style="padding:20px;">',
8096
+ '<div class="swfupload">',
8097
+ '</div>',
8098
+ '</div>'
8099
+ ].join('');
8100
+ var dialog = self.createDialog({
8101
+ name : name,
8102
+ width : 650,
8103
+ height : 510,
8104
+ title : self.lang(name),
8105
+ body : html,
8106
+ previewBtn : {
8107
+ name : lang.insertAll,
8108
+ click : function(e) {
8109
+ clickFn.call(self, swfupload.getUrlList());
8110
+ }
8111
+ },
8112
+ yesBtn : {
8113
+ name : lang.clearAll,
8114
+ click : function(e) {
8115
+ swfupload.removeFiles();
8116
+ }
8117
+ },
8118
+ beforeRemove : function() {
8119
+ if (!K.IE || K.V <= 8) {
8120
+ swfupload.remove();
8121
+ }
8122
+ }
8123
+ }),
8124
+ div = dialog.div;
8125
+ var swfupload = K.swfupload({
8126
+ container : K('.swfupload', div),
8127
+ buttonImageUrl : imgPath + (self.langType == 'zh-CN' ? 'select-files-zh-CN.png' : 'select-files-en.png'),
8128
+ buttonWidth : self.langType == 'zh-CN' ? 72 : 88,
8129
+ buttonHeight : 23,
8130
+ fileIconUrl : imgPath + 'image.png',
8131
+ uploadDesc : uploadDesc,
8132
+ startButtonValue : lang.startUpload,
8133
+ uploadUrl : K.addParam(uploadJson, 'dir=image'),
8134
+ flashUrl : imgPath + 'swfupload.swf',
8135
+ filePostName : filePostName,
8136
+ fileTypes : '*.jpg;*.jpeg;*.gif;*.png;*.bmp',
8137
+ fileTypesDesc : 'Image Files',
8138
+ fileUploadLimit : imageUploadLimit,
8139
+ fileSizeLimit : imageSizeLimit,
8140
+ postParams : K.undef(self.extraFileUploadParams, {}),
8141
+ queueLimitExceeded : lang.queueLimitExceeded,
8142
+ fileExceedsSizeLimit : lang.fileExceedsSizeLimit,
8143
+ zeroByteFile : lang.zeroByteFile,
8144
+ invalidFiletype : lang.invalidFiletype,
8145
+ unknownError : lang.unknownError,
8146
+ pendingMessage : lang.pending,
8147
+ errorMessage : lang.uploadError,
8148
+ afterError : function(html) {
8149
+ self.errorDialog(html);
8150
+ }
8151
+ });
8152
+ return dialog;
8153
+ };
8154
+ self.clickToolbar(name, function() {
8155
+ self.plugin.multiImageDialog({
8156
+ clickFn : function (urlList) {
8157
+ if (urlList.length === 0) {
8158
+ return;
8159
+ }
8160
+ K.each(urlList, function(i, data) {
8161
+ if (self.afterUpload) {
8162
+ self.afterUpload.call(self, data.url, data, 'multiimage');
8163
+ }
8164
+ self.exec('insertimage', data.url, data.title, data.width, data.height, data.border, data.align);
8165
+ });
8166
+ setTimeout(function() {
8167
+ self.hideDialog().focus();
8168
+ }, 0);
8169
+ }
8170
+ });
8171
+ });
8172
+ });
8173
+ /* ******************* */
8174
+ /* Constructor & Init */
8175
+ /* ******************* */
8176
+ (function() {
8177
+ window.SWFUpload = function (settings) {
8178
+ this.initSWFUpload(settings);
8179
+ };
8180
+ SWFUpload.prototype.initSWFUpload = function (settings) {
8181
+ try {
8182
+ this.customSettings = {};
8183
+ this.settings = settings;
8184
+ this.eventQueue = [];
8185
+ this.movieName = "KindEditor_SWFUpload_" + SWFUpload.movieCount++;
8186
+ this.movieElement = null;
8187
+ SWFUpload.instances[this.movieName] = this;
8188
+ this.initSettings();
8189
+ this.loadFlash();
8190
+ this.displayDebugInfo();
8191
+ } catch (ex) {
8192
+ delete SWFUpload.instances[this.movieName];
8193
+ throw ex;
8194
+ }
8195
+ };
8196
+ /* *************** */
8197
+ /* Static Members */
8198
+ /* *************** */
8199
+ SWFUpload.instances = {};
8200
+ SWFUpload.movieCount = 0;
8201
+ SWFUpload.version = "2.2.0 2009-03-25";
8202
+ SWFUpload.QUEUE_ERROR = {
8203
+ QUEUE_LIMIT_EXCEEDED : -100,
8204
+ FILE_EXCEEDS_SIZE_LIMIT : -110,
8205
+ ZERO_BYTE_FILE : -120,
8206
+ INVALID_FILETYPE : -130
8207
+ };
8208
+ SWFUpload.UPLOAD_ERROR = {
8209
+ HTTP_ERROR : -200,
8210
+ MISSING_UPLOAD_URL : -210,
8211
+ IO_ERROR : -220,
8212
+ SECURITY_ERROR : -230,
8213
+ UPLOAD_LIMIT_EXCEEDED : -240,
8214
+ UPLOAD_FAILED : -250,
8215
+ SPECIFIED_FILE_ID_NOT_FOUND : -260,
8216
+ FILE_VALIDATION_FAILED : -270,
8217
+ FILE_CANCELLED : -280,
8218
+ UPLOAD_STOPPED : -290
8219
+ };
8220
+ SWFUpload.FILE_STATUS = {
8221
+ QUEUED : -1,
8222
+ IN_PROGRESS : -2,
8223
+ ERROR : -3,
8224
+ COMPLETE : -4,
8225
+ CANCELLED : -5
8226
+ };
8227
+ SWFUpload.BUTTON_ACTION = {
8228
+ SELECT_FILE : -100,
8229
+ SELECT_FILES : -110,
8230
+ START_UPLOAD : -120
8231
+ };
8232
+ SWFUpload.CURSOR = {
8233
+ ARROW : -1,
8234
+ HAND : -2
8235
+ };
8236
+ SWFUpload.WINDOW_MODE = {
8237
+ WINDOW : "window",
8238
+ TRANSPARENT : "transparent",
8239
+ OPAQUE : "opaque"
8240
+ };
8241
+ SWFUpload.completeURL = function(url) {
8242
+ if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
8243
+ return url;
8244
+ }
8245
+ var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
8246
+ var indexSlash = window.location.pathname.lastIndexOf("/");
8247
+ if (indexSlash <= 0) {
8248
+ path = "/";
8249
+ } else {
8250
+ path = window.location.pathname.substr(0, indexSlash) + "/";
8251
+ }
8252
+ return /*currentURL +*/ path + url;
8253
+ };
8254
+ /* ******************** */
8255
+ /* Instance Members */
8256
+ /* ******************** */
8257
+ SWFUpload.prototype.initSettings = function () {
8258
+ this.ensureDefault = function (settingName, defaultValue) {
8259
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
8260
+ };
8261
+ this.ensureDefault("upload_url", "");
8262
+ this.ensureDefault("preserve_relative_urls", false);
8263
+ this.ensureDefault("file_post_name", "Filedata");
8264
+ this.ensureDefault("post_params", {});
8265
+ this.ensureDefault("use_query_string", false);
8266
+ this.ensureDefault("requeue_on_error", false);
8267
+ this.ensureDefault("http_success", []);
8268
+ this.ensureDefault("assume_success_timeout", 0);
8269
+ this.ensureDefault("file_types", "*.*");
8270
+ this.ensureDefault("file_types_description", "All Files");
8271
+ this.ensureDefault("file_size_limit", 0);
8272
+ this.ensureDefault("file_upload_limit", 0);
8273
+ this.ensureDefault("file_queue_limit", 0);
8274
+ this.ensureDefault("flash_url", "swfupload.swf");
8275
+ this.ensureDefault("prevent_swf_caching", true);
8276
+ this.ensureDefault("button_image_url", "");
8277
+ this.ensureDefault("button_width", 1);
8278
+ this.ensureDefault("button_height", 1);
8279
+ this.ensureDefault("button_text", "");
8280
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
8281
+ this.ensureDefault("button_text_top_padding", 0);
8282
+ this.ensureDefault("button_text_left_padding", 0);
8283
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
8284
+ this.ensureDefault("button_disabled", false);
8285
+ this.ensureDefault("button_placeholder_id", "");
8286
+ this.ensureDefault("button_placeholder", null);
8287
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
8288
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
8289
+ this.ensureDefault("debug", false);
8290
+ this.settings.debug_enabled = this.settings.debug;
8291
+ this.settings.return_upload_start_handler = this.returnUploadStart;
8292
+ this.ensureDefault("swfupload_loaded_handler", null);
8293
+ this.ensureDefault("file_dialog_start_handler", null);
8294
+ this.ensureDefault("file_queued_handler", null);
8295
+ this.ensureDefault("file_queue_error_handler", null);
8296
+ this.ensureDefault("file_dialog_complete_handler", null);
8297
+ this.ensureDefault("upload_start_handler", null);
8298
+ this.ensureDefault("upload_progress_handler", null);
8299
+ this.ensureDefault("upload_error_handler", null);
8300
+ this.ensureDefault("upload_success_handler", null);
8301
+ this.ensureDefault("upload_complete_handler", null);
8302
+ this.ensureDefault("debug_handler", this.debugMessage);
8303
+ this.ensureDefault("custom_settings", {});
8304
+ this.customSettings = this.settings.custom_settings;
8305
+ if (!!this.settings.prevent_swf_caching) {
8306
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
8307
+ }
8308
+ if (!this.settings.preserve_relative_urls) {
8309
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
8310
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
8311
+ }
8312
+ delete this.ensureDefault;
8313
+ };
8314
+ SWFUpload.prototype.loadFlash = function () {
8315
+ var targetElement, tempParent;
8316
+ if (document.getElementById(this.movieName) !== null) {
8317
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
8318
+ }
8319
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
8320
+ if (targetElement == undefined) {
8321
+ throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
8322
+ }
8323
+ tempParent = document.createElement("div");
8324
+ tempParent.innerHTML = this.getFlashHTML();
8325
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
8326
+ if (window[this.movieName] == undefined) {
8327
+ window[this.movieName] = this.getMovieElement();
8328
+ }
8329
+ };
8330
+ SWFUpload.prototype.getFlashHTML = function () {
8331
+ var classid = '';
8332
+ if (KindEditor.IE && KindEditor.V > 8) {
8333
+ classid = ' classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
8334
+ }
8335
+ return ['<object id="', this.movieName, '"' + classid + ' type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
8336
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
8337
+ '<param name="movie" value="', this.settings.flash_url, '" />',
8338
+ '<param name="quality" value="high" />',
8339
+ '<param name="menu" value="false" />',
8340
+ '<param name="allowScriptAccess" value="always" />',
8341
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
8342
+ '</object>'].join("");
8343
+ };
8344
+ SWFUpload.prototype.getFlashVars = function () {
8345
+ var paramString = this.buildParamString();
8346
+ var httpSuccessString = this.settings.http_success.join(",");
8347
+ return ["movieName=", encodeURIComponent(this.movieName),
8348
+ "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
8349
+ "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
8350
+ "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
8351
+ "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
8352
+ "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
8353
+ "&amp;params=", encodeURIComponent(paramString),
8354
+ "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
8355
+ "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
8356
+ "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
8357
+ "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
8358
+ "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
8359
+ "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
8360
+ "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
8361
+ "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
8362
+ "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
8363
+ "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
8364
+ "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
8365
+ "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
8366
+ "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
8367
+ "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
8368
+ "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
8369
+ "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
8370
+ "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
8371
+ ].join("");
8372
+ };
8373
+ SWFUpload.prototype.getMovieElement = function () {
8374
+ if (this.movieElement == undefined) {
8375
+ this.movieElement = document.getElementById(this.movieName);
8376
+ }
8377
+ if (this.movieElement === null) {
8378
+ throw "Could not find Flash element";
8379
+ }
8380
+ return this.movieElement;
8381
+ };
8382
+ SWFUpload.prototype.buildParamString = function () {
8383
+ var postParams = this.settings.post_params;
8384
+ var paramStringPairs = [];
8385
+ if (typeof(postParams) === "object") {
8386
+ for (var name in postParams) {
8387
+ if (postParams.hasOwnProperty(name)) {
8388
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
8389
+ }
8390
+ }
8391
+ }
8392
+ return paramStringPairs.join("&amp;");
8393
+ };
8394
+ SWFUpload.prototype.destroy = function () {
8395
+ try {
8396
+ this.cancelUpload(null, false);
8397
+ var movieElement = null;
8398
+ movieElement = this.getMovieElement();
8399
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") {
8400
+ for (var i in movieElement) {
8401
+ try {
8402
+ if (typeof(movieElement[i]) === "function") {
8403
+ movieElement[i] = null;
8404
+ }
8405
+ } catch (ex1) {}
8406
+ }
8407
+ try {
8408
+ movieElement.parentNode.removeChild(movieElement);
8409
+ } catch (ex) {}
8410
+ }
8411
+ window[this.movieName] = null;
8412
+ SWFUpload.instances[this.movieName] = null;
8413
+ delete SWFUpload.instances[this.movieName];
8414
+ this.movieElement = null;
8415
+ this.settings = null;
8416
+ this.customSettings = null;
8417
+ this.eventQueue = null;
8418
+ this.movieName = null;
8419
+ return true;
8420
+ } catch (ex2) {
8421
+ return false;
8422
+ }
8423
+ };
8424
+ SWFUpload.prototype.displayDebugInfo = function () {
8425
+ this.debug(
8426
+ [
8427
+ "---SWFUpload Instance Info---\n",
8428
+ "Version: ", SWFUpload.version, "\n",
8429
+ "Movie Name: ", this.movieName, "\n",
8430
+ "Settings:\n",
8431
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
8432
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
8433
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
8434
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
8435
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
8436
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
8437
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
8438
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
8439
+ "\t", "file_types: ", this.settings.file_types, "\n",
8440
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
8441
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
8442
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
8443
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
8444
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
8445
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
8446
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
8447
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
8448
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
8449
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
8450
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
8451
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
8452
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
8453
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
8454
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
8455
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
8456
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
8457
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
8458
+ "Event Handlers:\n",
8459
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
8460
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
8461
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
8462
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
8463
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
8464
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
8465
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
8466
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
8467
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
8468
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
8469
+ ].join("")
8470
+ );
8471
+ };
8472
+ /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
8473
+ the maintain v2 API compatibility
8474
+ */
8475
+ SWFUpload.prototype.addSetting = function (name, value, default_value) {
8476
+ if (value == undefined) {
8477
+ return (this.settings[name] = default_value);
8478
+ } else {
8479
+ return (this.settings[name] = value);
8480
+ }
8481
+ };
8482
+ SWFUpload.prototype.getSetting = function (name) {
8483
+ if (this.settings[name] != undefined) {
8484
+ return this.settings[name];
8485
+ }
8486
+ return "";
8487
+ };
8488
+ SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
8489
+ argumentArray = argumentArray || [];
8490
+ var movieElement = this.getMovieElement();
8491
+ var returnValue, returnString;
8492
+ try {
8493
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
8494
+ returnValue = eval(returnString);
8495
+ } catch (ex) {
8496
+ throw "Call to " + functionName + " failed";
8497
+ }
8498
+ if (returnValue != undefined && typeof returnValue.post === "object") {
8499
+ returnValue = this.unescapeFilePostParams(returnValue);
8500
+ }
8501
+ return returnValue;
8502
+ };
8503
+ /* *****************************
8504
+ -- Flash control methods --
8505
+ Your UI should use these
8506
+ to operate SWFUpload
8507
+ ***************************** */
8508
+ SWFUpload.prototype.selectFile = function () {
8509
+ this.callFlash("SelectFile");
8510
+ };
8511
+ SWFUpload.prototype.selectFiles = function () {
8512
+ this.callFlash("SelectFiles");
8513
+ };
8514
+ SWFUpload.prototype.startUpload = function (fileID) {
8515
+ this.callFlash("StartUpload", [fileID]);
8516
+ };
8517
+ SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
8518
+ if (triggerErrorEvent !== false) {
8519
+ triggerErrorEvent = true;
8520
+ }
8521
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
8522
+ };
8523
+ SWFUpload.prototype.stopUpload = function () {
8524
+ this.callFlash("StopUpload");
8525
+ };
8526
+ /* ************************
8527
+ * Settings methods
8528
+ * These methods change the SWFUpload settings.
8529
+ * SWFUpload settings should not be changed directly on the settings object
8530
+ * since many of the settings need to be passed to Flash in order to take
8531
+ * effect.
8532
+ * *********************** */
8533
+ SWFUpload.prototype.getStats = function () {
8534
+ return this.callFlash("GetStats");
8535
+ };
8536
+ SWFUpload.prototype.setStats = function (statsObject) {
8537
+ this.callFlash("SetStats", [statsObject]);
8538
+ };
8539
+ SWFUpload.prototype.getFile = function (fileID) {
8540
+ if (typeof(fileID) === "number") {
8541
+ return this.callFlash("GetFileByIndex", [fileID]);
8542
+ } else {
8543
+ return this.callFlash("GetFile", [fileID]);
8544
+ }
8545
+ };
8546
+ SWFUpload.prototype.addFileParam = function (fileID, name, value) {
8547
+ return this.callFlash("AddFileParam", [fileID, name, value]);
8548
+ };
8549
+ SWFUpload.prototype.removeFileParam = function (fileID, name) {
8550
+ this.callFlash("RemoveFileParam", [fileID, name]);
8551
+ };
8552
+ SWFUpload.prototype.setUploadURL = function (url) {
8553
+ this.settings.upload_url = url.toString();
8554
+ this.callFlash("SetUploadURL", [url]);
8555
+ };
8556
+ SWFUpload.prototype.setPostParams = function (paramsObject) {
8557
+ this.settings.post_params = paramsObject;
8558
+ this.callFlash("SetPostParams", [paramsObject]);
8559
+ };
8560
+ SWFUpload.prototype.addPostParam = function (name, value) {
8561
+ this.settings.post_params[name] = value;
8562
+ this.callFlash("SetPostParams", [this.settings.post_params]);
8563
+ };
8564
+ SWFUpload.prototype.removePostParam = function (name) {
8565
+ delete this.settings.post_params[name];
8566
+ this.callFlash("SetPostParams", [this.settings.post_params]);
8567
+ };
8568
+ SWFUpload.prototype.setFileTypes = function (types, description) {
8569
+ this.settings.file_types = types;
8570
+ this.settings.file_types_description = description;
8571
+ this.callFlash("SetFileTypes", [types, description]);
8572
+ };
8573
+ SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
8574
+ this.settings.file_size_limit = fileSizeLimit;
8575
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
8576
+ };
8577
+ SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
8578
+ this.settings.file_upload_limit = fileUploadLimit;
8579
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
8580
+ };
8581
+ SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
8582
+ this.settings.file_queue_limit = fileQueueLimit;
8583
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
8584
+ };
8585
+ SWFUpload.prototype.setFilePostName = function (filePostName) {
8586
+ this.settings.file_post_name = filePostName;
8587
+ this.callFlash("SetFilePostName", [filePostName]);
8588
+ };
8589
+ SWFUpload.prototype.setUseQueryString = function (useQueryString) {
8590
+ this.settings.use_query_string = useQueryString;
8591
+ this.callFlash("SetUseQueryString", [useQueryString]);
8592
+ };
8593
+ SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
8594
+ this.settings.requeue_on_error = requeueOnError;
8595
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
8596
+ };
8597
+ SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
8598
+ if (typeof http_status_codes === "string") {
8599
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
8600
+ }
8601
+ this.settings.http_success = http_status_codes;
8602
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
8603
+ };
8604
+ SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
8605
+ this.settings.assume_success_timeout = timeout_seconds;
8606
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
8607
+ };
8608
+ SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
8609
+ this.settings.debug_enabled = debugEnabled;
8610
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
8611
+ };
8612
+ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
8613
+ if (buttonImageURL == undefined) {
8614
+ buttonImageURL = "";
8615
+ }
8616
+ this.settings.button_image_url = buttonImageURL;
8617
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
8618
+ };
8619
+ SWFUpload.prototype.setButtonDimensions = function (width, height) {
8620
+ this.settings.button_width = width;
8621
+ this.settings.button_height = height;
8622
+ var movie = this.getMovieElement();
8623
+ if (movie != undefined) {
8624
+ movie.style.width = width + "px";
8625
+ movie.style.height = height + "px";
8626
+ }
8627
+ this.callFlash("SetButtonDimensions", [width, height]);
8628
+ };
8629
+ SWFUpload.prototype.setButtonText = function (html) {
8630
+ this.settings.button_text = html;
8631
+ this.callFlash("SetButtonText", [html]);
8632
+ };
8633
+ SWFUpload.prototype.setButtonTextPadding = function (left, top) {
8634
+ this.settings.button_text_top_padding = top;
8635
+ this.settings.button_text_left_padding = left;
8636
+ this.callFlash("SetButtonTextPadding", [left, top]);
8637
+ };
8638
+ SWFUpload.prototype.setButtonTextStyle = function (css) {
8639
+ this.settings.button_text_style = css;
8640
+ this.callFlash("SetButtonTextStyle", [css]);
8641
+ };
8642
+ SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
8643
+ this.settings.button_disabled = isDisabled;
8644
+ this.callFlash("SetButtonDisabled", [isDisabled]);
8645
+ };
8646
+ SWFUpload.prototype.setButtonAction = function (buttonAction) {
8647
+ this.settings.button_action = buttonAction;
8648
+ this.callFlash("SetButtonAction", [buttonAction]);
8649
+ };
8650
+ SWFUpload.prototype.setButtonCursor = function (cursor) {
8651
+ this.settings.button_cursor = cursor;
8652
+ this.callFlash("SetButtonCursor", [cursor]);
8653
+ };
8654
+ /* *******************************
8655
+ Flash Event Interfaces
8656
+ These functions are used by Flash to trigger the various
8657
+ events.
8658
+ All these functions a Private.
8659
+ Because the ExternalInterface library is buggy the event calls
8660
+ are added to a queue and the queue then executed by a setTimeout.
8661
+ This ensures that events are executed in a determinate order and that
8662
+ the ExternalInterface bugs are avoided.
8663
+ ******************************* */
8664
+ SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
8665
+ if (argumentArray == undefined) {
8666
+ argumentArray = [];
8667
+ } else if (!(argumentArray instanceof Array)) {
8668
+ argumentArray = [argumentArray];
8669
+ }
8670
+ var self = this;
8671
+ if (typeof this.settings[handlerName] === "function") {
8672
+ this.eventQueue.push(function () {
8673
+ this.settings[handlerName].apply(this, argumentArray);
8674
+ });
8675
+ setTimeout(function () {
8676
+ self.executeNextEvent();
8677
+ }, 0);
8678
+ } else if (this.settings[handlerName] !== null) {
8679
+ throw "Event handler " + handlerName + " is unknown or is not a function";
8680
+ }
8681
+ };
8682
+ SWFUpload.prototype.executeNextEvent = function () {
8683
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
8684
+ if (typeof(f) === "function") {
8685
+ f.apply(this);
8686
+ }
8687
+ };
8688
+ SWFUpload.prototype.unescapeFilePostParams = function (file) {
8689
+ var reg = /[$]([0-9a-f]{4})/i;
8690
+ var unescapedPost = {};
8691
+ var uk;
8692
+ if (file != undefined) {
8693
+ for (var k in file.post) {
8694
+ if (file.post.hasOwnProperty(k)) {
8695
+ uk = k;
8696
+ var match;
8697
+ while ((match = reg.exec(uk)) !== null) {
8698
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
8699
+ }
8700
+ unescapedPost[uk] = file.post[k];
8701
+ }
8702
+ }
8703
+ file.post = unescapedPost;
8704
+ }
8705
+ return file;
8706
+ };
8707
+ SWFUpload.prototype.testExternalInterface = function () {
8708
+ try {
8709
+ return this.callFlash("TestExternalInterface");
8710
+ } catch (ex) {
8711
+ return false;
8712
+ }
8713
+ };
8714
+ SWFUpload.prototype.flashReady = function () {
8715
+ var movieElement = this.getMovieElement();
8716
+ if (!movieElement) {
8717
+ this.debug("Flash called back ready but the flash movie can't be found.");
8718
+ return;
8719
+ }
8720
+ this.cleanUp(movieElement);
8721
+ this.queueEvent("swfupload_loaded_handler");
8722
+ };
8723
+ SWFUpload.prototype.cleanUp = function (movieElement) {
8724
+ try {
8725
+ if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") {
8726
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
8727
+ for (var key in movieElement) {
8728
+ try {
8729
+ if (typeof(movieElement[key]) === "function") {
8730
+ movieElement[key] = null;
8731
+ }
8732
+ } catch (ex) {
8733
+ }
8734
+ }
8735
+ }
8736
+ } catch (ex1) {
8737
+ }
8738
+ window["__flash__removeCallback"] = function (instance, name) {
8739
+ try {
8740
+ if (instance) {
8741
+ instance[name] = null;
8742
+ }
8743
+ } catch (flashEx) {
8744
+ }
8745
+ };
8746
+ };
8747
+ /* This is a chance to do something before the browse window opens */
8748
+ SWFUpload.prototype.fileDialogStart = function () {
8749
+ this.queueEvent("file_dialog_start_handler");
8750
+ };
8751
+ /* Called when a file is successfully added to the queue. */
8752
+ SWFUpload.prototype.fileQueued = function (file) {
8753
+ file = this.unescapeFilePostParams(file);
8754
+ this.queueEvent("file_queued_handler", file);
8755
+ };
8756
+ /* Handle errors that occur when an attempt to queue a file fails. */
8757
+ SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
8758
+ file = this.unescapeFilePostParams(file);
8759
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
8760
+ };
8761
+ /* Called after the file dialog has closed and the selected files have been queued.
8762
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
8763
+ SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
8764
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
8765
+ };
8766
+ SWFUpload.prototype.uploadStart = function (file) {
8767
+ file = this.unescapeFilePostParams(file);
8768
+ this.queueEvent("return_upload_start_handler", file);
8769
+ };
8770
+ SWFUpload.prototype.returnUploadStart = function (file) {
8771
+ var returnValue;
8772
+ if (typeof this.settings.upload_start_handler === "function") {
8773
+ file = this.unescapeFilePostParams(file);
8774
+ returnValue = this.settings.upload_start_handler.call(this, file);
8775
+ } else if (this.settings.upload_start_handler != undefined) {
8776
+ throw "upload_start_handler must be a function";
8777
+ }
8778
+ if (returnValue === undefined) {
8779
+ returnValue = true;
8780
+ }
8781
+ returnValue = !!returnValue;
8782
+ this.callFlash("ReturnUploadStart", [returnValue]);
8783
+ };
8784
+ SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
8785
+ file = this.unescapeFilePostParams(file);
8786
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
8787
+ };
8788
+ SWFUpload.prototype.uploadError = function (file, errorCode, message) {
8789
+ file = this.unescapeFilePostParams(file);
8790
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
8791
+ };
8792
+ SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
8793
+ file = this.unescapeFilePostParams(file);
8794
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
8795
+ };
8796
+ SWFUpload.prototype.uploadComplete = function (file) {
8797
+ file = this.unescapeFilePostParams(file);
8798
+ this.queueEvent("upload_complete_handler", file);
8799
+ };
8800
+ /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
8801
+ internal debug console. You can override this event and have messages written where you want. */
8802
+ SWFUpload.prototype.debug = function (message) {
8803
+ this.queueEvent("debug_handler", message);
8804
+ };
8805
+ /* **********************************
8806
+ Debug Console
8807
+ The debug console is a self contained, in page location
8808
+ for debug message to be sent. The Debug Console adds
8809
+ itself to the body if necessary.
8810
+ The console is automatically scrolled as messages appear.
8811
+ If you are using your own debug handler or when you deploy to production and
8812
+ have debug disabled you can remove these functions to reduce the file size
8813
+ and complexity.
8814
+ ********************************** */
8815
+ SWFUpload.prototype.debugMessage = function (message) {
8816
+ if (this.settings.debug) {
8817
+ var exceptionMessage, exceptionValues = [];
8818
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
8819
+ for (var key in message) {
8820
+ if (message.hasOwnProperty(key)) {
8821
+ exceptionValues.push(key + ": " + message[key]);
8822
+ }
8823
+ }
8824
+ exceptionMessage = exceptionValues.join("\n") || "";
8825
+ exceptionValues = exceptionMessage.split("\n");
8826
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
8827
+ SWFUpload.Console.writeLine(exceptionMessage);
8828
+ } else {
8829
+ SWFUpload.Console.writeLine(message);
8830
+ }
8831
+ }
8832
+ };
8833
+ SWFUpload.Console = {};
8834
+ SWFUpload.Console.writeLine = function (message) {
8835
+ var console, documentForm;
8836
+ try {
8837
+ console = document.getElementById("SWFUpload_Console");
8838
+ if (!console) {
8839
+ documentForm = document.createElement("form");
8840
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
8841
+ console = document.createElement("textarea");
8842
+ console.id = "SWFUpload_Console";
8843
+ console.style.fontFamily = "monospace";
8844
+ console.setAttribute("wrap", "off");
8845
+ console.wrap = "off";
8846
+ console.style.overflow = "auto";
8847
+ console.style.width = "700px";
8848
+ console.style.height = "350px";
8849
+ console.style.margin = "5px";
8850
+ documentForm.appendChild(console);
8851
+ }
8852
+ console.value += message + "\n";
8853
+ console.scrollTop = console.scrollHeight - console.clientHeight;
8854
+ } catch (ex) {
8855
+ alert("Exception: " + ex.name + " Message: " + ex.message);
8856
+ }
8857
+ };
8858
+ })();
8859
+ (function() {
8860
+ /*
8861
+ Queue Plug-in
8862
+ Features:
8863
+ *Adds a cancelQueue() method for cancelling the entire queue.
8864
+ *All queued files are uploaded when startUpload() is called.
8865
+ *If false is returned from uploadComplete then the queue upload is stopped.
8866
+ If false is not returned (strict comparison) then the queue upload is continued.
8867
+ *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
8868
+ Set the event handler with the queue_complete_handler setting.
8869
+ */
8870
+ if (typeof(SWFUpload) === "function") {
8871
+ SWFUpload.queue = {};
8872
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
8873
+ return function () {
8874
+ if (typeof(oldInitSettings) === "function") {
8875
+ oldInitSettings.call(this);
8876
+ }
8877
+ this.queueSettings = {};
8878
+ this.queueSettings.queue_cancelled_flag = false;
8879
+ this.queueSettings.queue_upload_count = 0;
8880
+ this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
8881
+ this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
8882
+ this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
8883
+ this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
8884
+ this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
8885
+ };
8886
+ })(SWFUpload.prototype.initSettings);
8887
+ SWFUpload.prototype.startUpload = function (fileID) {
8888
+ this.queueSettings.queue_cancelled_flag = false;
8889
+ this.callFlash("StartUpload", [fileID]);
8890
+ };
8891
+ SWFUpload.prototype.cancelQueue = function () {
8892
+ this.queueSettings.queue_cancelled_flag = true;
8893
+ this.stopUpload();
8894
+ var stats = this.getStats();
8895
+ while (stats.files_queued > 0) {
8896
+ this.cancelUpload();
8897
+ stats = this.getStats();
8898
+ }
8899
+ };
8900
+ SWFUpload.queue.uploadStartHandler = function (file) {
8901
+ var returnValue;
8902
+ if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
8903
+ returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
8904
+ }
8905
+ returnValue = (returnValue === false) ? false : true;
8906
+ this.queueSettings.queue_cancelled_flag = !returnValue;
8907
+ return returnValue;
8908
+ };
8909
+ SWFUpload.queue.uploadCompleteHandler = function (file) {
8910
+ var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
8911
+ var continueUpload;
8912
+ if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
8913
+ this.queueSettings.queue_upload_count++;
8914
+ }
8915
+ if (typeof(user_upload_complete_handler) === "function") {
8916
+ continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
8917
+ } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
8918
+ continueUpload = false;
8919
+ } else {
8920
+ continueUpload = true;
8921
+ }
8922
+ if (continueUpload) {
8923
+ var stats = this.getStats();
8924
+ if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
8925
+ this.startUpload();
8926
+ } else if (this.queueSettings.queue_cancelled_flag === false) {
8927
+ this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
8928
+ this.queueSettings.queue_upload_count = 0;
8929
+ } else {
8930
+ this.queueSettings.queue_cancelled_flag = false;
8931
+ this.queueSettings.queue_upload_count = 0;
8932
+ }
8933
+ }
8934
+ };
8935
+ }
8936
+ })();
8937
+
8938
+ /*******************************************************************************
8939
+ * KindEditor - WYSIWYG HTML Editor for Internet
8940
+ * Copyright (C) 2006-2011 kindsoft.net
8941
+ *
8942
+ * @author Roddy <luolonghao@gmail.com>
8943
+ * @site http://www.kindsoft.net/
8944
+ * @licence http://www.kindsoft.net/license.php
8945
+ *******************************************************************************/
8946
+ KindEditor.plugin('pagebreak', function(K) {
8947
+ var self = this;
8948
+ var name = 'pagebreak';
8949
+ var pagebreakHtml = K.undef(self.pagebreakHtml, '<hr style="page-break-after: always;" class="ke-pagebreak" />');
8950
+ self.clickToolbar(name, function() {
8951
+ var cmd = self.cmd, range = cmd.range;
8952
+ self.focus();
8953
+ var tail = self.newlineTag == 'br' || K.WEBKIT ? '' : '<span id="__kindeditor_tail_tag__"></span>';
8954
+ self.insertHtml(pagebreakHtml + tail);
8955
+ if (tail !== '') {
8956
+ var p = K('#__kindeditor_tail_tag__', self.edit.doc);
8957
+ range.selectNodeContents(p[0]);
8958
+ p.removeAttr('id');
8959
+ cmd.select();
8960
+ }
8961
+ });
8962
+ });
8963
+
8964
+ /*******************************************************************************
8965
+ * KindEditor - WYSIWYG HTML Editor for Internet
8966
+ * Copyright (C) 2006-2011 kindsoft.net
8967
+ *
8968
+ * @author Roddy <luolonghao@gmail.com>
8969
+ * @site http://www.kindsoft.net/
8970
+ * @licence http://www.kindsoft.net/license.php
8971
+ *******************************************************************************/
8972
+ KindEditor.plugin('plainpaste', function(K) {
8973
+ var self = this, name = 'plainpaste';
8974
+ self.clickToolbar(name, function() {
8975
+ var lang = self.lang(name + '.'),
8976
+ html = '<div style="padding:10px 20px;">' +
8977
+ '<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
8978
+ '<textarea class="ke-textarea" style="width:408px;height:260px;"></textarea>' +
8979
+ '</div>',
8980
+ dialog = self.createDialog({
8981
+ name : name,
8982
+ width : 450,
8983
+ title : self.lang(name),
8984
+ body : html,
8985
+ yesBtn : {
8986
+ name : self.lang('yes'),
8987
+ click : function(e) {
8988
+ var html = textarea.val();
8989
+ html = K.escape(html);
8990
+ html = html.replace(/ {2}/g, ' &nbsp;');
8991
+ if (self.newlineTag == 'p') {
8992
+ html = html.replace(/^/, '<p>').replace(/$/, '</p>').replace(/\n/g, '</p><p>');
8993
+ } else {
8994
+ html = html.replace(/\n/g, '<br />$&');
8995
+ }
8996
+ self.insertHtml(html).hideDialog().focus();
8997
+ }
8998
+ }
8999
+ }),
9000
+ textarea = K('textarea', dialog.div);
9001
+ textarea[0].focus();
9002
+ });
9003
+ });
9004
+
9005
+ /*******************************************************************************
9006
+ * KindEditor - WYSIWYG HTML Editor for Internet
9007
+ * Copyright (C) 2006-2011 kindsoft.net
9008
+ *
9009
+ * @author Roddy <luolonghao@gmail.com>
9010
+ * @site http://www.kindsoft.net/
9011
+ * @licence http://www.kindsoft.net/license.php
9012
+ *******************************************************************************/
9013
+ KindEditor.plugin('preview', function(K) {
9014
+ var self = this, name = 'preview', undefined;
9015
+ self.clickToolbar(name, function() {
9016
+ var lang = self.lang(name + '.'),
9017
+ html = '<div style="padding:10px 20px;">' +
9018
+ '<iframe class="ke-textarea" frameborder="0" style="width:708px;height:400px;"></iframe>' +
9019
+ '</div>',
9020
+ dialog = self.createDialog({
9021
+ name : name,
9022
+ width : 750,
9023
+ title : self.lang(name),
9024
+ body : html
9025
+ }),
9026
+ iframe = K('iframe', dialog.div),
9027
+ doc = K.iframeDoc(iframe);
9028
+ doc.open();
9029
+ doc.write(self.fullHtml());
9030
+ doc.close();
9031
+ K(doc.body).css('background-color', '#FFF');
9032
+ iframe[0].contentWindow.focus();
9033
+ });
9034
+ });
9035
+
9036
+ /*******************************************************************************
9037
+ * KindEditor - WYSIWYG HTML Editor for Internet
9038
+ * Copyright (C) 2006-2011 kindsoft.net
9039
+ *
9040
+ * @author Roddy <luolonghao@gmail.com>
9041
+ * @site http://www.kindsoft.net/
9042
+ * @licence http://www.kindsoft.net/license.php
9043
+ *******************************************************************************/
9044
+ KindEditor.plugin('quickformat', function(K) {
9045
+ var self = this, name = 'quickformat',
9046
+ blockMap = K.toMap('blockquote,center,div,h1,h2,h3,h4,h5,h6,p');
9047
+ function getFirstChild(knode) {
9048
+ var child = knode.first();
9049
+ while (child && child.first()) {
9050
+ child = child.first();
9051
+ }
9052
+ return child;
9053
+ }
9054
+ self.clickToolbar(name, function() {
9055
+ self.focus();
9056
+ var doc = self.edit.doc,
9057
+ range = self.cmd.range,
9058
+ child = K(doc.body).first(), next,
9059
+ nodeList = [], subList = [],
9060
+ bookmark = range.createBookmark(true);
9061
+ while(child) {
9062
+ next = child.next();
9063
+ var firstChild = getFirstChild(child);
9064
+ if (!firstChild || firstChild.name != 'img') {
9065
+ if (blockMap[child.name]) {
9066
+ child.html(child.html().replace(/^(\s|&nbsp;| )+/ig, ''));
9067
+ child.css('text-indent', '2em');
9068
+ } else {
9069
+ subList.push(child);
9070
+ }
9071
+ if (!next || (blockMap[next.name] || blockMap[child.name] && !blockMap[next.name])) {
9072
+ if (subList.length > 0) {
9073
+ nodeList.push(subList);
9074
+ }
9075
+ subList = [];
9076
+ }
9077
+ }
9078
+ child = next;
9079
+ }
9080
+ K.each(nodeList, function(i, subList) {
9081
+ var wrapper = K('<p style="text-indent:2em;"></p>', doc);
9082
+ subList[0].before(wrapper);
9083
+ K.each(subList, function(i, knode) {
9084
+ wrapper.append(knode);
9085
+ });
9086
+ });
9087
+ range.moveToBookmark(bookmark);
9088
+ self.addBookmark();
9089
+ });
9090
+ });
9091
+
9092
+ /*******************************************************************************
9093
+ * KindEditor - WYSIWYG HTML Editor for Internet
9094
+ * Copyright (C) 2006-2011 kindsoft.net
9095
+ *
9096
+ * @author Roddy <luolonghao@gmail.com>
9097
+ * @site http://www.kindsoft.net/
9098
+ * @licence http://www.kindsoft.net/license.php
9099
+ *******************************************************************************/
9100
+ KindEditor.plugin('table', function(K) {
9101
+ var self = this, name = 'table', lang = self.lang(name + '.'), zeroborder = 'ke-zeroborder';
9102
+ function _setColor(box, color) {
9103
+ color = color.toUpperCase();
9104
+ box.css('background-color', color);
9105
+ box.css('color', color === '#000000' ? '#FFFFFF' : '#000000');
9106
+ box.html(color);
9107
+ }
9108
+ var pickerList = [];
9109
+ function _initColorPicker(dialogDiv, colorBox) {
9110
+ colorBox.bind('click,mousedown', function(e){
9111
+ e.stopPropagation();
9112
+ });
9113
+ function removePicker() {
9114
+ K.each(pickerList, function() {
9115
+ this.remove();
9116
+ });
9117
+ pickerList = [];
9118
+ K(document).unbind('click,mousedown', removePicker);
9119
+ dialogDiv.unbind('click,mousedown', removePicker);
9120
+ }
9121
+ colorBox.click(function(e) {
9122
+ removePicker();
9123
+ var box = K(this),
9124
+ pos = box.pos();
9125
+ var picker = K.colorpicker({
9126
+ x : pos.x,
9127
+ y : pos.y + box.height(),
9128
+ z : 811214,
9129
+ selectedColor : K(this).html(),
9130
+ colors : self.colorTable,
9131
+ noColor : self.lang('noColor'),
9132
+ shadowMode : self.shadowMode,
9133
+ click : function(color) {
9134
+ _setColor(box, color);
9135
+ removePicker();
9136
+ }
9137
+ });
9138
+ pickerList.push(picker);
9139
+ K(document).bind('click,mousedown', removePicker);
9140
+ dialogDiv.bind('click,mousedown', removePicker);
9141
+ });
9142
+ }
9143
+ function _getCellIndex(table, row, cell) {
9144
+ var rowSpanCount = 0;
9145
+ for (var i = 0, len = row.cells.length; i < len; i++) {
9146
+ if (row.cells[i] == cell) {
9147
+ break;
9148
+ }
9149
+ rowSpanCount += row.cells[i].rowSpan - 1;
9150
+ }
9151
+ return cell.cellIndex - rowSpanCount;
9152
+ }
9153
+ self.plugin.table = {
9154
+ prop : function(isInsert) {
9155
+ var html = [
9156
+ '<div style="padding:20px;">',
9157
+ '<div class="ke-dialog-row">',
9158
+ '<label for="keRows" style="width:90px;">' + lang.cells + '</label>',
9159
+ lang.rows + ' <input type="text" id="keRows" class="ke-input-text ke-input-number" name="rows" value="" maxlength="4" /> &nbsp; ',
9160
+ lang.cols + ' <input type="text" class="ke-input-text ke-input-number" name="cols" value="" maxlength="4" />',
9161
+ '</div>',
9162
+ '<div class="ke-dialog-row">',
9163
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
9164
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
9165
+ '<select name="widthType">',
9166
+ '<option value="%">' + lang.percent + '</option>',
9167
+ '<option value="px">' + lang.px + '</option>',
9168
+ '</select> &nbsp; ',
9169
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
9170
+ '<select name="heightType">',
9171
+ '<option value="%">' + lang.percent + '</option>',
9172
+ '<option value="px">' + lang.px + '</option>',
9173
+ '</select>',
9174
+ '</div>',
9175
+ '<div class="ke-dialog-row">',
9176
+ '<label for="kePadding" style="width:90px;">' + lang.space + '</label>',
9177
+ lang.padding + ' <input type="text" id="kePadding" class="ke-input-text ke-input-number" name="padding" value="" maxlength="4" /> &nbsp; ',
9178
+ lang.spacing + ' <input type="text" class="ke-input-text ke-input-number" name="spacing" value="" maxlength="4" />',
9179
+ '</div>',
9180
+ '<div class="ke-dialog-row">',
9181
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
9182
+ '<select id="keAlign" name="align">',
9183
+ '<option value="">' + lang.alignDefault + '</option>',
9184
+ '<option value="left">' + lang.alignLeft + '</option>',
9185
+ '<option value="center">' + lang.alignCenter + '</option>',
9186
+ '<option value="right">' + lang.alignRight + '</option>',
9187
+ '</select>',
9188
+ '</div>',
9189
+ '<div class="ke-dialog-row">',
9190
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
9191
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
9192
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
9193
+ '</div>',
9194
+ '<div class="ke-dialog-row">',
9195
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
9196
+ '<span class="ke-inline-block ke-input-color"></span>',
9197
+ '</div>',
9198
+ '</div>'
9199
+ ].join('');
9200
+ var bookmark = self.cmd.range.createBookmark();
9201
+ var dialog = self.createDialog({
9202
+ name : name,
9203
+ width : 500,
9204
+ title : self.lang(name),
9205
+ body : html,
9206
+ beforeRemove : function() {
9207
+ colorBox.unbind();
9208
+ },
9209
+ yesBtn : {
9210
+ name : self.lang('yes'),
9211
+ click : function(e) {
9212
+ var rows = rowsBox.val(),
9213
+ cols = colsBox.val(),
9214
+ width = widthBox.val(),
9215
+ height = heightBox.val(),
9216
+ widthType = widthTypeBox.val(),
9217
+ heightType = heightTypeBox.val(),
9218
+ padding = paddingBox.val(),
9219
+ spacing = spacingBox.val(),
9220
+ align = alignBox.val(),
9221
+ border = borderBox.val(),
9222
+ borderColor = K(colorBox[0]).html() || '',
9223
+ bgColor = K(colorBox[1]).html() || '';
9224
+ if (rows == 0 || !/^\d+$/.test(rows)) {
9225
+ alert(self.lang('invalidRows'));
9226
+ rowsBox[0].focus();
9227
+ return;
9228
+ }
9229
+ if (cols == 0 || !/^\d+$/.test(cols)) {
9230
+ alert(self.lang('invalidRows'));
9231
+ colsBox[0].focus();
9232
+ return;
9233
+ }
9234
+ if (!/^\d*$/.test(width)) {
9235
+ alert(self.lang('invalidWidth'));
9236
+ widthBox[0].focus();
9237
+ return;
9238
+ }
9239
+ if (!/^\d*$/.test(height)) {
9240
+ alert(self.lang('invalidHeight'));
9241
+ heightBox[0].focus();
9242
+ return;
9243
+ }
9244
+ if (!/^\d*$/.test(padding)) {
9245
+ alert(self.lang('invalidPadding'));
9246
+ paddingBox[0].focus();
9247
+ return;
9248
+ }
9249
+ if (!/^\d*$/.test(spacing)) {
9250
+ alert(self.lang('invalidSpacing'));
9251
+ spacingBox[0].focus();
9252
+ return;
9253
+ }
9254
+ if (!/^\d*$/.test(border)) {
9255
+ alert(self.lang('invalidBorder'));
9256
+ borderBox[0].focus();
9257
+ return;
9258
+ }
9259
+ if (table) {
9260
+ if (width !== '') {
9261
+ table.width(width + widthType);
9262
+ } else {
9263
+ table.css('width', '');
9264
+ }
9265
+ if (table[0].width !== undefined) {
9266
+ table.removeAttr('width');
9267
+ }
9268
+ if (height !== '') {
9269
+ table.height(height + heightType);
9270
+ } else {
9271
+ table.css('height', '');
9272
+ }
9273
+ if (table[0].height !== undefined) {
9274
+ table.removeAttr('height');
9275
+ }
9276
+ table.css('background-color', bgColor);
9277
+ if (table[0].bgColor !== undefined) {
9278
+ table.removeAttr('bgColor');
9279
+ }
9280
+ if (padding !== '') {
9281
+ table[0].cellPadding = padding;
9282
+ } else {
9283
+ table.removeAttr('cellPadding');
9284
+ }
9285
+ if (spacing !== '') {
9286
+ table[0].cellSpacing = spacing;
9287
+ } else {
9288
+ table.removeAttr('cellSpacing');
9289
+ }
9290
+ if (align !== '') {
9291
+ table[0].align = align;
9292
+ } else {
9293
+ table.removeAttr('align');
9294
+ }
9295
+ if (border !== '') {
9296
+ table.attr('border', border);
9297
+ } else {
9298
+ table.removeAttr('border');
9299
+ }
9300
+ if (border === '' || border === '0') {
9301
+ table.addClass(zeroborder);
9302
+ } else {
9303
+ table.removeClass(zeroborder);
9304
+ }
9305
+ if (borderColor !== '') {
9306
+ table.attr('borderColor', borderColor);
9307
+ } else {
9308
+ table.removeAttr('borderColor');
9309
+ }
9310
+ self.hideDialog().focus();
9311
+ self.cmd.range.moveToBookmark(bookmark);
9312
+ self.cmd.select();
9313
+ self.addBookmark();
9314
+ return;
9315
+ }
9316
+ var style = '';
9317
+ if (width !== '') {
9318
+ style += 'width:' + width + widthType + ';';
9319
+ }
9320
+ if (height !== '') {
9321
+ style += 'height:' + height + heightType + ';';
9322
+ }
9323
+ if (bgColor !== '') {
9324
+ style += 'background-color:' + bgColor + ';';
9325
+ }
9326
+ var html = '<table';
9327
+ if (style !== '') {
9328
+ html += ' style="' + style + '"';
9329
+ }
9330
+ if (padding !== '') {
9331
+ html += ' cellpadding="' + padding + '"';
9332
+ }
9333
+ if (spacing !== '') {
9334
+ html += ' cellspacing="' + spacing + '"';
9335
+ }
9336
+ if (align !== '') {
9337
+ html += ' align="' + align + '"';
9338
+ }
9339
+ if (border !== '') {
9340
+ html += ' border="' + border + '"';
9341
+ }
9342
+ if (border === '' || border === '0') {
9343
+ html += ' class="' + zeroborder + '"';
9344
+ }
9345
+ if (borderColor !== '') {
9346
+ html += ' bordercolor="' + borderColor + '"';
9347
+ }
9348
+ html += '>';
9349
+ for (var i = 0; i < rows; i++) {
9350
+ html += '<tr>';
9351
+ for (var j = 0; j < cols; j++) {
9352
+ html += '<td>' + (K.IE ? '&nbsp;' : '<br />') + '</td>';
9353
+ }
9354
+ html += '</tr>';
9355
+ }
9356
+ html += '</table>';
9357
+ if (!K.IE) {
9358
+ html += '<br />';
9359
+ }
9360
+ self.insertHtml(html);
9361
+ self.select().hideDialog().focus();
9362
+ self.addBookmark();
9363
+ }
9364
+ }
9365
+ }),
9366
+ div = dialog.div,
9367
+ rowsBox = K('[name="rows"]', div).val(3),
9368
+ colsBox = K('[name="cols"]', div).val(2),
9369
+ widthBox = K('[name="width"]', div).val(100),
9370
+ heightBox = K('[name="height"]', div),
9371
+ widthTypeBox = K('[name="widthType"]', div),
9372
+ heightTypeBox = K('[name="heightType"]', div),
9373
+ paddingBox = K('[name="padding"]', div).val(2),
9374
+ spacingBox = K('[name="spacing"]', div).val(0),
9375
+ alignBox = K('[name="align"]', div),
9376
+ borderBox = K('[name="border"]', div).val(1),
9377
+ colorBox = K('.ke-input-color', div);
9378
+ _initColorPicker(div, colorBox.eq(0));
9379
+ _initColorPicker(div, colorBox.eq(1));
9380
+ _setColor(colorBox.eq(0), '#000000');
9381
+ _setColor(colorBox.eq(1), '');
9382
+ rowsBox[0].focus();
9383
+ rowsBox[0].select();
9384
+ var table;
9385
+ if (isInsert) {
9386
+ return;
9387
+ }
9388
+ table = self.plugin.getSelectedTable();
9389
+ if (table) {
9390
+ rowsBox.val(table[0].rows.length);
9391
+ colsBox.val(table[0].rows.length > 0 ? table[0].rows[0].cells.length : 0);
9392
+ rowsBox.attr('disabled', true);
9393
+ colsBox.attr('disabled', true);
9394
+ var match,
9395
+ tableWidth = table[0].style.width || table[0].width,
9396
+ tableHeight = table[0].style.height || table[0].height;
9397
+ if (tableWidth !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableWidth))) {
9398
+ widthBox.val(match[1]);
9399
+ widthTypeBox.val(match[2]);
9400
+ } else {
9401
+ widthBox.val('');
9402
+ }
9403
+ if (tableHeight !== undefined && (match = /^(\d+)((?:px|%)*)$/.exec(tableHeight))) {
9404
+ heightBox.val(match[1]);
9405
+ heightTypeBox.val(match[2]);
9406
+ }
9407
+ paddingBox.val(table[0].cellPadding || '');
9408
+ spacingBox.val(table[0].cellSpacing || '');
9409
+ alignBox.val(table[0].align || '');
9410
+ borderBox.val(table[0].border === undefined ? '' : table[0].border);
9411
+ _setColor(colorBox.eq(0), K.toHex(table.attr('borderColor') || ''));
9412
+ _setColor(colorBox.eq(1), K.toHex(table[0].style.backgroundColor || table[0].bgColor || ''));
9413
+ widthBox[0].focus();
9414
+ widthBox[0].select();
9415
+ }
9416
+ },
9417
+ cellprop : function() {
9418
+ var html = [
9419
+ '<div style="padding:20px;">',
9420
+ '<div class="ke-dialog-row">',
9421
+ '<label for="keWidth" style="width:90px;">' + lang.size + '</label>',
9422
+ lang.width + ' <input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="" maxlength="4" /> &nbsp; ',
9423
+ '<select name="widthType">',
9424
+ '<option value="%">' + lang.percent + '</option>',
9425
+ '<option value="px">' + lang.px + '</option>',
9426
+ '</select> &nbsp; ',
9427
+ lang.height + ' <input type="text" class="ke-input-text ke-input-number" name="height" value="" maxlength="4" /> &nbsp; ',
9428
+ '<select name="heightType">',
9429
+ '<option value="%">' + lang.percent + '</option>',
9430
+ '<option value="px">' + lang.px + '</option>',
9431
+ '</select>',
9432
+ '</div>',
9433
+ '<div class="ke-dialog-row">',
9434
+ '<label for="keAlign" style="width:90px;">' + lang.align + '</label>',
9435
+ lang.textAlign + ' <select id="keAlign" name="textAlign">',
9436
+ '<option value="">' + lang.alignDefault + '</option>',
9437
+ '<option value="left">' + lang.alignLeft + '</option>',
9438
+ '<option value="center">' + lang.alignCenter + '</option>',
9439
+ '<option value="right">' + lang.alignRight + '</option>',
9440
+ '</select> ',
9441
+ lang.verticalAlign + ' <select name="verticalAlign">',
9442
+ '<option value="">' + lang.alignDefault + '</option>',
9443
+ '<option value="top">' + lang.alignTop + '</option>',
9444
+ '<option value="middle">' + lang.alignMiddle + '</option>',
9445
+ '<option value="bottom">' + lang.alignBottom + '</option>',
9446
+ '<option value="baseline">' + lang.alignBaseline + '</option>',
9447
+ '</select>',
9448
+ '</div>',
9449
+ '<div class="ke-dialog-row">',
9450
+ '<label for="keBorder" style="width:90px;">' + lang.border + '</label>',
9451
+ lang.borderWidth + ' <input type="text" id="keBorder" class="ke-input-text ke-input-number" name="border" value="" maxlength="4" /> &nbsp; ',
9452
+ lang.borderColor + ' <span class="ke-inline-block ke-input-color"></span>',
9453
+ '</div>',
9454
+ '<div class="ke-dialog-row">',
9455
+ '<label for="keBgColor" style="width:90px;">' + lang.backgroundColor + '</label>',
9456
+ '<span class="ke-inline-block ke-input-color"></span>',
9457
+ '</div>',
9458
+ '</div>'
9459
+ ].join('');
9460
+ var bookmark = self.cmd.range.createBookmark();
9461
+ var dialog = self.createDialog({
9462
+ name : name,
9463
+ width : 500,
9464
+ title : self.lang('tablecell'),
9465
+ body : html,
9466
+ beforeRemove : function() {
9467
+ colorBox.unbind();
9468
+ },
9469
+ yesBtn : {
9470
+ name : self.lang('yes'),
9471
+ click : function(e) {
9472
+ var width = widthBox.val(),
9473
+ height = heightBox.val(),
9474
+ widthType = widthTypeBox.val(),
9475
+ heightType = heightTypeBox.val(),
9476
+ padding = paddingBox.val(),
9477
+ spacing = spacingBox.val(),
9478
+ textAlign = textAlignBox.val(),
9479
+ verticalAlign = verticalAlignBox.val(),
9480
+ border = borderBox.val(),
9481
+ borderColor = K(colorBox[0]).html() || '',
9482
+ bgColor = K(colorBox[1]).html() || '';
9483
+ if (!/^\d*$/.test(width)) {
9484
+ alert(self.lang('invalidWidth'));
9485
+ widthBox[0].focus();
9486
+ return;
9487
+ }
9488
+ if (!/^\d*$/.test(height)) {
9489
+ alert(self.lang('invalidHeight'));
9490
+ heightBox[0].focus();
9491
+ return;
9492
+ }
9493
+ if (!/^\d*$/.test(border)) {
9494
+ alert(self.lang('invalidBorder'));
9495
+ borderBox[0].focus();
9496
+ return;
9497
+ }
9498
+ cell.css({
9499
+ width : width !== '' ? (width + widthType) : '',
9500
+ height : height !== '' ? (height + heightType) : '',
9501
+ 'background-color' : bgColor,
9502
+ 'text-align' : textAlign,
9503
+ 'vertical-align' : verticalAlign,
9504
+ 'border-width' : border,
9505
+ 'border-style' : border !== '' ? 'solid' : '',
9506
+ 'border-color' : borderColor
9507
+ });
9508
+ self.hideDialog().focus();
9509
+ self.cmd.range.moveToBookmark(bookmark);
9510
+ self.cmd.select();
9511
+ self.addBookmark();
9512
+ }
9513
+ }
9514
+ }),
9515
+ div = dialog.div,
9516
+ widthBox = K('[name="width"]', div).val(100),
9517
+ heightBox = K('[name="height"]', div),
9518
+ widthTypeBox = K('[name="widthType"]', div),
9519
+ heightTypeBox = K('[name="heightType"]', div),
9520
+ paddingBox = K('[name="padding"]', div).val(2),
9521
+ spacingBox = K('[name="spacing"]', div).val(0),
9522
+ textAlignBox = K('[name="textAlign"]', div),
9523
+ verticalAlignBox = K('[name="verticalAlign"]', div),
9524
+ borderBox = K('[name="border"]', div).val(1),
9525
+ colorBox = K('.ke-input-color', div);
9526
+ _initColorPicker(div, colorBox.eq(0));
9527
+ _initColorPicker(div, colorBox.eq(1));
9528
+ _setColor(colorBox.eq(0), '#000000');
9529
+ _setColor(colorBox.eq(1), '');
9530
+ widthBox[0].focus();
9531
+ widthBox[0].select();
9532
+ var cell = self.plugin.getSelectedCell();
9533
+ var match,
9534
+ cellWidth = cell[0].style.width || cell[0].width || '',
9535
+ cellHeight = cell[0].style.height || cell[0].height || '';
9536
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellWidth))) {
9537
+ widthBox.val(match[1]);
9538
+ widthTypeBox.val(match[2]);
9539
+ } else {
9540
+ widthBox.val('');
9541
+ }
9542
+ if ((match = /^(\d+)((?:px|%)*)$/.exec(cellHeight))) {
9543
+ heightBox.val(match[1]);
9544
+ heightTypeBox.val(match[2]);
9545
+ }
9546
+ textAlignBox.val(cell[0].style.textAlign || '');
9547
+ verticalAlignBox.val(cell[0].style.verticalAlign || '');
9548
+ var border = cell[0].style.borderWidth || '';
9549
+ if (border) {
9550
+ border = parseInt(border);
9551
+ }
9552
+ borderBox.val(border);
9553
+ _setColor(colorBox.eq(0), K.toHex(cell[0].style.borderColor || ''));
9554
+ _setColor(colorBox.eq(1), K.toHex(cell[0].style.backgroundColor || ''));
9555
+ widthBox[0].focus();
9556
+ widthBox[0].select();
9557
+ },
9558
+ insert : function() {
9559
+ this.prop(true);
9560
+ },
9561
+ 'delete' : function() {
9562
+ var table = self.plugin.getSelectedTable();
9563
+ self.cmd.range.setStartBefore(table[0]).collapse(true);
9564
+ self.cmd.select();
9565
+ table.remove();
9566
+ self.addBookmark();
9567
+ },
9568
+ colinsert : function(offset) {
9569
+ var table = self.plugin.getSelectedTable()[0],
9570
+ row = self.plugin.getSelectedRow()[0],
9571
+ cell = self.plugin.getSelectedCell()[0],
9572
+ index = cell.cellIndex + offset;
9573
+ index += table.rows[0].cells.length - row.cells.length;
9574
+ for (var i = 0, len = table.rows.length; i < len; i++) {
9575
+ var newRow = table.rows[i],
9576
+ newCell = newRow.insertCell(index);
9577
+ newCell.innerHTML = K.IE ? '' : '<br />';
9578
+ index = _getCellIndex(table, newRow, newCell);
9579
+ }
9580
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9581
+ self.cmd.select();
9582
+ self.addBookmark();
9583
+ },
9584
+ colinsertleft : function() {
9585
+ this.colinsert(0);
9586
+ },
9587
+ colinsertright : function() {
9588
+ this.colinsert(1);
9589
+ },
9590
+ rowinsert : function(offset) {
9591
+ var table = self.plugin.getSelectedTable()[0],
9592
+ row = self.plugin.getSelectedRow()[0],
9593
+ cell = self.plugin.getSelectedCell()[0];
9594
+ var rowIndex = row.rowIndex;
9595
+ if (offset === 1) {
9596
+ rowIndex = row.rowIndex + (cell.rowSpan - 1) + offset;
9597
+ }
9598
+ var newRow = table.insertRow(rowIndex);
9599
+ for (var i = 0, len = row.cells.length; i < len; i++) {
9600
+ if (row.cells[i].rowSpan > 1) {
9601
+ len -= row.cells[i].rowSpan - 1;
9602
+ }
9603
+ var newCell = newRow.insertCell(i);
9604
+ if (offset === 1 && row.cells[i].colSpan > 1) {
9605
+ newCell.colSpan = row.cells[i].colSpan;
9606
+ }
9607
+ newCell.innerHTML = K.IE ? '' : '<br />';
9608
+ }
9609
+ for (var j = rowIndex; j >= 0; j--) {
9610
+ var cells = table.rows[j].cells;
9611
+ if (cells.length > i) {
9612
+ for (var k = cell.cellIndex; k >= 0; k--) {
9613
+ if (cells[k].rowSpan > 1) {
9614
+ cells[k].rowSpan += 1;
9615
+ }
9616
+ }
9617
+ break;
9618
+ }
9619
+ }
9620
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9621
+ self.cmd.select();
9622
+ self.addBookmark();
9623
+ },
9624
+ rowinsertabove : function() {
9625
+ this.rowinsert(0);
9626
+ },
9627
+ rowinsertbelow : function() {
9628
+ this.rowinsert(1);
9629
+ },
9630
+ rowmerge : function() {
9631
+ var table = self.plugin.getSelectedTable()[0],
9632
+ row = self.plugin.getSelectedRow()[0],
9633
+ cell = self.plugin.getSelectedCell()[0],
9634
+ rowIndex = row.rowIndex,
9635
+ nextRowIndex = rowIndex + cell.rowSpan,
9636
+ nextRow = table.rows[nextRowIndex];
9637
+ if (table.rows.length <= nextRowIndex) {
9638
+ return;
9639
+ }
9640
+ var cellIndex = cell.cellIndex;
9641
+ if (nextRow.cells.length <= cellIndex) {
9642
+ return;
9643
+ }
9644
+ var nextCell = nextRow.cells[cellIndex];
9645
+ if (cell.colSpan !== nextCell.colSpan) {
9646
+ return;
9647
+ }
9648
+ cell.rowSpan += nextCell.rowSpan;
9649
+ nextRow.deleteCell(cellIndex);
9650
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9651
+ self.cmd.select();
9652
+ self.addBookmark();
9653
+ },
9654
+ colmerge : function() {
9655
+ var table = self.plugin.getSelectedTable()[0],
9656
+ row = self.plugin.getSelectedRow()[0],
9657
+ cell = self.plugin.getSelectedCell()[0],
9658
+ rowIndex = row.rowIndex,
9659
+ cellIndex = cell.cellIndex,
9660
+ nextCellIndex = cellIndex + 1;
9661
+ if (row.cells.length <= nextCellIndex) {
9662
+ return;
9663
+ }
9664
+ var nextCell = row.cells[nextCellIndex];
9665
+ if (cell.rowSpan !== nextCell.rowSpan) {
9666
+ return;
9667
+ }
9668
+ cell.colSpan += nextCell.colSpan;
9669
+ row.deleteCell(nextCellIndex);
9670
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9671
+ self.cmd.select();
9672
+ self.addBookmark();
9673
+ },
9674
+ rowsplit : function() {
9675
+ var table = self.plugin.getSelectedTable()[0],
9676
+ row = self.plugin.getSelectedRow()[0],
9677
+ cell = self.plugin.getSelectedCell()[0],
9678
+ rowIndex = row.rowIndex;
9679
+ if (cell.rowSpan === 1) {
9680
+ return;
9681
+ }
9682
+ var cellIndex = _getCellIndex(table, row, cell);
9683
+ for (var i = 1, len = cell.rowSpan; i < len; i++) {
9684
+ var newRow = table.rows[rowIndex + i],
9685
+ newCell = newRow.insertCell(cellIndex);
9686
+ if (cell.colSpan > 1) {
9687
+ newCell.colSpan = cell.colSpan;
9688
+ }
9689
+ newCell.innerHTML = K.IE ? '' : '<br />';
9690
+ cellIndex = _getCellIndex(table, newRow, newCell);
9691
+ }
9692
+ K(cell).removeAttr('rowSpan');
9693
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9694
+ self.cmd.select();
9695
+ self.addBookmark();
9696
+ },
9697
+ colsplit : function() {
9698
+ var table = self.plugin.getSelectedTable()[0],
9699
+ row = self.plugin.getSelectedRow()[0],
9700
+ cell = self.plugin.getSelectedCell()[0],
9701
+ cellIndex = cell.cellIndex;
9702
+ if (cell.colSpan === 1) {
9703
+ return;
9704
+ }
9705
+ for (var i = 1, len = cell.colSpan; i < len; i++) {
9706
+ var newCell = row.insertCell(cellIndex + i);
9707
+ if (cell.rowSpan > 1) {
9708
+ newCell.rowSpan = cell.rowSpan;
9709
+ }
9710
+ newCell.innerHTML = K.IE ? '' : '<br />';
9711
+ }
9712
+ K(cell).removeAttr('colSpan');
9713
+ self.cmd.range.selectNodeContents(cell).collapse(true);
9714
+ self.cmd.select();
9715
+ self.addBookmark();
9716
+ },
9717
+ coldelete : function() {
9718
+ var table = self.plugin.getSelectedTable()[0],
9719
+ row = self.plugin.getSelectedRow()[0],
9720
+ cell = self.plugin.getSelectedCell()[0],
9721
+ index = cell.cellIndex;
9722
+ for (var i = 0, len = table.rows.length; i < len; i++) {
9723
+ var newRow = table.rows[i],
9724
+ newCell = newRow.cells[index];
9725
+ if (newCell.colSpan > 1) {
9726
+ newCell.colSpan -= 1;
9727
+ if (newCell.colSpan === 1) {
9728
+ K(newCell).removeAttr('colSpan');
9729
+ }
9730
+ } else {
9731
+ newRow.deleteCell(index);
9732
+ }
9733
+ if (newCell.rowSpan > 1) {
9734
+ i += newCell.rowSpan - 1;
9735
+ }
9736
+ }
9737
+ if (row.cells.length === 0) {
9738
+ self.cmd.range.setStartBefore(table).collapse(true);
9739
+ self.cmd.select();
9740
+ K(table).remove();
9741
+ } else {
9742
+ self.cmd.selection(true);
9743
+ }
9744
+ self.addBookmark();
9745
+ },
9746
+ rowdelete : function() {
9747
+ var table = self.plugin.getSelectedTable()[0],
9748
+ row = self.plugin.getSelectedRow()[0],
9749
+ cell = self.plugin.getSelectedCell()[0],
9750
+ rowIndex = row.rowIndex;
9751
+ for (var i = cell.rowSpan - 1; i >= 0; i--) {
9752
+ table.deleteRow(rowIndex + i);
9753
+ }
9754
+ if (table.rows.length === 0) {
9755
+ self.cmd.range.setStartBefore(table).collapse(true);
9756
+ self.cmd.select();
9757
+ K(table).remove();
9758
+ } else {
9759
+ self.cmd.selection(true);
9760
+ }
9761
+ self.addBookmark();
9762
+ }
9763
+ };
9764
+ self.clickToolbar(name, self.plugin.table.prop);
9765
+ });
9766
+
9767
+ /*******************************************************************************
9768
+ * KindEditor - WYSIWYG HTML Editor for Internet
9769
+ * Copyright (C) 2006-2011 kindsoft.net
9770
+ *
9771
+ * @author Roddy <luolonghao@gmail.com>
9772
+ * @site http://www.kindsoft.net/
9773
+ * @licence http://www.kindsoft.net/license.php
9774
+ *******************************************************************************/
9775
+ KindEditor.plugin('template', function(K) {
9776
+ var self = this, name = 'template', lang = self.lang(name + '.'),
9777
+ htmlPath = self.pluginsPath + name + '/html/';
9778
+ function getFilePath(fileName) {
9779
+ return htmlPath + fileName + '?ver=' + encodeURIComponent(K.DEBUG ? K.TIME : K.VERSION);
9780
+ }
9781
+ self.clickToolbar(name, function() {
9782
+ var lang = self.lang(name + '.'),
9783
+ arr = ['<div style="padding:10px 20px;">',
9784
+ '<div class="ke-header">',
9785
+ '<div class="ke-left">',
9786
+ lang. selectTemplate + ' <select>'];
9787
+ K.each(lang.fileList, function(key, val) {
9788
+ arr.push('<option value="' + key + '">' + val + '</option>');
9789
+ });
9790
+ html = [arr.join(''),
9791
+ '</select></div>',
9792
+ '<div class="ke-right">',
9793
+ '<input type="checkbox" id="keReplaceFlag" name="replaceFlag" value="1" /> <label for="keReplaceFlag">' + lang.replaceContent + '</label>',
9794
+ '</div>',
9795
+ '<div class="ke-clearfix"></div>',
9796
+ '</div>',
9797
+ '<iframe class="ke-textarea" frameborder="0" style="width:458px;height:260px;background-color:#FFF;"></iframe>',
9798
+ '</div>'].join('');
9799
+ var dialog = self.createDialog({
9800
+ name : name,
9801
+ width : 500,
9802
+ title : self.lang(name),
9803
+ body : html,
9804
+ yesBtn : {
9805
+ name : self.lang('yes'),
9806
+ click : function(e) {
9807
+ var doc = K.iframeDoc(iframe);
9808
+ self[checkbox[0].checked ? 'html' : 'insertHtml'](doc.body.innerHTML).hideDialog().focus();
9809
+ }
9810
+ }
9811
+ });
9812
+ var selectBox = K('select', dialog.div),
9813
+ checkbox = K('[name="replaceFlag"]', dialog.div),
9814
+ iframe = K('iframe', dialog.div);
9815
+ checkbox[0].checked = true;
9816
+ iframe.attr('src', getFilePath(selectBox.val()));
9817
+ selectBox.change(function() {
9818
+ iframe.attr('src', getFilePath(this.value));
9819
+ });
9820
+ });
9821
+ });
9822
+
9823
+ /*******************************************************************************
9824
+ * KindEditor - WYSIWYG HTML Editor for Internet
9825
+ * Copyright (C) 2006-2011 kindsoft.net
9826
+ *
9827
+ * @author Roddy <luolonghao@gmail.com>
9828
+ * @site http://www.kindsoft.net/
9829
+ * @licence http://www.kindsoft.net/license.php
9830
+ *******************************************************************************/
9831
+ KindEditor.plugin('wordpaste', function(K) {
9832
+ var self = this, name = 'wordpaste';
9833
+ self.clickToolbar(name, function() {
9834
+ var lang = self.lang(name + '.'),
9835
+ html = '<div style="padding:10px 20px;">' +
9836
+ '<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
9837
+ '<iframe class="ke-textarea" frameborder="0" style="width:408px;height:260px;"></iframe>' +
9838
+ '</div>',
9839
+ dialog = self.createDialog({
9840
+ name : name,
9841
+ width : 450,
9842
+ title : self.lang(name),
9843
+ body : html,
9844
+ yesBtn : {
9845
+ name : self.lang('yes'),
9846
+ click : function(e) {
9847
+ var str = doc.body.innerHTML;
9848
+ str = K.clearMsWord(str, self.filterMode ? self.htmlTags : K.options.htmlTags);
9849
+ self.insertHtml(str).hideDialog().focus();
9850
+ }
9851
+ }
9852
+ }),
9853
+ div = dialog.div,
9854
+ iframe = K('iframe', div),
9855
+ doc = K.iframeDoc(iframe);
9856
+ if (!K.IE) {
9857
+ doc.designMode = 'on';
9858
+ }
9859
+ doc.open();
9860
+ doc.write('<!doctype html><html><head><title>WordPaste</title></head>');
9861
+ doc.write('<body style="background-color:#FFF;font-size:12px;margin:2px;">');
9862
+ if (!K.IE) {
9863
+ doc.write('<br />');
9864
+ }
9865
+ doc.write('</body></html>');
9866
+ doc.close();
9867
+ if (K.IE) {
9868
+ doc.body.contentEditable = 'true';
9869
+ }
9870
+ iframe[0].contentWindow.focus();
9871
+ });
9872
+ });
9873
+
9874
+
9875
+ KindEditor.plugin('fixtoolbar', function (K) {
9876
+ var self = this;
9877
+ if (!self.fixToolBar) {
9878
+ return;
9879
+ }
9880
+ function init() {
9881
+ var toolbar = K('.ke-toolbar');
9882
+ var originY = toolbar.pos().y;
9883
+ K(window).bind('scroll', function () {
9884
+ if (toolbar.css('position') == 'fixed') {
9885
+ if(document.body.scrollTop - originY < 0){
9886
+ toolbar.css('position', 'static');
9887
+ toolbar.css('top', 'auto');
9888
+ }
9889
+ } else {
9890
+ if (toolbar.pos().y - document.body.scrollTop < 0) {
9891
+ toolbar.css('position', 'fixed');
9892
+ toolbar.css('top', 0);
9893
+ }
9894
+ }
9895
+ });
9896
+ }
9897
+ if (self.isCreated) {
9898
+ init();
9899
+ } else {
9900
+ self.afterCreate(init);
9901
+ }
9902
+ });