ckeditor 3.5.4 → 3.6.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/Gemfile +23 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +96 -97
  4. data/Rakefile +16 -33
  5. data/app/controllers/ckeditor/attachment_files_controller.rb +4 -4
  6. data/app/controllers/ckeditor/base_controller.rb +15 -42
  7. data/app/controllers/ckeditor/pictures_controller.rb +3 -3
  8. data/app/views/ckeditor/attachment_files/index.html.erb +13 -51
  9. data/app/views/ckeditor/pictures/index.html.erb +14 -52
  10. data/app/views/ckeditor/shared/_asset.html.erb +19 -0
  11. data/app/views/ckeditor/shared/_asset_tmpl.html.erb +21 -0
  12. data/app/views/layouts/ckeditor.html.erb +16 -23
  13. data/config/locales/en.ckeditor.yml +3 -7
  14. data/config/locales/ru.ckeditor.yml +4 -8
  15. data/config/locales/uk.ckeditor.yml +4 -8
  16. data/config/routes.rb +3 -3
  17. data/lib/ckeditor.rb +30 -79
  18. data/lib/ckeditor/engine.rb +14 -13
  19. data/lib/ckeditor/helpers/controllers.rb +30 -0
  20. data/lib/ckeditor/helpers/form_builder.rb +11 -0
  21. data/lib/ckeditor/helpers/form_helper.rb +25 -0
  22. data/lib/ckeditor/helpers/view_helper.rb +19 -0
  23. data/lib/ckeditor/http.rb +81 -0
  24. data/lib/ckeditor/orm/active_record.rb +91 -0
  25. data/lib/ckeditor/utils.rb +51 -70
  26. data/lib/ckeditor/version.rb +2 -7
  27. data/lib/generators/ckeditor/install_generator.rb +62 -0
  28. data/lib/generators/ckeditor/models_generator.rb +51 -0
  29. data/lib/generators/ckeditor/templates/ckeditor.rb +18 -0
  30. data/lib/generators/ckeditor/templates/ckeditor/config.js +52 -0
  31. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.jpg +0 -0
  32. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.png +0 -0
  33. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_del.png +0 -0
  34. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_more.gif +0 -0
  35. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/preloader.gif +0 -0
  36. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/ckfnothumb.gif +0 -0
  37. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/mp3.gif +0 -0
  38. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/pdf.gif +0 -0
  39. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/rar.gif +0 -0
  40. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/swf.gif +0 -0
  41. data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/xls.gif +0 -0
  42. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/javascripts/application.js +222 -0
  43. data/lib/generators/ckeditor/templates/ckeditor/filebrowser/stylesheets/uploader.css +112 -0
  44. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/dialogs/attachment.js +0 -0
  45. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/images/attachment.png +0 -0
  46. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/en.js +0 -0
  47. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/ru.js +0 -0
  48. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/uk.js +0 -0
  49. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/plugin.js +0 -0
  50. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/dialogs/embed.js +0 -0
  51. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/images/embed.png +0 -0
  52. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/en.js +0 -0
  53. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/ru.js +0 -0
  54. data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/uk.js +0 -0
  55. data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/plugin.js +0 -0
  56. data/lib/generators/ckeditor/templates/models/active_record/asset.rb +7 -0
  57. data/lib/generators/ckeditor/templates/models/active_record/attachment_file.rb +15 -0
  58. data/lib/generators/ckeditor/{migration/templates/models/paperclip → templates/models/active_record}/migration.rb +3 -8
  59. data/lib/generators/ckeditor/templates/models/active_record/picture.rb +13 -0
  60. data/test/ckeditor_test.rb +13 -0
  61. data/test/controllers/attachment_files_controller_test.rb +52 -0
  62. data/test/controllers/pictures_controller_test.rb +52 -0
  63. data/test/dummy/Rakefile +7 -0
  64. data/test/dummy/app/controllers/application_controller.rb +4 -0
  65. data/test/dummy/app/controllers/posts_controller.rb +83 -0
  66. data/test/dummy/app/helpers/application_helper.rb +2 -0
  67. data/test/dummy/app/helpers/posts_helper.rb +2 -0
  68. data/test/dummy/app/models/ckeditor/asset.rb +7 -0
  69. data/test/dummy/app/models/ckeditor/attachment_file.rb +15 -0
  70. data/test/dummy/app/models/ckeditor/picture.rb +13 -0
  71. data/test/dummy/app/models/post.rb +3 -0
  72. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  73. data/test/dummy/app/views/posts/_form.html.erb +30 -0
  74. data/test/dummy/app/views/posts/edit.html.erb +6 -0
  75. data/test/dummy/app/views/posts/index.html.erb +27 -0
  76. data/test/dummy/app/views/posts/new.html.erb +5 -0
  77. data/test/dummy/app/views/posts/show.html.erb +5 -0
  78. data/test/dummy/config.ru +4 -0
  79. data/test/dummy/config/application.rb +46 -0
  80. data/test/dummy/config/boot.rb +10 -0
  81. data/test/dummy/config/database.yml +34 -0
  82. data/test/dummy/config/environment.rb +5 -0
  83. data/test/dummy/config/environments/development.rb +26 -0
  84. data/test/dummy/config/environments/production.rb +49 -0
  85. data/test/dummy/config/environments/test.rb +35 -0
  86. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  87. data/test/dummy/config/initializers/ckeditor.rb +18 -0
  88. data/test/dummy/config/initializers/inflections.rb +10 -0
  89. data/test/dummy/config/initializers/mime_types.rb +5 -0
  90. data/test/dummy/config/initializers/secret_token.rb +7 -0
  91. data/test/dummy/config/initializers/session_store.rb +8 -0
  92. data/test/dummy/config/locales/en.yml +5 -0
  93. data/test/dummy/config/routes.rb +4 -0
  94. data/test/dummy/db/migrate/20110623120047_create_posts.rb +14 -0
  95. data/test/dummy/db/migrate/20110705195648_create_ckeditor_assets.rb +26 -0
  96. data/test/dummy/db/schema.rb +36 -0
  97. data/test/dummy/log/development.log +818 -0
  98. data/test/dummy/log/production.log +0 -0
  99. data/test/dummy/log/server.log +0 -0
  100. data/test/dummy/log/test.log +5398 -0
  101. data/test/dummy/public/404.html +26 -0
  102. data/test/dummy/public/422.html +26 -0
  103. data/test/dummy/public/500.html +26 -0
  104. data/test/dummy/public/favicon.ico +0 -0
  105. data/test/dummy/public/javascripts/application.js +2 -0
  106. data/test/dummy/public/javascripts/controls.js +965 -0
  107. data/test/dummy/public/javascripts/dragdrop.js +974 -0
  108. data/test/dummy/public/javascripts/effects.js +1123 -0
  109. data/test/dummy/public/javascripts/prototype.js +6001 -0
  110. data/test/dummy/public/javascripts/rails.js +191 -0
  111. data/test/dummy/public/stylesheets/scaffold.css +56 -0
  112. data/test/dummy/script/rails +6 -0
  113. data/test/dummy/test/fixtures/files/rails.png +0 -0
  114. data/test/dummy/test/fixtures/files/rails.tar.gz +0 -0
  115. data/test/generators/install_generator_test.rb +18 -0
  116. data/test/generators/models_generator_test.rb +21 -0
  117. data/test/integration/navigation_test.rb +7 -0
  118. data/test/integration/posts_test.rb +41 -0
  119. data/test/routes_test.rb +47 -0
  120. data/test/support/integration_case.rb +5 -0
  121. data/test/test_helper.rb +28 -0
  122. data/test/tmp/app/models/ckeditor/asset.rb +7 -0
  123. data/test/tmp/app/models/ckeditor/attachment_file.rb +15 -0
  124. data/test/tmp/app/models/ckeditor/picture.rb +13 -0
  125. data/test/tmp/db/migrate/20110711170413_create_ckeditor_assets.rb +26 -0
  126. metadata +220 -99
  127. data/CHANGELOG +0 -15
  128. data/app/helpers/ckeditor/base_helper.rb +0 -21
  129. data/app/views/ckeditor/_asset.html.erb +0 -20
  130. data/app/views/ckeditor/_swfupload.html.erb +0 -73
  131. data/lib/ckeditor/form_builder.rb +0 -22
  132. data/lib/ckeditor/middleware.rb +0 -18
  133. data/lib/ckeditor/view_helper.rb +0 -92
  134. data/lib/generators/ckeditor/base/USAGE +0 -9
  135. data/lib/generators/ckeditor/base/base_generator.rb +0 -41
  136. data/lib/generators/ckeditor/base/templates/ckeditor.rb +0 -54
  137. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/dialogs/attachment.js +0 -384
  138. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/plugin.js +0 -44
  139. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/dialogs/embed.js +0 -65
  140. data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/plugin.js +0 -43
  141. data/lib/generators/ckeditor/base/templates/ckeditor/config.js +0 -43
  142. data/lib/generators/ckeditor/base/templates/ckeditor/css/ckfinder.css +0 -316
  143. data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_dialog.css +0 -119
  144. data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_editor.css +0 -448
  145. data/lib/generators/ckeditor/base/templates/ckeditor/css/swfupload.css +0 -94
  146. data/lib/generators/ckeditor/base/templates/ckeditor/images/add.gif +0 -0
  147. data/lib/generators/ckeditor/base/templates/ckeditor/images/cancelbutton.gif +0 -0
  148. data/lib/generators/ckeditor/base/templates/ckeditor/images/doc.gif +0 -0
  149. data/lib/generators/ckeditor/base/templates/ckeditor/images/refresh.gif +0 -0
  150. data/lib/generators/ckeditor/base/templates/ckeditor/images/select_files.png +0 -0
  151. data/lib/generators/ckeditor/base/templates/ckeditor/images/spacer.gif +0 -0
  152. data/lib/generators/ckeditor/base/templates/ckeditor/images/toolbar.start.gif +0 -0
  153. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/images/attachment.png +0 -0
  154. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/en.js +0 -10
  155. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/ru.js +0 -10
  156. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/uk.js +0 -10
  157. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/images/embed.png +0 -0
  158. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/en.js +0 -9
  159. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/ru.js +0 -9
  160. data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/uk.js +0 -9
  161. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/fileprogress.js +0 -266
  162. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/handlers.js +0 -181
  163. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/jquery-1.5.1.min.js +0 -16
  164. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/querystring.js +0 -40
  165. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/rails.js +0 -158
  166. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.js +0 -1
  167. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.queue.js +0 -1
  168. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swf +0 -0
  169. data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swfobject.js +0 -111
  170. data/lib/generators/ckeditor/migration/USAGE +0 -12
  171. data/lib/generators/ckeditor/migration/migration_generator.rb +0 -46
  172. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/asset.rb +0 -32
  173. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb +0 -24
  174. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/migration.rb +0 -30
  175. data/lib/generators/ckeditor/migration/templates/models/attachment_fu/picture.rb +0 -25
  176. data/lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb +0 -97
  177. data/lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb +0 -40
  178. data/lib/generators/ckeditor/migration/templates/models/paperclip/picture.rb +0 -23
  179. data/lib/tasks/ckeditor_tasks.rake +0 -3
