rails_kindeditor 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9953e89ceb6b66c193776ef01b8dfbd0f96b7521
4
- data.tar.gz: cca4bd72c30501d0b6fd2f99357023f8239a7714
3
+ metadata.gz: 66f2473afc715a6acb5b4d9d409d8e1e954f074f
4
+ data.tar.gz: db64a6dc2c6fc7d9168c5ce6e0874983653772f3
5
5
  SHA512:
6
- metadata.gz: 411bc9ddf64d32f25478211de00c255a88ed68a9420337fb4b1a1d0e680b0b9334d42b5ea27e99ce9d8321650724e5cfbcdb6a2d6c5fcbf6d5dd08a4a4d26cea
7
- data.tar.gz: a146bc706d32f11e653228cb20e826ff2c74ebb95355ed17a9b0fdd6a1913481a553195ae6fc5df923457e1e04f350cf6248e5a02ac8f65d6e0f3523b3a6fabf
6
+ metadata.gz: 14bbd52ce96ba95977fb855182b1aa07c0c66a4737389ea22cf94ad8fcefed5eac8df8dca08828832a0f344b8cf1ae48262ac54fa38375a19110d23c1c216ebf
7
+ data.tar.gz: 1989a75fef926c16fb4451d0e23d0dea67adb57cd2d96f0d1f18b637e811ce367126c63958f1ee11ede7373134901703af5a82e39b0da3e5555e9383b7aee661
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Kindeditor for Ruby on Rails
1
+ # Kindeditor for Ruby on Rails [![Gem Version](https://badge.fury.io/rb/rails_kindeditor.png)](http://badge.fury.io/rb/rails_kindeditor)
2
2
 
3
3
  Kindeditor is a WYSIWYG javascript editor, visit http://www.kindsoft.net for details.
4
4
  rails_kindeditor will helps your rails app integrate with kindeditor, includes images and files uploading.
@@ -10,7 +10,7 @@ rails_kindeditor will helps your rails app integrate with kindeditor, includes i
10
10
  ### Add this to your Gemfile
11
11
 
12
12
  ```ruby
13
- gem 'rails_kindeditor', '~> 0.4.2'
13
+ gem 'rails_kindeditor'
14
14
  ```
15
15
 
16
16
  ### Run "bundle" command.
@@ -261,7 +261,7 @@ rails_kindeditor可以帮助你的rails程序集成kindeditor,包括了图片和
261
261
  ### 将下面代码加入Gemfile:
262
262
 
263
263
  ```ruby
264
- gem 'rails_kindeditor', '~> 0.4.2'
264
+ gem 'rails_kindeditor'
265
265
  ```
266
266
 
267
267
  ### 运行"bundle"命令:
@@ -35,8 +35,13 @@ module RailsKindeditor
35
35
  def js_replace(dom_id, options = {})
36
36
  editor_id = options[:editor_id].nil? ? '' : "#{options[:editor_id].to_s.downcase} = "
37
37
  if options[:window_onload]
