ckeditor 4.0.7 → 4.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/README.md +16 -2
  2. data/app/assets/javascripts/ckeditor/application.js +1 -0
  3. data/app/assets/javascripts/ckeditor/filebrowser/javascripts/application.js.erb +10 -0
  4. data/app/assets/javascripts/ckeditor/filebrowser/javascripts/jquery.endless-scroll.js +300 -0
  5. data/app/assets/javascripts/ckeditor/filebrowser/stylesheets/uploader.css.erb +4 -0
  6. data/app/controllers/ckeditor/attachment_files_controller.rb +3 -1
  7. data/app/controllers/ckeditor/pictures_controller.rb +3 -1
  8. data/app/views/ckeditor/attachment_files/index.html.erb +11 -5
  9. data/app/views/ckeditor/pictures/index.html.erb +12 -6
  10. data/app/views/ckeditor/shared/_asset.html.erb +1 -1
  11. data/app/views/ckeditor/shared/_asset_tmpl.html.erb +1 -1
  12. data/config/locales/cs.ckeditor.yml +1 -0
  13. data/config/locales/de.ckeditor.yml +1 -0
  14. data/config/locales/el-GR.cdkeditor.yml +2 -1
  15. data/config/locales/en.ckeditor.yml +1 -0
  16. data/config/locales/es.ckeditor.yml +1 -0
  17. data/config/locales/fr.ckeditor.yml +1 -0
  18. data/config/locales/hu.ckeditor.yml +1 -0
  19. data/config/locales/it.ckeditor.yml +1 -0
  20. data/config/locales/nl.ckeditor.yml +2 -1
  21. data/config/locales/pl.ckeditor.yml +1 -0
  22. data/config/locales/pt-BR.ckeditor.yml +2 -1
  23. data/config/locales/pt-PT.ckeditor.yml +1 -0
  24. data/config/locales/ru.ckeditor.yml +1 -0
  25. data/config/locales/sv-SE.ckeditor.yml +1 -0
  26. data/config/locales/uk.ckeditor.yml +1 -0
  27. data/config/locales/zh-CN.ckeditor.yml +1 -0
  28. data/lib/ckeditor.rb +11 -0
  29. data/lib/ckeditor/helpers/controllers.rb +1 -1
  30. data/lib/ckeditor/paginatable.rb +56 -0
  31. data/lib/ckeditor/utils.rb +41 -18
  32. data/lib/ckeditor/version.rb +2 -2
  33. data/lib/generators/ckeditor/templates/ckeditor.rb +3 -0
  34. data/test/dummy/public/uploads/tmp/20140108-1222-52217-3986/rails.tar.gz +0 -0
  35. data/test/dummy/public/uploads/tmp/20140108-1222-52217-6261/rails.tar.gz +0 -0
  36. data/test/dummy/public/uploads/tmp/20140108-1222-52217-6421/rails.tar.gz +0 -0
  37. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/content_rails.png +0 -0
  38. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/rails.png +0 -0
  39. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/thumb_rails.png +0 -0
  40. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/content_rails.png +0 -0
  41. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/rails.png +0 -0
  42. data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/thumb_rails.png +0 -0
  43. data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/content_rails.png +0 -0
  44. data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/rails.png +0 -0
  45. data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/thumb_rails.png +0 -0
  46. data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/content_rails.png +0 -0
  47. data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/rails.png +0 -0
  48. data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/thumb_rails.png +0 -0
  49. data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/content_rails.png +0 -0
  50. data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/rails.png +0 -0
  51. data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/thumb_rails.png +0 -0
  52. data/test/dummy/public/uploads/tmp/20140108-1228-52513-4718/rails.tar.gz +0 -0
  53. data/test/dummy/public/uploads/tmp/20140108-1228-52513-4820/rails.tar.gz +0 -0
  54. data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/content_rails.png +0 -0
  55. data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/rails.png +0 -0
  56. data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/thumb_rails.png +0 -0
  57. data/test/dummy/public/uploads/tmp/20140108-1228-52513-9147/rails.tar.gz +0 -0
  58. data/test/dummy/public/uploads/tmp/20140108-1228-52590-3606/rails.tar.gz +0 -0
  59. data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/content_rails.png +0 -0
  60. data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/rails.png +0 -0
  61. data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/thumb_rails.png +0 -0
  62. data/test/dummy/public/uploads/tmp/20140108-1228-52590-4698/rails.tar.gz +0 -0
  63. data/test/dummy/public/uploads/tmp/20140108-1228-52590-7541/rails.tar.gz +0 -0
  64. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/content_rails.png +0 -0
  65. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/rails.png +0 -0
  66. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/thumb_rails.png +0 -0
  67. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/content_rails.png +0 -0
  68. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/rails.png +0 -0
  69. data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/thumb_rails.png +0 -0
  70. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/content_rails.png +0 -0
  71. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/rails.png +0 -0
  72. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/thumb_rails.png +0 -0
  73. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/content_rails.png +0 -0
  74. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/rails.png +0 -0
  75. data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/thumb_rails.png +0 -0
  76. data/test/dummy/public/uploads/tmp/20140108-1230-52768-4292/rails.tar.gz +0 -0
  77. data/test/dummy/public/uploads/tmp/20140108-1230-52768-4514/rails.tar.gz +0 -0
  78. data/test/dummy/public/uploads/tmp/20140108-1230-52768-7430/rails.tar.gz +0 -0
  79. data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/content_rails.png +0 -0
  80. data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/rails.png +0 -0
  81. data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/thumb_rails.png +0 -0
  82. data/vendor/assets/javascripts/ckeditor/CHANGES.md +36 -0
  83. data/vendor/assets/javascripts/ckeditor/ckeditor.js +465 -463
  84. data/vendor/assets/javascripts/ckeditor/config.js +1 -1
  85. data/vendor/assets/javascripts/ckeditor/contents.css +17 -0
  86. data/vendor/assets/javascripts/ckeditor/lang/ca.js +1 -1
  87. data/vendor/assets/javascripts/ckeditor/lang/cs.js +1 -1
  88. data/vendor/assets/javascripts/ckeditor/lang/cy.js +1 -1
  89. data/vendor/assets/javascripts/ckeditor/lang/de.js +1 -1
  90. data/vendor/assets/javascripts/ckeditor/lang/el.js +1 -1
  91. data/vendor/assets/javascripts/ckeditor/lang/en-au.js +1 -1
  92. data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +1 -1
  93. data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +1 -1
  94. data/vendor/assets/javascripts/ckeditor/lang/es.js +1 -1
  95. data/vendor/assets/javascripts/ckeditor/lang/fi.js +1 -1
  96. data/vendor/assets/javascripts/ckeditor/lang/it.js +1 -1
  97. data/vendor/assets/javascripts/ckeditor/lang/ja.js +1 -1
  98. data/vendor/assets/javascripts/ckeditor/lang/km.js +1 -1
  99. data/vendor/assets/javascripts/ckeditor/lang/nb.js +1 -1
  100. data/vendor/assets/javascripts/ckeditor/lang/nl.js +1 -1
  101. data/vendor/assets/javascripts/ckeditor/lang/no.js +1 -1
  102. data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +1 -1
  103. data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
  104. data/vendor/assets/javascripts/ckeditor/lang/sv.js +1 -1
  105. data/vendor/assets/javascripts/ckeditor/lang/tr.js +1 -1
  106. data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +1 -1
  107. data/vendor/assets/javascripts/ckeditor/lang/zh.js +1 -1
  108. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cy.js +3 -3
  109. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fi.js +2 -2
  110. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh-cn.js +1 -1
  111. data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh.js +7 -0
  112. data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +16 -16
  113. data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/zh.js +12 -0
  114. data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +1 -1
  115. data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +31 -31
  116. data/vendor/assets/javascripts/ckeditor/samples/ajax.html +82 -0
  117. data/vendor/assets/javascripts/ckeditor/samples/api.html +207 -0
  118. data/vendor/assets/javascripts/ckeditor/samples/appendto.html +57 -0
  119. data/vendor/assets/javascripts/ckeditor/samples/assets/inlineall/logo.png +0 -0
  120. data/vendor/assets/javascripts/ckeditor/samples/assets/outputxhtml/outputxhtml.css +204 -0
  121. data/vendor/assets/javascripts/ckeditor/samples/assets/posteddata.php +59 -0
  122. data/vendor/assets/javascripts/ckeditor/samples/assets/sample.css +3 -0
  123. data/vendor/assets/javascripts/ckeditor/samples/assets/sample.jpg +0 -0
  124. data/vendor/assets/javascripts/ckeditor/samples/assets/uilanguages/languages.js +7 -0
  125. data/vendor/assets/javascripts/ckeditor/samples/datafiltering.html +401 -0
  126. data/vendor/assets/javascripts/ckeditor/samples/divreplace.html +141 -0
  127. data/vendor/assets/javascripts/ckeditor/samples/index.html +128 -0
  128. data/vendor/assets/javascripts/ckeditor/samples/inlineall.html +311 -0
  129. data/vendor/assets/javascripts/ckeditor/samples/inlinebycode.html +121 -0
  130. data/vendor/assets/javascripts/ckeditor/samples/inlinetextarea.html +110 -0
  131. data/vendor/assets/javascripts/ckeditor/samples/jquery.html +97 -0
  132. data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/assets/my_dialog.js +48 -0
  133. data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/dialog.html +187 -0
  134. data/vendor/assets/javascripts/ckeditor/samples/plugins/enterkey/enterkey.html +103 -0
  135. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.fla +0 -0
  136. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.swf +0 -0
  137. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/swfobject.js +18 -0
  138. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputforflash.html +280 -0
  139. data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputhtml.html +221 -0
  140. data/vendor/assets/javascripts/ckeditor/samples/plugins/magicline/magicline.html +206 -0
  141. data/vendor/assets/javascripts/ckeditor/samples/plugins/toolbar/toolbar.html +232 -0
  142. data/vendor/assets/javascripts/ckeditor/samples/plugins/wysiwygarea/fullpage.html +77 -0
  143. data/vendor/assets/javascripts/ckeditor/samples/readonly.html +73 -0
  144. data/vendor/assets/javascripts/ckeditor/samples/replacebyclass.html +57 -0
  145. data/vendor/assets/javascripts/ckeditor/samples/replacebycode.html +56 -0
  146. data/vendor/assets/javascripts/ckeditor/samples/sample.css +356 -0
  147. data/vendor/assets/javascripts/ckeditor/samples/sample.js +50 -0
  148. data/vendor/assets/javascripts/ckeditor/samples/sample_posteddata.php +16 -0
  149. data/vendor/assets/javascripts/ckeditor/samples/tabindex.html +75 -0
  150. data/vendor/assets/javascripts/ckeditor/samples/uicolor.html +69 -0
  151. data/vendor/assets/javascripts/ckeditor/samples/uilanguages.html +119 -0
  152. data/vendor/assets/javascripts/ckeditor/samples/xhtmlstyle.html +231 -0
  153. metadata +139 -16
  154. data/test/dummy/db/test.sqlite3 +0 -0
  155. data/test/dummy/log/test.log +0 -1425
  156. data/test/tmp/app/models/ckeditor/asset.rb +0 -5
  157. data/test/tmp/app/models/ckeditor/attachment_file.rb +0 -12
  158. data/test/tmp/app/models/ckeditor/picture.rb +0 -13
  159. data/test/tmp/config/initializers/ckeditor.rb +0 -19
  160. data/test/tmp/config/routes.rb +0 -6
data/README.md CHANGED
@@ -5,7 +5,7 @@ CKEditor is a ready-for-use HTML text editor designed to simplify web content cr
5
5
 
6
6
  ## Features
7
7
 
8
- * Ckeditor version 4.3 (full)
8
+ * Ckeditor version 4.3.1 (full)
9
9
  * Rails 4 integration
10
10
  * Files browser
11
11
  * HTML5 files uploader
@@ -150,7 +150,7 @@ You can include this rake task in a capistrano task (if you are deploying via ca
150
150
  ```ruby
151
151
  desc 'copy ckeditor nondigest assets'
152
152
  task :copy_nondigest_assets, roles: :app do
153
- run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} ckeditor:copy_nondigest_assets"
153
+ run "cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} ckeditor:create_nondigest_assets"
154
154
  end
155
155
  after 'deploy:assets:precompile', 'copy_nondigest_assets'
156
156
  ```
@@ -158,6 +158,19 @@ after 'deploy:assets:precompile', 'copy_nondigest_assets'
158
158
  Periodically check your error monitoring tool, if you see some part of ckeditor try to load
159
159
  unexisting non-digest asset - if so just add it in the ckeditor rake task.
160
160
 
161
+ Also you can use gem [non-stupid-digest-assets](https://rubygems.org/gems/non-stupid-digest-assets), which do the same work.
162
+
163
+ To reduce the asset precompilation time, you can limit plugins and/or languages to those you need:
164
+
165
+ ```ruby
166
+ # in config/initializers/ckeditor.rb
167
+
168
+ Ckeditor.setup do |config|
169
+ config.assets_languages = ['en', 'fr']
170
+ config.assets_plugins = ['image', 'smiley']
171
+ end
172
+ ```
173
+
161
174
  ### AJAX
162
175
 
163
176
  jQuery sample:
@@ -222,6 +235,7 @@ en:
222
235
  cancel: "Cancel"
223
236
  upload: "Upload"
224
237
  delete: "Delete"
238
+ next: "Next"
225
239
  ```
226
240
 
227
241
  ## Tests
@@ -1,5 +1,6 @@
1
1
  //= require ckeditor/filebrowser/javascripts/jquery.min.js
2
2
  //= require ckeditor/filebrowser/javascripts/jquery.tmpl.min.js
3
3
  //= require ckeditor/filebrowser/javascripts/fileuploader.js
4
+ //= require ckeditor/filebrowser/javascripts/jquery.endless-scroll.js
4
5
  //= require ckeditor/filebrowser/javascripts/rails.js
5
6
  //= require ckeditor/filebrowser/javascripts/application.js
@@ -27,6 +27,16 @@ $(document).ready(function(){
27
27
  $("div.gal-item a.gal-del").live('ajax:complete', function(xhr, status){
28
28
  $(this).parents('div.gal-item').remove();
29
29
  });
30
+
31
+ var endlessScroll = $.endlessScroll({
32
+ container: ".fileupload-list",
33
+ entity: ".gal-item",
34
+ scrollPadding: 100
35
+ });
36
+
37
+ // Don't listen events first second
38
+ endlessScroll.scrollModule.unbind();
39
+ window.setTimeout(function() { endlessScroll.scrollModule.bind();}, 1000);
30
40
  });
31
41
 
32
42
  // Collection of all instances on page
@@ -0,0 +1,300 @@
1
+ /**
2
+ * Author: Sergey Kukunin
3
+ * See: https://github.com/Kukunin/jquery-endless-scroll
4
+ */
5
+ (function($) {
6
+ 'use strict';
7
+
8
+ // Is pushState supported by this browser?
9
+ $.support.pushState =
10
+ window.history && window.history.pushState && window.history.replaceState &&
11
+ // pushState isn't reliable on iOS until 5.
12
+ !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/)
13
+
14
+ //Declaration of modules
15
+ var scrollModule = {
16
+ init: function(options, obj) {
17
+ obj.options = $.extend({
18
+ scrollContainer: window,
19
+ scrollPadding: 100,
20
+ scrollEventDelay: 300
21
+ }, options);
22
+ this.options = obj.options;
23
+ this.container = obj.container;
24
+ obj.scrollModule = this;
25
+
26
+ this._toplock = true;
27
+ this._bottomlock = true;
28
+
29
+ this.scrollContainer = $(this.options.scrollContainer);
30
+
31
+ this.updateEntities();
32
+ this.sortMarkers();
33
+
34
+ this.currentPage = null;
35
+
36
+ this.container.on("jes:afterPageLoad", $.proxy(function(event, url, placement) {
37
+ this.updateEntities();
38
+ this.sortMarkers();
39
+ this.checkMarker();
40
+
41
+ if ( placement == "top" ) {
42
+ //Get offset between first and second pages
43
+ var offset = this.markers[1].top,
44
+ scrollTop = this.scrollContainer.scrollTop();
45
+
46
+ this.scrollContainer.scrollTop(scrollTop + offset);
47
+ }
48
+ }, this));
49
+
50
+ this.bind();
51
+ },
52
+ updateEntities: function() {
53
+ this.entities = $(this.options.entity, this.container);
54
+ },
55
+ sortMarkers: function() {
56
+ var markers = [];
57
+ $(".jes-marker", this.container).each(function() {
58
+ markers.push({ top: $(this).position().top, url: $(this).data("jesUrl") });
59
+ });
60
+ this.markers = markers;
61
+ },
62
+ //Check, whether user scrolled to another page
63
+ checkMarker: function() {
64
+ var newPage = this.markers[0],
65
+ scrollTop = this.scrollContainer.scrollTop();
66
+
67
+ //Determine, what is current page
68
+ for ( var i = 1; i < this.markers.length; i++ ) {
69
+ if ( scrollTop > this.markers[i].top ) {
70
+ newPage = this.markers[i];
71
+ } else {
72
+ break;
73
+ }
74
+ }
75
+ if ( newPage.url != this.currentPage ) {
76
+ this.currentPage = newPage.url;
77
+ $(this.container).trigger("jes:scrollToPage", newPage.url);
78
+ }
79
+ },
80
+ bind: function() {
81
+ this.scrollContainer.on("scroll.jes", $.proxy(function(event) {
82
+ if ( this._tId ) { return; }
83
+
84
+ this.scrollHandler(event);
85
+ //Clean up mark
86
+ this._tId= setTimeout($.proxy(function(){
87
+ this._tId = null;
88
+ },this), this.options.scrollEventDelay);
89
+
90
+ }, this));
91
+ },
92
+ unbind: function() {
93
+ $(this.options.scrollContainer).off("scroll.jes");
94
+ },
95
+ scrollHandler: function(ev) {
96
+ var $scrollable = this.scrollContainer,
97
+ $entities = this.entities,
98
+ $firstEntity = $entities.first(),
99
+ $lastEntity = $entities.last();
100
+
101
+ var scrollTop = $scrollable.scrollTop(),
102
+ height = $scrollable.height(),
103
+ scrollBottom = scrollTop + height;
104
+
105
+ var topEntityPosition = $firstEntity.position().top,
106
+ topTarget = topEntityPosition + this.options.scrollPadding,
107
+ bottomEntityPosition = $lastEntity.outerHeight() + $lastEntity.position().top,
108
+ bottomTarget = bottomEntityPosition - this.options.scrollPadding;
109
+
110
+ //Don't trigger event again, if already fired
111
+ //Visitor have to leave the area and get back to fire event again
112
+ //Process top threshold
113
+ if ( scrollTop < topTarget ) {
114
+ if ( !this._toplock ) {
115
+ $(this.container).trigger("jes:topThreshold");
116
+ this._toplock = true;
117
+ }
118
+ } else {
119
+ this._toplock = false;
120
+ }
121
+
122
+ //Process bottom threshold
123
+ if ( scrollBottom > bottomTarget ) {
124
+ if ( !this._bottomlock ) {
125
+ $(this.container).trigger("jes:bottomThreshold");
126
+ this._bottomlock = true;
127
+ }
128
+ } else {
129
+ this._bottomlock = false;
130
+ }
131
+
132
+ this.checkMarker();
133
+ }
134
+ }
135
+
136
+ var ajaxModule = {
137
+ init: function(options, obj) {
138
+ obj.options = $.extend({
139
+ }, options);
140
+
141
+ this.options = obj.options;
142
+ this.container = obj.container;
143
+
144
+ //markers
145
+ this.setMarker($(this.options.entity, this.container).first(), location.href);
146
+
147
+ obj.ajaxModule = this;
148
+ },
149
+ loadPage: function(url, placement, callback) {
150
+ //The hash with methods list
151
+ //depends from placement
152
+ var actions = {
153
+ top: {
154
+ find: 'first',
155
+ inject: 'insertBefore'
156
+ },
157
+ bottom: {
158
+ find: 'last',
159
+ inject: 'insertAfter'
160
+ }
161
+ },
162
+ action = actions[placement];
163
+
164
+ this.container.trigger("jes:beforePageLoad", [url, placement]);
165
+
166
+ //Make AJAX query
167
+ $.get(url, null, $.proxy(function (_data) {
168
+ var data = $("<div>").html(_data),
169
+ containerSelector = this.options.container,
170
+ container = $(containerSelector, data).first();
171
+
172
+ if ( container.length ) {
173
+ //Find entities
174
+ var entities = container.find(this.options.entity);
175
+
176
+ if ( placement == "bottom" ) {
177
+ //Remove duplicated (staled) entities from page
178
+ entities.each(function(i) {
179
+ var id = $(this).attr("id");
180
+ if ( id ) {
181
+ $('#' + id, this.container).remove();
182
+ }
183
+ });
184
+ }
185
+
186
+ //Find the cursor
187
+ var cursor = $(this.options.entity, containerSelector)[action.find]();
188
+
189
+ //Find and insert entities
190
+ entities[action.inject](cursor);
191
+ this.setMarker(entities.first(), url);
192
+ }
193
+
194
+ if ( $.isFunction(callback) ) {
195
+ callback(data);
196
+ }
197
+ this.container.trigger("jes:afterPageLoad", [url, placement, data, entities]);
198
+ }, this), 'html');
199
+ },
200
+ setMarker: function(entity, url) {
201
+ entity.addClass("jes-marker").data("jesUrl", url);
202
+ }
203
+ }
204
+
205
+ var navigationModule = {
206
+ init: function(options, obj) {
207
+ obj.options = $.extend({
208
+ nextPage: ".pagination a[rel=next]",
209
+ previousPage: ".pagination a[rel=previous]"
210
+ }, options);
211
+
212
+ this.options = obj.options;
213
+ this.container = obj.container;
214
+
215
+ $.each([{
216
+ selector: this.options.nextPage,
217
+ event: "jes:bottomThreshold.navigation",
218
+ placement: 'bottom'
219
+ }, {
220
+ selector: this.options.previousPage,
221
+ event: "jes:topThreshold.navigation",
222
+ placement: 'top'
223
+ }], $.proxy(function(i, v) {
224
+ v.element = $(v.selector);
225
+ if ( v.element.length ) {
226
+ var url = v.element.prop("href"),
227
+ lock = false;
228
+
229
+ var handler = function() {
230
+ //this object is container
231
+ if ( lock || !url ) return;
232
+
233
+ lock = true;
234
+ obj.ajaxModule.loadPage(url, v.placement, $.proxy(function( data ) {
235
+ //Search new next link
236
+ var newElement = $(v.selector, $(data));
237
+ if ( newElement.length ) {
238
+ //Update URL and remove lock
239
+ lock = false;
240
+ url = newElement.prop("href");
241
+ v.element.attr("href", url);
242
+ } else {
243
+ //Remove event at all
244
+ $(this).off(v.event);
245
+ v.element.remove();
246
+ }
247
+ }, this));
248
+ };
249
+
250
+ $(this.container).on(v.event, handler);
251
+ $(v.element).on("click", $.proxy(function(ev) {
252
+ ev.preventDefault();
253
+ handler.apply(this.container)
254
+ }, this));
255
+ }
256
+ },this));
257
+ }
258
+ }
259
+
260
+ var pushStateHistory = {
261
+ init: function(options, obj) {
262
+ if ( !$.support.pushState ) {
263
+ return;
264
+ }
265
+
266
+ obj.container.on("jes:scrollToPage", function(event, url) {
267
+ history.replaceState({}, null, url);
268
+ });
269
+ }
270
+ }
271
+
272
+ $.endlessScroll = function(options) {
273
+
274
+ //Initialize modules
275
+ this.options = $.extend(true, {
276
+ container: "#container",
277
+ entity: ".entity",
278
+ _modules: [ ajaxModule, scrollModule, navigationModule, pushStateHistory ],
279
+ modules: []
280
+ }, options);
281
+
282
+ this.container = $(this.options.container);
283
+ if ( !this.container.length ) {
284
+ throw "Container for endless scroll isn't available on the page";
285
+ return;
286
+ }
287
+
288
+
289
+ //Merge custom options with default
290
+ $.merge(this.options.modules, this.options._modules);
291
+ //Init modules
292
+ this.options.modules.forEach($.proxy(function(module) {
293
+ module.init(this.options, this);
294
+ },this));
295
+
296
+
297
+ return this;
298
+ }
299
+
300
+ })(jQuery);
@@ -116,3 +116,7 @@ img {
116
116
  .gal-more a:hover {
117
117
  text-decoration: underline;
118
118
  }
119
+
120
+ .pagination, .pagination a {
121
+ display: none;
122
+ }
@@ -2,7 +2,9 @@ class Ckeditor::AttachmentFilesController < Ckeditor::ApplicationController
2
2
 
3
3
  def index
4
4
  @attachments = Ckeditor.attachment_file_adapter.find_all(ckeditor_attachment_files_scope)
5
- respond_with(@attachments)
5
+ @attachments = Ckeditor::Paginatable.new(@attachments).page(params[:page])
6
+
7
+ respond_with(@attachments, :layout => @attachments.first_page?)
6
8
  end
7
9
 
8
10
  def create
@@ -2,7 +2,9 @@ class Ckeditor::PicturesController < Ckeditor::ApplicationController
2
2
 
3
3
  def index
4
4
  @pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope)
5
- respond_with(@pictures)
5
+ @pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page])
6
+
7
+ respond_with(@pictures, :layout => @pictures.first_page?)
6
8
  end
7
9
 
8
10
  def create
@@ -6,10 +6,16 @@
6
6
  </div>
7
7
 
8
8
  <div class="fileupload-list">
9
- <%= render :partial => 'ckeditor/shared/asset', :collection => @attachments %>
9
+ <%= render :partial => 'ckeditor/shared/asset', :collection => @attachments.scoped %>
10
10
  </div>
11
- </div>
12
11
 
13
- <script type="text/javascript">
14
- <%= Ckeditor::Utils.js_fileuploader('attachments') %>
15
- </script>
12
+ <% unless @attachments.last_page? %>
13
+ <div class="pagination">
14
+ <%= link_to I18n.t("ckeditor.buttons.next"), params.merge(:page => @attachments.next_page), :class => "next", :rel => "next" %>
15
+ </div>
16
+ <% end -%>
17
+
18
+ <script type="text/javascript">
19
+ <%= Ckeditor::Utils.js_fileuploader('attachments') %>
20
+ </script>
21
+ </div>
@@ -5,11 +5,17 @@
5
5
  </div>
6
6
  </div>
7
7
 
8
- <div class="fileupload-list">
9
- <%= render :partial => 'ckeditor/shared/asset', :collection => @pictures %>
8
+ <div class="fileupload-list" data-endless="true">
9
+ <%= render :partial => 'ckeditor/shared/asset', :collection => @pictures.scoped %>
10
10
  </div>
11
- </div>
12
11
 
13
- <script type="text/javascript">
14
- <%= Ckeditor::Utils.js_fileuploader('image') %>
15
- </script>
12
+ <% unless @pictures.last_page? %>
13
+ <div class="pagination">
14
+ <%= link_to I18n.t("ckeditor.buttons.next"), params.merge(:page => @pictures.next_page), :class => "next", :rel => "next" %>
15
+ </div>
16
+ <% end -%>
17
+
18
+ <script type="text/javascript">
19
+ <%= Ckeditor::Utils.js_fileuploader('image') %>
20
+ </script>
21
+ </div>