@@ -0,0 +1,51 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Ckeditor
5
+ module Generators
6
+ class ModelsGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ desc "Generates migration for Asset (Picture, AttachmentFile) models"
10
+
11
+ # ORM configuration
12
+ class_option :orm, :type => :string, :default => "active_record",
13
+ :desc => "Backend processor for upload support"
14
+
15
+ def self.source_root
16
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates', 'models/'))
17
+ end
18
+
19
+ def self.next_migration_number(dirname)
20
+ Time.now.strftime("%Y%m%d%H%M%S")
21
+ end
22
+
23
+ def create_models
24
+ template "#{generator_dir}/asset.rb",
25
+ File.join('app/models', ckeditor_dir, "asset.rb")
26
+
27
+ template "#{generator_dir}/picture.rb",
28
+ File.join('app/models', ckeditor_dir, "picture.rb")
29
+
30
+ template "#{generator_dir}/attachment_file.rb",
31
+ File.join('app/models', ckeditor_dir, "attachment_file.rb")
32
+ end
33
+
34
+ def create_migration
35
+ if options[:orm] == "active_record"
36
+ migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', "create_ckeditor_assets.rb")
37
+ end
38
+ end
39
+
40
+ protected
41
+
42
+ def ckeditor_dir
43
+ 'ckeditor'
44
+ end
45
+
46
+ def generator_dir
47
+ options[:orm] || "active_record"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,18 @@
1
+ # Use this hook to configure ckeditor
2
+ if Object.const_defined?("Ckeditor")
3
+ Ckeditor.setup do |config|
4
+ # ==> ORM configuration
5
+ # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
6
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
7
+ # available as additional gems.
8
+ require 'ckeditor/orm/active_record'
9
+
10
+ # Allowed image file types for upload.
11
+ # Set to nil or [] (empty array) for all file types
12
+ # config.image_file_types = ["jpg", "jpeg", "png", "gif", "tiff"]
13
+
14
+ # Allowed attachment file types for upload.
15
+ # Set to nil or [] (empty array) for all file types
16
+ # config.attachment_file_types = ["doc", "docx", "rar", "zip", "xls", "swf"]
17
+ end
18
+ end
@@ -0,0 +1,52 @@
1
+ /*
2
+ Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3
+ For licensing, see LICENSE.html or http://ckeditor.com/license
4
+ */
5
+
6
+ CKEDITOR.editorConfig = function( config )
7
+ {
8
+ // Define changes to default configuration here. For example:
9
+ // config.language = 'fr';
10
+ // config.uiColor = '#AADC6E';
11
+
12
+ /* Filebrowser routes */
13
+ // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
14
+ config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
15
+
16
+ // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
17
+ config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
18
+
19
+ // The location of a script that handles file uploads in the Flash dialog.
20
+ config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
21
+
22
+ // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
23
+ config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
24
+
25
+ // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
26
+ config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
27
+
28
+ // The location of a script that handles file uploads in the Image dialog.
29
+ config.filebrowserImageUploadUrl = "/ckeditor/pictures";
30
+
31
+ // The location of a script that handles file uploads.
32
+ config.filebrowserUploadUrl = "/ckeditor/attachment_files";
33
+
34
+ /* Extra plugins */
35
+ // works only with en, ru, uk locales
36
+ config.extraPlugins = "embed,attachment";
37
+
38
+ /* Toolbars */
39
+ config.toolbar = 'Easy';
40
+
41
+ config.toolbar_Easy =
42
+ [
43
+ ['Source','-','Preview'],
44
+ ['Cut','Copy','Paste','PasteText','PasteFromWord',],
45
+ ['Undo','Redo','-','SelectAll','RemoveFormat'],
46
+ ['Styles','Format'], ['Subscript', 'Superscript', 'TextColor'], ['Maximize','-','About'], '/',
47
+ ['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
48
+ ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
49
+ ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
50
+ ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
51
+ ];
52
+ };
@@ -0,0 +1,222 @@
1
+ (function($) {
2
+ $.QueryString = (function(a) {
3
+ if (a == "") return {};
4
+ var b = {};
5
+ for (var i = 0; i < a.length; ++i)
6
+ {
7
+ var p=a[i].split('=');
8
+ if (p.length != 2) continue;
9
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
10
+ }
11
+ return b;
12
+ })(window.location.search.substr(1).split('&'))
13
+ })(jQuery);
14
+
15
+ $(document).ready(function(){
16
+ $("div.gal-item div.gal-inner-holder")
17
+ .live('mouseover', function(e){
18
+ $(this).addClass('hover');
19
+ })
20
+ .live('mouseout', function(e){
21
+ $(this).removeClass('hover');
22
+ })
23
+ .live('click', function(e){
24
+ var url = $(this).parents('div.gal-item').data('url');
25
+ CKEDITOR.tools.callFunction(CKEditorFuncNum, url);
26
+ window.close();
27
+ });
28
+
29
+ $("div.gal-item a.gal-del").live('ajax:complete', function(xhr, status){
30
+ $(this).parents('div.gal-item').remove();
31
+ });
32
+ });
33
+
34
+ // Collection of all instances on page
35
+ qq.FileUploader.instances = new Object();
36
+
37
+ /**
38
+ * Class that creates upload widget with drag-and-drop and file list
39
+ * @inherits qq.FileUploaderBasic
40
+ */
41
+ qq.FileUploaderInput = function(o){
42
+ // call parent constructor
43
+ qq.FileUploaderBasic.apply(this, arguments);
44
+
45
+ // additional options
46
+ qq.extend(this._options, {
47
+ element: null,
48
+ // if set, will be used instead of qq-upload-list in template
49
+ listElement: null,
50
+
51
+ template_id: '#fileupload_tmpl',
52
+
53
+ classes: {
54
+ // used to get elements from templates
55
+ button: 'fileupload-button',
56
+ drop: 'fileupload-drop-area',
57
+ dropActive: 'fileupload-drop-area-active',
58
+ list: 'fileupload-list',
59
+ preview: 'fileupload-preview',
60
+
61
+ file: 'fileupload-file',
62
+ spinner: 'fileupload-spinner',
63
+ size: 'fileupload-size',
64
+ cancel: 'fileupload-cancel',
65
+
66
+ // added to list item when upload completes
67
+ // used in css to hide progress spinner
68
+ success: 'fileupload-success',
69
+ fail: 'fileupload-fail'
70
+ }
71
+ });
72
+ // overwrite options with user supplied
73
+ qq.extend(this._options, o);
74
+
75
+ this._element = document.getElementById(this._options.element);
76
+ this._listElement = this._options.listElement || this._find(this._element, 'list');
77
+
78
+ this._classes = this._options.classes;
79
+
80
+ this._button = this._createUploadButton(this._find(this._element, 'button'));
81
+
82
+ //this._setupDragDrop();
83
+
84
+ qq.FileUploader.instances[this._element.id] = this;
85
+ };
86
+
87
+ // inherit from Basic Uploader
88
+ qq.extend(qq.FileUploaderInput.prototype, qq.FileUploaderBasic.prototype);
89
+
90
+ qq.extend(qq.FileUploaderInput.prototype, {
91
+ /**
92
+ * Gets one of the elements listed in this._options.classes
93
+ **/
94
+ _find: function(parent, type){
95
+ var element = qq.getByClass(parent, this._options.classes[type])[0];
96
+ if (!element){
97
+ alert(type);
98
+ throw new Error('element not found ' + type);
99
+ }
100
+
101
+ return element;
102
+ },
103
+ _setupDragDrop: function(){
104
+ var self = this,
105
+ dropArea = this._find(this._element, 'drop');
106
+
107
+ var dz = new qq.UploadDropZone({
108
+ element: dropArea,
109
+ onEnter: function(e){
110
+ qq.addClass(dropArea, self._classes.dropActive);
111
+ e.stopPropagation();
112
+ },
113
+ onLeave: function(e){
114
+ e.stopPropagation();
115
+ },
116
+ onLeaveNotDescendants: function(e){
117
+ qq.removeClass(dropArea, self._classes.dropActive);
118
+ },
119
+ onDrop: function(e){
120
+ dropArea.style.display = 'none';
121
+ qq.removeClass(dropArea, self._classes.dropActive);
122
+ self._uploadFileList(e.dataTransfer.files);
123
+ }
124
+ });
125
+
126
+ dropArea.style.display = 'none';
127
+
128
+ qq.attach(document, 'dragenter', function(e){
129
+ if (!dz._isValidFileDrag(e)) return;
130
+
131
+ dropArea.style.display = 'block';
132
+ });
133
+ qq.attach(document, 'dragleave', function(e){
134
+ if (!dz._isValidFileDrag(e)) return;
135
+
136
+ var relatedTarget = document.elementFromPoint(e.clientX, e.clientY);
137
+ // only fire when leaving document out
138
+ if ( ! relatedTarget || relatedTarget.nodeName == "HTML"){
139
+ dropArea.style.display = 'none';
140
+ }
141
+ });
142
+ },
143
+ _onSubmit: function(id, fileName){
144
+ qq.FileUploaderBasic.prototype._onSubmit.apply(this, arguments);
145
+ this._addToList(id, fileName);
146
+ },
147
+ _onProgress: function(id, fileName, loaded, total){
148
+ qq.FileUploaderBasic.prototype._onProgress.apply(this, arguments);
149
+
150
+ var item = this._getItemByFileId(id);
151
+ var size = this._find(item, 'size');
152
+
153
+ var text;
154
+ if (loaded != total){
155
+ text = Math.round(loaded / total * 100) + '% from ' + this._formatSize(total);
156
+ } else {
157
+ text = this._formatSize(total);
158
+ }
159
+
160
+ qq.setText(size, text);
161
+ },
162
+ _onComplete: function(id, fileName, result){
163
+ qq.FileUploaderBasic.prototype._onComplete.apply(this, arguments);
164
+
165
+ var item = this._getItemByFileId(id);
166
+ var asset = result.asset;
167
+
168
+ if (asset && asset.id){
169
+ qq.addClass(item, this._classes.success);
170
+
171
+ asset.size = this._formatSize(asset.size);
172
+ asset.controller = (asset.type.toLowerCase() == "ckeditor::picture" ? "pictures" : "attachment_files");
173
+
174
+ $(item).replaceWith($(this._options.template_id).tmpl(asset));
175
+ } else {
176
+ qq.addClass(item, this._classes.fail);
177
+ }
178
+ },
179
+ _addToList: function(id, fileName){
180
+ if (this._listElement) {
181
+ if (this._options.multiple === false) {
182
+ $(this._listElement).empty();
183
+ }
184
+
185
+ var asset = {
186
+ id: 0,
187
+ filename: this._formatFileName(fileName),
188
+ size: 0,
189
+ format_created_at: '',
190
+ url_content: "#",
191
+ controller: "assets",
192
+ url_thumb: "/javascripts/ckeditor/filebrowser/images/preloader.gif"
193
+ };
194
+
195
+ var item = $(this._options.template_id)
196
+ .tmpl(asset)
197
+ .attr('qqfileid', id)
198
+ .prependTo( this._listElement );
199
+
200
+ item.find('div.img').addClass('preloader');
201
+
202
+ this._bindCancelEvent(item);
203
+ }
204
+ },
205
+ _getItemByFileId: function(id){
206
+ return $(this._listElement).find('div[qqfileid=' + id +']').get(0);
207
+ },
208
+ /**
209
+ * delegate click event for cancel link
210
+ **/
211
+ _bindCancelEvent: function(element){
212
+ var self = this,
213
+ item = $(element);
214
+
215
+ item.find('a.' + this._classes.cancel).bind('click', function(e){
216
+ self._handler.cancel( item.attr('qqfileid') );
217
+ item.remove();
218
+ qq.preventDefault(e);
219
+ return false;
220
+ });
221
+ }
222
+ });
@@ -0,0 +1,112 @@
1
+ body {
2
+ padding: 0;
3
+ margin: 0;
4
+ font-family: Arial, Helvetica, sans-serif;
5
+ }
6
+ .gal-holder {
7
+ display: block;
8
+ overflow: hidden;
9
+ padding: 20px;
10
+ }
11
+ .gal-holder .gal-item {
12
+ display: block;
13
+ float: left;
14
+ width: 150px;
15
+ overflow: hidden;
16
+ position: relative;
17
+ margin: 0 12px 12px 0;
18
+ }
19
+ .gal-holder .gal-item .gal-del {
20
+ display: block;
21
+ position: absolute;
22
+ right: 0;
23
+ top: 0;
24
+ }
25
+ .gal-holder .gal-item .gal-del:hover {
26
+ -moz-opacity: 0.7;
27
+ -khtml-opacity: 0.7;
28
+ opacity: 0.7;
29
+ }
30
+ .gal-holder .gal-item .gal-upload-holder .add {
31
+ display: block;
32
+ color: #2e5aff;
33
+ background: url(/javascripts/ckeditor/filebrowser/images/gal_add.png) no-repeat left center;
34
+ padding-left: 33px;
35
+ line-height: 25px;
36
+ text-decoration: none;
37
+ margin: 50px 0 0 10px;
38
+ font-size: 14px;
39
+ }
40
+ .gal-holder .gal-item .gal-upload-holder .add:hover {
41
+ text-decoration: underline;
42
+ }
43
+ .gal-holder .gal-item .gal-inner-holder, .gal-holder .gal-item .gal-upload-holder {
44
+ display: block;
45
+ margin: 6px 6px 0 0;
46
+ overflow: hidden;
47
+ padding: 12px;
48
+ background: #fff;
49
+ border: solid 1px #D3D3D3;
50
+ min-height: 138px;
51
+ }
52
+ .gal-holder .gal-item .gal-inner-holder.hover {
53
+ background: #DFF1FF;
54
+ border: solid 1px #99CCFF;
55
+ }
56
+ .gal-holder .gal-item .gal-inner-holder.selected {
57
+ background: #B4D9FF;
58
+ border: solid 1px #6565FE;
59
+ }
60
+ .gal-holder .gal-item .gal-inner-holder .img {
61
+ height: 100px;
62
+ overflow: hidden;
63
+ cursor:pointer;
64
+ }
65
+ .gal-holder .gal-item .gal-inner-holder .img.preloader {
66
+ padding: 27px 0 0 33px;
67
+ height: 73px;
68
+ }
69
+ .gal-holder .gal-item .gal-inner-holder .img-data {
70
+ display: block;
71
+ overflow: hidden;
72
+ padding-top: 5px;
73
+ }
74
+ .gal-holder .gal-item .gal-inner-holder .img-data .img-name {
75
+ display: block;
76
+ color: #333;
77
+ padding-bottom: 5px;
78
+ font-size: 12px;
79
+ overflow: hidden;
80
+ width: 500px;
81
+ }
82
+ .gal-holder .gal-item .gal-inner-holder .img-data .time-size {
83
+ display: block;
84
+ overflow: hidden;
85
+ font-size: 10px;
86
+ color: #666;
87
+ }
88
+ .gal-holder .gal-item .gal-inner-holder .img-data .time-size .time {
89
+ display: block;
90
+ float: left;
91
+ }
92
+ .gal-holder .gal-item .gal-inner-holder .img-data .time-size .size {
93
+ display: block;
94
+ float: right;
95
+ }
96
+ .gal-more {
97
+ display: block;
98
+ overflow: hidden;
99
+ border-top: dashed 1px #d3d3d3;
100
+ padding: 20px 0;
101
+ text-align: center;
102
+ }
103
+ .gal-more a {
104
+ color: #2e5aff;
105
+ background: url(/javascripts/ckeditor/filebrowser/images/gal_more.gif) no-repeat left center;
106
+ padding-left: 15px;
107
+ font-size: 14px;
108
+ text-decoration: none;
109
+ }
110
+ .gal-more a:hover {
111
+ text-decoration: underline;
112
+ }