ckeditor 4.0.7 → 4.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -2
- data/app/assets/javascripts/ckeditor/application.js +1 -0
- data/app/assets/javascripts/ckeditor/filebrowser/javascripts/application.js.erb +10 -0
- data/app/assets/javascripts/ckeditor/filebrowser/javascripts/jquery.endless-scroll.js +300 -0
- data/app/assets/javascripts/ckeditor/filebrowser/stylesheets/uploader.css.erb +4 -0
- data/app/controllers/ckeditor/attachment_files_controller.rb +3 -1
- data/app/controllers/ckeditor/pictures_controller.rb +3 -1
- data/app/views/ckeditor/attachment_files/index.html.erb +11 -5
- data/app/views/ckeditor/pictures/index.html.erb +12 -6
- data/app/views/ckeditor/shared/_asset.html.erb +1 -1
- data/app/views/ckeditor/shared/_asset_tmpl.html.erb +1 -1
- data/config/locales/cs.ckeditor.yml +1 -0
- data/config/locales/de.ckeditor.yml +1 -0
- data/config/locales/el-GR.cdkeditor.yml +2 -1
- data/config/locales/en.ckeditor.yml +1 -0
- data/config/locales/es.ckeditor.yml +1 -0
- data/config/locales/fr.ckeditor.yml +1 -0
- data/config/locales/hu.ckeditor.yml +1 -0
- data/config/locales/it.ckeditor.yml +1 -0
- data/config/locales/nl.ckeditor.yml +2 -1
- data/config/locales/pl.ckeditor.yml +1 -0
- data/config/locales/pt-BR.ckeditor.yml +2 -1
- data/config/locales/pt-PT.ckeditor.yml +1 -0
- data/config/locales/ru.ckeditor.yml +1 -0
- data/config/locales/sv-SE.ckeditor.yml +1 -0
- data/config/locales/uk.ckeditor.yml +1 -0
- data/config/locales/zh-CN.ckeditor.yml +1 -0
- data/lib/ckeditor.rb +11 -0
- data/lib/ckeditor/helpers/controllers.rb +1 -1
- data/lib/ckeditor/paginatable.rb +56 -0
- data/lib/ckeditor/utils.rb +41 -18
- data/lib/ckeditor/version.rb +2 -2
- data/lib/generators/ckeditor/templates/ckeditor.rb +3 -0
- data/test/dummy/public/uploads/tmp/20140108-1222-52217-3986/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1222-52217-6261/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1222-52217-6421/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3058/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-3990/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1223-52217-8126/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-0400/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-1537/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-4718/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-4820/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-8057/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52513-9147/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-3606/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-4369/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-4698/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-7541/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9146/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1228-52590-9782/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3256/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-3565/thumb_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-4292/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-4514/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-7430/rails.tar.gz +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/content_rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/rails.png +0 -0
- data/test/dummy/public/uploads/tmp/20140108-1230-52768-9145/thumb_rails.png +0 -0
- data/vendor/assets/javascripts/ckeditor/CHANGES.md +36 -0
- data/vendor/assets/javascripts/ckeditor/ckeditor.js +465 -463
- data/vendor/assets/javascripts/ckeditor/config.js +1 -1
- data/vendor/assets/javascripts/ckeditor/contents.css +17 -0
- data/vendor/assets/javascripts/ckeditor/lang/ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cs.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/cy.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/de.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/el.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-au.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-ca.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/en-gb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/es.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/fi.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/it.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ja.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/km.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nb.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/nl.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/no.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/pt-br.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/ru.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/sv.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/tr.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh-cn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/lang/zh.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/cy.js +3 -3
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/fi.js +2 -2
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh-cn.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/a11yhelp/dialogs/lang/zh.js +7 -0
- data/vendor/assets/javascripts/ckeditor/plugins/scayt/dialogs/options.js +16 -16
- data/vendor/assets/javascripts/ckeditor/plugins/specialchar/dialogs/lang/zh.js +12 -0
- data/vendor/assets/javascripts/ckeditor/plugins/templates/templates/default.js +1 -1
- data/vendor/assets/javascripts/ckeditor/plugins/wsc/dialogs/wsc.js +31 -31
- data/vendor/assets/javascripts/ckeditor/samples/ajax.html +82 -0
- data/vendor/assets/javascripts/ckeditor/samples/api.html +207 -0
- data/vendor/assets/javascripts/ckeditor/samples/appendto.html +57 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/inlineall/logo.png +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/outputxhtml/outputxhtml.css +204 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/posteddata.php +59 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/sample.css +3 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/sample.jpg +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/assets/uilanguages/languages.js +7 -0
- data/vendor/assets/javascripts/ckeditor/samples/datafiltering.html +401 -0
- data/vendor/assets/javascripts/ckeditor/samples/divreplace.html +141 -0
- data/vendor/assets/javascripts/ckeditor/samples/index.html +128 -0
- data/vendor/assets/javascripts/ckeditor/samples/inlineall.html +311 -0
- data/vendor/assets/javascripts/ckeditor/samples/inlinebycode.html +121 -0
- data/vendor/assets/javascripts/ckeditor/samples/inlinetextarea.html +110 -0
- data/vendor/assets/javascripts/ckeditor/samples/jquery.html +97 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/assets/my_dialog.js +48 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/dialog/dialog.html +187 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/enterkey/enterkey.html +103 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.fla +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/outputforflash.swf +0 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/assets/outputforflash/swfobject.js +18 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputforflash.html +280 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/htmlwriter/outputhtml.html +221 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/magicline/magicline.html +206 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/toolbar/toolbar.html +232 -0
- data/vendor/assets/javascripts/ckeditor/samples/plugins/wysiwygarea/fullpage.html +77 -0
- data/vendor/assets/javascripts/ckeditor/samples/readonly.html +73 -0
- data/vendor/assets/javascripts/ckeditor/samples/replacebyclass.html +57 -0
- data/vendor/assets/javascripts/ckeditor/samples/replacebycode.html +56 -0
- data/vendor/assets/javascripts/ckeditor/samples/sample.css +356 -0
- data/vendor/assets/javascripts/ckeditor/samples/sample.js +50 -0
- data/vendor/assets/javascripts/ckeditor/samples/sample_posteddata.php +16 -0
- data/vendor/assets/javascripts/ckeditor/samples/tabindex.html +75 -0
- data/vendor/assets/javascripts/ckeditor/samples/uicolor.html +69 -0
- data/vendor/assets/javascripts/ckeditor/samples/uilanguages.html +119 -0
- data/vendor/assets/javascripts/ckeditor/samples/xhtmlstyle.html +231 -0
- metadata +139 -16
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -1425
- data/test/tmp/app/models/ckeditor/asset.rb +0 -5
- data/test/tmp/app/models/ckeditor/attachment_file.rb +0 -12
- data/test/tmp/app/models/ckeditor/picture.rb +0 -13
- data/test/tmp/config/initializers/ckeditor.rb +0 -19
- 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:
|
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);
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
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>
|