38
- "window.onload = function() {
38
+ require 'SecureRandom'
39
+ random_name = SecureRandom.hex;
40
+ "var old_onload_#{random_name};
41
+ if(typeof window.onload == 'function') old_onload_#{random_name} = window.onload;
42
+ window.onload = function() {
39
43
  #{editor_id}KindEditor.create('##{dom_id}', #{get_options(options).to_json});
44
+ if(old_onload_#{random_name}) old_onload_#{random_name}();
40
45
  }"
41
46
  else
42
47
  "KindEditor.ready(function(K){
@@ -1,4 +1,4 @@
1
1
  module RailsKindeditor
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.4"
3
3
  end
4
4
 
@@ -5,7 +5,7 @@
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.9 (2013-10-08)
8
+ * @version 4.1.10 (2013-11-23)
9
9
  *******************************************************************************/
10
10
  (function (window, undefined) {
11
11
  if (window.KindEditor) {
@@ -17,9 +17,10 @@ if (!window.console) {
17
17
  if (!console.log) {
18
18
  console.log = function () {};
19
19
  }
20
- var _VERSION = '4.1.9 (2013-10-08)',
20
+ var _VERSION = '4.1.10 (2013-11-23)',
21
21
  _ua = navigator.userAgent.toLowerCase(),
22
22
  _IE = _ua.indexOf('msie') > -1 && _ua.indexOf('opera') == -1,
23
+ _NEWIE = _ua.indexOf('msie') == -1 && _ua.indexOf('trident') > -1,
23
24
  _GECKO = _ua.indexOf('gecko') > -1 && _ua.indexOf('khtml') == -1,
24
25
  _WEBKIT = _ua.indexOf('applewebkit') > -1,
25
26
  _OPERA = _ua.indexOf('opera') > -1,
@@ -213,23 +214,19 @@ var _INLINE_TAG_MAP = _toMap('a,abbr,acronym,b,basefont,bdo,big,br,button,cite,c
213
214
  _AUTOCLOSE_TAG_MAP = _toMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'),
214
215
  _FILL_ATTR_MAP = _toMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'),
215
216
  _VALUE_TAG_MAP = _toMap('input,button,textarea,select');
216
-
217
217
  // Begining of modification by Macrow
218
218
  function _getBasePath() {
219
+ var refPath = '/assets/kindeditor/';
219
220
  var els = document.getElementsByTagName('script'), src;
220
221
  for (var i = 0, len = els.length; i < len; i++) {
221
222
  src = els[i].src || '';
222
- if (/kindeditor[\w\-\.]*\.js/.test(src)) { // in development mode
223
- return src.substring(0, src.lastIndexOf('/') + 1);
224
- }
225
- if (/application[\w\-\.]*\.js/.test(src)) { // in production mode, we need application.js.
226
- return src.substring(0, src.lastIndexOf('/') + 1) + 'kindeditor/';
223
+ if (/(kindeditor|application)[\w\-\.]*\.js/.test(src)) {
224
+ return src.substring(0, src.indexOf('assets')) + refPath;
227
225
  }
228
226
  }
229
- return '/assets/kindeditor/';
227
+ return refPath;
230
228
  }
231
229
  // End of modification by Macrow
232
-
233
230
  K.basePath = _getBasePath();
234
231
  K.options = {
235
232
  designMode : true,
@@ -405,15 +402,17 @@ _extend(KEvent, {
405
402
  var ev = this.event;
406
403
  if (ev.preventDefault) {
407
404
  ev.preventDefault();
405
+ } else {
406
+ ev.returnValue = false;
408
407
  }
409
- ev.returnValue = false;
410
408
  },
411
409
  stopPropagation : function() {
412
410
  var ev = this.event;
413
411
  if (ev.stopPropagation) {
414
412
  ev.stopPropagation();
413
+ } else {
414
+ ev.cancelBubble = true;
415
415
  }
416
- ev.cancelBubble = true;
417
416
  },
418
417
  stop : function() {
419
418
  this.preventDefault();
@@ -734,7 +733,8 @@ function _formatHtml(html, htmlTags, urlType, wellFormatted, indentChar) {
734
733
  html = html.replace(/(<(?:p|p\s[^>]*)>)\s*(<\/p>)/ig, '$1<br />$2');
735
734
  html = html.replace(/\u200B/g, '');
736
735
  html = html.replace(/\u00A9/g, '&copy;');
737
- html = html.replace(/<[^>]+>/g, function($0) {
736
+ html = html.replace(/\u00AE/g, '&reg;');
737
+ html = html.replace(/<[^>]+/g, function($0) {
738
738
  return $0.replace(/\s+/g, ' ');
739
739
  });
740
740
  var htmlTagMap = {};
@@ -1280,7 +1280,7 @@ function _docWidth(doc) {
1280
1280
  function _getScrollPos(doc) {
1281
1281
  doc = doc || document;
1282
1282
  var x, y;
1283
- if (_IE || _OPERA) {
1283
+ if (_IE || _NEWIE || _OPERA) {
1284
1284
  x = _docElement(doc).scrollLeft;
1285
1285
  y = _docElement(doc).scrollTop;
1286
1286
  } else {
@@ -3110,30 +3110,19 @@ _extend(KCmd, {
3110
3110
  });
3111
3111
  },
3112
3112
  forecolor : function(val) {
3113
- return this.toggle('<span style="color:' + val + ';"></span>', {
3114
- span : '.color=' + val,
3115
- font : 'color'
3116
- });
3113
+ return this.wrap('<span style="color:' + val + ';"></span>').select();
3117
3114
  },
3118
3115
  hilitecolor : function(val) {
3119
- return this.toggle('<span style="background-color:' + val + ';"></span>', {
3120
- span : '.background-color=' + val
3121
- });
3116
+ return this.wrap('<span style="background-color:' + val + ';"></span>').select();
3122
3117
  },
3123
3118
  fontsize : function(val) {
3124
- return this.toggle('<span style="font-size:' + val + ';"></span>', {
3125
- span : '.font-size=' + val,
3126
- font : 'size'
3127
- });
3119
+ return this.wrap('<span style="font-size:' + val + ';"></span>').select();
3128
3120
  },
3129
3121
  fontname : function(val) {
3130
3122
  return this.fontfamily(val);
3131
3123
  },
3132
3124
  fontfamily : function(val) {
3133
- return this.toggle('<span style="font-family:' + val + ';"></span>', {
3134
- span : '.font-family=' + val,
3135
- font : 'face'
3136
- });
3125
+ return this.wrap('<span style="font-family:' + val + ';"></span>').select();
3137
3126
  },
3138
3127
  removeformat : function() {
3139
3128
  var map = {
@@ -3731,12 +3720,16 @@ _extend(KEdit, KWidget, {
3731
3720
  !isDocumentDomain && ready();
3732
3721
  },
3733
3722
  setWidth : function(val) {
3734
- this.div.css('width', _addUnit(val));
3735
- return this;
3723
+ var self = this;
3724
+ val = _addUnit(val);
3725
+ self.width = val;
3726
+ self.div.css('width', val);
3727
+ return self;
3736
3728
  },
3737
3729
  setHeight : function(val) {
3738
3730
  var self = this;
3739
3731
  val = _addUnit(val);
3732
+ self.height = val;
3740
3733
  self.div.css('height', val);
3741
3734
  self.iframe.css('height', val);
3742
3735
  if ((_IE && _V < 8) || _QUIRKS) {
@@ -4182,6 +4175,8 @@ _extend(KUploadButton, {
4182
4175
  self.iframe = options.target ? K('iframe[name="' + target + '"]') : K('iframe', div);
4183
4176
  self.form = options.form ? K(options.form) : K('form', div);
4184
4177
  self.fileBox = K('.ke-upload-file', div);
4178
+ var width = options.width || K('.ke-button-common', div).width();
4179
+ K('.ke-upload-area', div).width(width);
4185
4180
  self.options = options;
4186
4181
  },
4187
4182
  submit : function() {
@@ -14,31 +14,41 @@ KindEditor.plugin('autoheight', function(K) {
14
14
  return;
15
15
  }
16
16
 
17
- var edit = self.edit;
18
- var body = edit.doc.body;
19
- var minHeight = K.removeUnit(self.height);
17
+ var minHeight;
20
18
 
21
- edit.iframe[0].scroll = 'no';
22
- body.style.overflowY = 'hidden';
19
+ function hideScroll() {
20
+ var edit = self.edit;
21
+ var body = edit.doc.body;
22
+ edit.iframe[0].scroll = 'no';
23
+ body.style.overflowY = 'hidden';
24
+ }
23
25
 
24
26
  function resetHeight() {
27
+ var edit = self.edit;
28
+ var body = edit.doc.body;
25
29
  edit.iframe.height(minHeight);
26
30
  self.resize(null, Math.max((K.IE ? body.scrollHeight : body.offsetHeight) + 76, minHeight));
27
31
  }
28
32
 
29
- /*
30
- * 如何实现真正的自动高度?
31
- * 修改编辑器高度之后,再次获取body内容高度时,最小值只会是当前iframe的设置高度,这样就导致高度只增不减。
32
- * 所以每次获取body内容高度之前,先将iframe的高度重置为最小高度,这样就能获取body的实际高度。
33
- * 由此就实现了真正的自动高度
34
- * 测试:chrome、firefox、IE9、IE8
35
- * */
33
+ function init() {
34
+ minHeight = K.removeUnit(self.height);
36
35
 
37
- edit.afterChange(resetHeight);
36
+ self.edit.afterChange(resetHeight);
37
+ hideScroll();
38
+ resetHeight();
39
+ }
38
40
 
39
41
  if (self.isCreated) {
40
- resetHeight();
42
+ init();
41
43
  } else {
42
- self.afterCreate(resetHeight);
44
+ self.afterCreate(init);
43
45
  }
44
46
  });
47
+
48
+ /*
49
+ * 如何实现真正的自动高度?
50
+ * 修改编辑器高度之后,再次获取body内容高度时,最小值只会是当前iframe的设置高度,这样就导致高度只增不减。
51
+ * 所以每次获取body内容高度之前,先将iframe的高度重置为最小高度,这样就能获取body的实际高度。
52
+ * 由此就实现了真正的自动高度
53
+ * 测试:chrome、firefox、IE9、IE8
54
+ * */
@@ -862,6 +862,7 @@
862
862
  overflow: hidden;
863
863
  margin: 0;
864
864
  padding: 0;
865
+ *height: 25px;
865
866
  }
866
867
  .ke-upload-area .ke-upload-file {
867
868
  position: absolute;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_kindeditor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Macrow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-21 00:00:00.000000000 Z
11
+ date: 2013-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave