proclaim 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +6 -0
- data/Gemfile +14 -0
- data/LICENSE +674 -0
- data/README.md +137 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/app/assets/images/ajax_loader.gif +0 -0
- data/app/assets/javascripts/proclaim.js +18 -0
- data/app/assets/javascripts/proclaim/comments_handler.js.coffee +192 -0
- data/app/assets/javascripts/proclaim/editor.js.coffee +50 -0
- data/app/assets/javascripts/proclaim/images.js.coffee +3 -0
- data/app/assets/javascripts/proclaim/subscriptions.js.coffee +3 -0
- data/app/assets/stylesheets/proclaim.css.scss +28 -0
- data/app/assets/stylesheets/proclaim/comments.css.scss +14 -0
- data/app/assets/stylesheets/proclaim/images.scss +3 -0
- data/app/assets/stylesheets/proclaim/posts.css.scss +77 -0
- data/app/assets/stylesheets/proclaim/subscriptions.css.scss +3 -0
- data/app/controllers/proclaim/application_controller.rb +44 -0
- data/app/controllers/proclaim/comments_controller.rb +128 -0
- data/app/controllers/proclaim/images_controller.rb +108 -0
- data/app/controllers/proclaim/posts_controller.rb +131 -0
- data/app/controllers/proclaim/subscriptions_controller.rb +67 -0
- data/app/helpers/proclaim/application_helper.rb +34 -0
- data/app/helpers/proclaim/comments_helper.rb +4 -0
- data/app/helpers/proclaim/images_helper.rb +4 -0
- data/app/helpers/proclaim/posts_helper.rb +4 -0
- data/app/helpers/proclaim/subscriptions_helper.rb +4 -0
- data/app/mailers/proclaim/subscription_mailer.rb +43 -0
- data/app/models/proclaim/comment.rb +35 -0
- data/app/models/proclaim/image.rb +19 -0
- data/app/models/proclaim/post.rb +133 -0
- data/app/models/proclaim/subscription.rb +63 -0
- data/app/policies/application_policy.rb +53 -0
- data/app/policies/proclaim/comment_policy.rb +27 -0
- data/app/policies/proclaim/image_policy.rb +29 -0
- data/app/policies/proclaim/post_policy.rb +38 -0
- data/app/policies/proclaim/subscription_policy.rb +32 -0
- data/app/uploaders/proclaim/image_uploader.rb +82 -0
- data/app/views/layouts/proclaim/subscription_mailer.html.erb +133 -0
- data/app/views/proclaim/comments/_comment.html.erb +33 -0
- data/app/views/proclaim/comments/_form.html.erb +51 -0
- data/app/views/proclaim/posts/_form.html.erb +67 -0
- data/app/views/proclaim/posts/edit.html.erb +3 -0
- data/app/views/proclaim/posts/index.html.erb +30 -0
- data/app/views/proclaim/posts/new.html.erb +3 -0
- data/app/views/proclaim/posts/show.html.erb +46 -0
- data/app/views/proclaim/subscription_mailer/new_comment_notification_email.html.erb +11 -0
- data/app/views/proclaim/subscription_mailer/new_post_notification_email.html.erb +15 -0
- data/app/views/proclaim/subscription_mailer/welcome_email.html.erb +25 -0
- data/app/views/proclaim/subscriptions/_form.html.erb +32 -0
- data/app/views/proclaim/subscriptions/new.html.erb +8 -0
- data/app/views/proclaim/subscriptions/subscribed.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribe.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribed.html.erb +3 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20141108222616_create_proclaim_posts.rb +15 -0
- data/db/migrate/20141114235359_create_proclaim_comments.rb +15 -0
- data/db/migrate/20141115022230_create_proclaim_comment_hierarchies.rb +26 -0
- data/db/migrate/20141210234057_create_proclaim_subscriptions.rb +17 -0
- data/db/migrate/20141222224905_create_proclaim_images.rb +12 -0
- data/lib/generators/proclaim/install_generator.rb +23 -0
- data/lib/generators/proclaim/templates/README +27 -0
- data/lib/generators/proclaim/templates/initialize_proclaim.rb +22 -0
- data/lib/generators/proclaim/views_generator.rb +24 -0
- data/lib/proclaim.rb +22 -0
- data/lib/proclaim/engine.rb +39 -0
- data/lib/proclaim/version.rb +3 -0
- data/lib/tasks/proclaim_tasks.rake +4 -0
- data/proclaim.gemspec +46 -0
- data/test/controllers/proclaim/comments_controller_test.rb +228 -0
- data/test/controllers/proclaim/images_controller_test.rb +123 -0
- data/test/controllers/proclaim/posts_controller_test.rb +303 -0
- data/test/controllers/proclaim/subscriptions_controller_test.rb +93 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +15 -0
- data/test/dummy/app/helpers/application_helper.rb +28 -0
- data/test/dummy/app/models/user.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +16 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +45 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20141117214323_create_users.rb +10 -0
- data/test/dummy/db/schema.rb +75 -0
- data/test/dummy/log/development.log +131 -0
- data/test/dummy/log/test.log +25961 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/0b69f7cc441d56def3a51688e6a7a8474dc476d1/proclaim.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/comments.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/images.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/posts.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/subscriptions.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/04adcece63bc645379e6de797e7998f8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/06620fc450f0a9b4a482a7bc08387711 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/076dd0d567a92c34163b3b98af1d48ba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fc2eadf6d6062b2cc135a44e4e73db +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fe8c62e8ae706e01058b4b4d056c8e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/142fd040033525acb73ad2ccf1406aea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1762aeeaf38da3b8d989a5b66b088004 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/194ac1a695334e303516614579b3926d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/197ea008934db3e7ea8045302d206b92 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/19eba2635fec0895379c3e38f81ada84 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1c2ebe72fcd7ff1379a561552ca30f85 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1f42c80faacb651f670ec2b0998e49dc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2243230e778a749ecbf0415a52e75be0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/23ad87e715c70312aa61dde4fbb4bfe1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/245b8735db4ea90bcaa91c011a1f447e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/26a42dac0cec64483f4126d2de4b0c9e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30151c8f6d93717f06fa12774612ddf4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3c623d200214a5334aaf170537db087f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3ec36650a50759fd4b75794cb253936f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/40431cdcc10c75ba1f275ecfe42623d3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4226218a4b06608115b21063353370ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/437901953eb8707af6c27ca59cf65d91 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/461885b8ad31ef6a94c9a4f2e332b7eb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4792f46317cda92ccd5b278ec61f9ac5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4dcb3434b91b1c62f897a1741c6d398b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5101cda93cf70f0fc0837713be587780 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/52d8c61de0703e0d7cf97d0f7b0cca7a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/57f3d19a9bd484ac68c46f962a8684b2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/587e7c1332c8d8b69746dd85164e2cef +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5934d5d0d1ac6657842708e85c73cf51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5af081799d7da2f04ead6a516c6015ad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/69ee5af8d9a655898a67bc538ca1c7e7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6d1c56259648b0383bc438c875a448c3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6e7de35055967df848aa490830043e51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/70bc59560ee544af7bb2f727247db307 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/728cb566999910549092ff0a98e2853b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72b5f0d35e9d69b744a156edad98f983 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72ffa34d552e3fd02f28a6f845a5ac5b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7369d324e84bc872c42b3e717ff4ad6c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/749a8b0e45b11df748a256dd04ceb1f7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/77fb9f62552d9b786f9407ef11cc9a09 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/797823842565e01fc989ad8df0bd4254 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7c139afa2296ac17483520109aecd449 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7fb99e2b35af65c4f58bfb92dd4185b4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/819de31c63b704f9ddf4865587a91d41 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8604b464bf846e5223da37ef2f29b524 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/88fc815613b473e98e9307b1d423918d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8bc4341aa4060b8646e8134722cf3b11 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8cf8fd5ff8eae12211a88f971af30236 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8da3b4a9f17aafff49eb263bdb758f44 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9168e513bae02f041dbb806d6dbe94ac +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/920c1322be1212a54b7c4f2751d5e7bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/92205679a36afd387a2ba5c585a5a62c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/940566ebcae2d4e5c56a881ab66f2cf0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/976967e07e2944a7ecc7403667f1f96b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/99bdde70cefa71745279232be575f14e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9a8e402a7e32063e46647403b43553a5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9b09ad72f8cc33503878b01c713d92d0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a20dbdfebf37fe50e832a6273c972553 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a3c6189fad6cb9ae955f6d5a43a61d51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/abb54e11ff057a3e22a5a97d27cc4fa3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ad18e3875541d4298b1df133d494b93f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b9b7c575c22943d49734d52381c5ee16 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ba269a52f100d3d6cffda81e82e1ed49 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bc7a0846b4881b0832d41de2b1724dba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcb2df87f9611d3cc3ef8a5575e54fb8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcf33791d3286af3ba2cdf6a6756c89e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/be32d0a530ce861537d6abfa41333df9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8270a6f07dccc5f00e6b2b43f10efd2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cd82cd410a50bffcfb6e21e3c49a85c9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ce4ccaa06bdee6426486224bc7e54187 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d0bdb8592e4eed80aa2341e37f20dbc9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d4b784b16fa1b1dfcca6590689a8c157 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d968bd38a69bbf5c0065e2df3d30cfd3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/daa4d4b8a5ce46d6c4ecf031e0c61cfe +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/dc2effd195334219a7e4acfdc7ec7974 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de36ab6c3b1a9b62a586d98373dd569c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e3aec457d5c753090d6521f2bb2d91b6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8d6158b1fed2f574242b55856a3953d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ea82f6aececcf81eef3e2e15a9225e66 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed9f5c17f71ec75de10b1bb029ebd7a2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f2984adaeaa5322e3a040705c6d40622 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f62fd0cf9f5e7e077ec9c4daeccb06ae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f78ea69bdbba5738c052e9eb04e6c208 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f864e553f706456dbdf168319970ec2e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fb0f641bfcbb0101c040da9ff736447b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fe426a44cf23cf82032091cbffff898c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ff732ea47a86c449582b2a81ef2930da +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ffc4980851addaacf12abeebfa63e07f +0 -0
- data/test/dummy/tmp/generators/config/initializers/proclaim.rb +22 -0
- data/test/factories/proclaim/comment.rb +11 -0
- data/test/factories/proclaim/image.rb +6 -0
- data/test/factories/proclaim/post.rb +14 -0
- data/test/factories/proclaim/subscription.rb +13 -0
- data/test/factories/user.rb +6 -0
- data/test/helpers/proclaim/comments_helper_test.rb +6 -0
- data/test/helpers/proclaim/posts_helper_test.rb +6 -0
- data/test/helpers/proclaim/subscriptions_helper_test.rb +6 -0
- data/test/integration/with_javascript/comment_test.rb +353 -0
- data/test/integration/with_javascript/post_form_test.rb +179 -0
- data/test/integration/with_javascript/post_subscription_test.rb +273 -0
- data/test/integration/without_javascript/blog_subscription_test.rb +87 -0
- data/test/integration/without_javascript/post_test.rb +140 -0
- data/test/integration/without_javascript/subscription_email_test.rb +95 -0
- data/test/integration/without_javascript/unsubscribe_test.rb +32 -0
- data/test/mailers/previews/proclaim/subscription_mailer_preview.rb +22 -0
- data/test/mailers/proclaim/subscription_mailer_test.rb +87 -0
- data/test/models/proclaim/comment_test.rb +41 -0
- data/test/models/proclaim/image_test.rb +70 -0
- data/test/models/proclaim/post_test.rb +127 -0
- data/test/models/proclaim/subscription_test.rb +66 -0
- data/test/policies/proclaim/comment_policy_test.rb +71 -0
- data/test/policies/proclaim/post_policy_test.rb +87 -0
- data/test/policies/proclaim/subscription_policy_test.rb +91 -0
- data/test/proclaim_test.rb +7 -0
- data/test/support/images/test.jpg +0 -0
- data/test/support/pages/posts/edit_page.rb +5 -0
- data/test/support/pages/posts/show_page.rb +47 -0
- data/test/support/wait_for_ajax.rb +11 -0
- data/test/test_helper.rb +56 -0
- data/vendor/assets/images/link.png +0 -0
- data/vendor/assets/images/remove.png +0 -0
- data/vendor/assets/images/resize-bigger.png +0 -0
- data/vendor/assets/images/resize-smaller.png +0 -0
- data/vendor/assets/images/unlink.png +0 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.js +197 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.js +572 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.js +50 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.js +496 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.js +132 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.min.js +10 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.js +1415 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.min.js +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.css +55 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.min.css +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.css +277 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.min.css +10 -0
- metadata +791 -0
@@ -0,0 +1,10 @@
|
|
1
|
+
/*!
|
2
|
+
* medium-editor-insert-plugin v0.3.2 - jQuery insert plugin for MediumEditor
|
3
|
+
*
|
4
|
+
* https://github.com/orthes/medium-editor-insert-plugin
|
5
|
+
*
|
6
|
+
* Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
|
7
|
+
* Released under the MIT license
|
8
|
+
*/
|
9
|
+
|
10
|
+
!function(a){a.fn.mediumInsert.registerAddon("images",{defaults:{useDragAndDrop:!0,imagesUploadScript:"upload.php",imagesDeleteScript:"delete.php",urlPlaceholder:"Paste or type a link",formatData:function(a){var b=new FormData;return b.append("file",a),b},uploadFile:function(b,c,d){a.ajax({type:"post",url:d.options.imagesUploadScript,xhr:function(){var a=new XMLHttpRequest;return a.upload.onprogress=d.updateProgressBar,a},cache:!1,contentType:!1,complete:function(a){d.uploadCompleted(a,b)},processData:!1,data:d.options.formatData(c)})},deleteFile:function(b,c){a.ajax({type:"post",url:c.options.imagesDeleteScript,data:{file:b}})}},init:function(b){b&&b.$el&&(this.$el=b.$el),this.options=a.extend(this.defaults,b),this.setImageEvents(),this.options.useDragAndDrop===!0&&this.setDragAndDropEvents(),this.preparePreviousImages()},insertButton:function(a){var b="Img";return("fontawesome"===a||"object"==typeof a&&a.fontawesome)&&(b='<i class="fa fa-picture-o"></i>'),"object"==typeof a&&a.img&&(b=a.img),'<button data-addon="images" data-action="add" class="medium-editor-action mediumInsert-action">'+b+"</button>"},preparePreviousImages:function(){this.$el.find(".mediumInsert-images").each(function(){var b=a(this).parent();b.hasClass("mediumInsert-placeholder")||b.html(a.fn.mediumInsert.insert.getButtons("images")+'<div class="mediumInsert-placeholder" draggable="true">'+b.html()+"</div>")})},add:function(b){var c,d,e=this;return c=a('<input type="file" multiple="multiple">').click(),c.change(function(){d=this.files,e.uploadFiles(b,d,e)}),a.fn.mediumInsert.insert.deselect(),c},updateProgressBar:function(b){var c,d=a(".progress:first",this.$el);b.lengthComputable&&(c=b.loaded/b.total*100,c=c?c:0,d.attr("value",c),d.html(c))},uploadCompleted:function(b,c){var d,e=a(".progress:first",c);e.attr("value",100),e.html(100),b.responseText?(e.before('<figure class="mediumInsert-images"><img src="'+b.responseText+'" draggable="true" alt=""></figure>'),d=e.siblings("img"),d.load(function(){d.parent().mouseleave().mouseenter()})):(e.before('<div class="mediumInsert-error">There was a problem uploading the file.</div>'),setTimeout(function(){a(".mediumInsert-error:first",c).fadeOut(function(){a(this).remove()})},3e3)),e.remove(),c.closest("[data-medium-element]").trigger("keyup").trigger("input")},uploadFile:function(a,b,c){return c.options.uploadFile(a,b,c)},uploadFiles:function(a,b,c){for(var d={"image/png":!0,"image/jpeg":!0,"image/gif":!0},e=0;e<b.length;e++){var f=b[e];d[f.type]===!0&&(a.append('<progress class="progress" min="0" max="100" value="0">0</progress>'),c.uploadFile(a,f,c))}},deleteFile:function(a,b){return b.options.deleteFile(a,b)},setImageEvents:function(){var b=this;this.$el.on("mouseenter",".mediumInsert-images",function(){var b,c,d=a("img",this);a.fn.mediumInsert.settings.enabled!==!1&&d.length>0&&(a(this).append('<a class="mediumInsert-imageIcon mediumInsert-imageRemove"></a>'),0===a(this).prevAll().length&&a(this).append(a(this).parent().parent().hasClass("small")?'<a class="mediumInsert-imageIcon mediumInsert-imageResizeBigger"></a>':'<a class="mediumInsert-imageIcon mediumInsert-imageResizeSmaller"></a>'),0===a(this).siblings().length&&a(this).append(d.parent().is("a")?'<a class="mediumInsert-imageIcon mediumInsert-imageUnlink"></a>':'<a class="mediumInsert-imageIcon mediumInsert-imageLink"></a>'),b=d.position().top+parseInt(d.css("margin-top"),10),c=d.position().left+d.width()-30,a(".mediumInsert-imageRemove",this).css({right:"auto",top:b,left:c}),a(".mediumInsert-imageResizeBigger, .mediumInsert-imageResizeSmaller",this).css({right:"auto",top:b,left:c-31}),a(".mediumInsert-imageLink, .mediumInsert-imageUnlink",this).css({right:"auto",top:b,left:c-62}))}),this.$el.on("mouseleave",".mediumInsert-images",function(){a(".mediumInsert-imageIcon",this).remove()}),this.$el.on("click",".mediumInsert-imageResizeSmaller",function(){a(this).parent().parent().parent().addClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageResizeBigger",function(){a(this).parent().parent().parent().removeClass("small"),a(this).parent().mouseleave().mouseleave(),a.fn.mediumInsert.insert.deselect(),b.$el.trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageRemove",function(){var c=a(this).siblings("img").attr("src");0===a(this).parent().siblings().length&&a(this).parent().parent().parent().removeClass("small"),a(this).parent().remove(),b.deleteFile(c,b),a.fn.mediumInsert.insert.deselect(),b.$el.trigger("keyup").trigger("input")}),this.$el.on("click",".mediumInsert-imageLink",function(){var c=a(this).closest(".mediumInsert-placeholder"),d=a('<div class="medium-editor-toolbar medium-editor-toolbar-active medium-editor-toolbar-form-anchor mediumInsert-imageLinkWire" style="display: block;"><input type="text" value="" placeholder="'+b.options.urlPlaceholder+'" class="mediumInsert-imageLinkText medium-editor-toolbar-anchor-input"></div>');d.appendTo(c),setTimeout(function(){d.find("input").focus()},50),a.fn.mediumInsert.insert.deselect()}),this.$el.on("click",".mediumInsert-imageUnlink",function(){var c=a(this).closest(".mediumInsert-images");c.find("img").unwrap(),a(this).removeClass("mediumInsert-imageUnlink").addClass("mediumInsert-imageLink"),b.$el.trigger("keyup").trigger("input")}),this.$el.on("keypress",".mediumInsert-imageLinkText",function(c){var d=a(this).closest(".mediumInsert-placeholder");if(c.which&&13===c.which||c.keyCode&&13===c.keyCode){d.find(".mediumInsert-images:first").find("img").wrap('<a href="'+a(this).val()+'" target="_blank"></a>'),d.find(".mediumInsert-imageLink").removeClass("mediumInsert-imageLink").addClass("mediumInsert-imageUnlink");try{a(".mediumInsert-imageLinkWire").remove()}catch(e){}b.$el.trigger("keyup").trigger("input")}}).on("blur",".mediumInsert-imageLinkText",function(){a(".mediumInsert-imageLinkWire").remove()}).on("paste",".mediumInsert-imageLinkText",function(b){a.fn.mediumInsert.insert.isFirefox&&b.originalEvent.clipboardData&&a(this).val(b.originalEvent.clipboardData.getData("text/plain"))})},setDragAndDropEvents:function(){var b,c,d=this,e=!1,f=!1;a(document).on("dragover","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.addClass("hover")}),a(document).on("dragend","body",function(){a.fn.mediumInsert.settings.enabled!==!1&&d.$el.removeClass("hover")}),this.$el.on("dragover",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).addClass("hover"),a(this).attr("contenteditable",!0))}),this.$el.on("dragleave",".mediumInsert",function(){a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),a(this).attr("contenteditable",!1))}),this.$el.on("dragstart",".mediumInsert .mediumInsert-images img",function(){a.fn.mediumInsert.settings.enabled!==!1&&(b=a(this).parent().index(),c=a(this).parent().parent().parent().attr("id"))}),this.$el.on("dragend",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&e===!0&&(0===a(b.originalEvent.target.parentNode).siblings().length&&a(b.originalEvent.target.parentNode).parent().parent().removeClass("small"),a(b.originalEvent.target.parentNode).mouseleave(),a(b.originalEvent.target.parentNode).remove(),e=!1,f=!1,d.$el.trigger("keyup").trigger("input"))}),this.$el.on("dragover",".mediumInsert .mediumInsert-images img",function(b){a.fn.mediumInsert.settings.enabled!==!1&&b.preventDefault()}),this.$el.on("drop",".mediumInsert .mediumInsert-images img",function(){var e,g,h;if(a.fn.mediumInsert.settings.enabled!==!1){if(c!==a(this).parent().parent().parent().attr("id"))return f=!1,void(b=c=null);e=parseInt(b,10),g=a(this).parent().parent().find(".mediumInsert-images:nth-child("+(e+1)+")"),h=a(this).parent().index(),h>e?g.insertAfter(a(this).parent()):e>h&&g.insertBefore(a(this).parent()),g.mouseleave(),f=!0,b=null,d.$el.trigger("keyup").trigger("input")}}),this.$el.on("drop",".mediumInsert",function(b){var c;b.preventDefault(),a.fn.mediumInsert.settings.enabled!==!1&&(a(this).removeClass("hover"),d.$el.removeClass("hover"),a(this).attr("contenteditable",!1),c=b.originalEvent.dataTransfer.files,c.length>0?d.uploadFiles(a(".mediumInsert-placeholder",this),c,d):f===!0?f=!1:(a(".mediumInsert-placeholder",this).append('<figure class="mediumInsert-images">'+b.originalEvent.dataTransfer.getData("text/html")+"</figure>"),a("meta",this).remove(),e=!0))})}})}(jQuery);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/*!
|
2
|
+
* medium-editor-insert-plugin v0.3.2 - jQuery insert plugin for MediumEditor
|
3
|
+
*
|
4
|
+
* https://github.com/orthes/medium-editor-insert-plugin
|
5
|
+
*
|
6
|
+
* Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
|
7
|
+
* Released under the MIT license
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function ($) {
|
11
|
+
|
12
|
+
$.fn.mediumInsert.registerAddon('maps', {
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Maps initial function
|
16
|
+
* @return {void}
|
17
|
+
*/
|
18
|
+
|
19
|
+
init: function () {
|
20
|
+
this.$el = $.fn.mediumInsert.insert.$el;
|
21
|
+
},
|
22
|
+
|
23
|
+
insertButton: function(buttonLabels){
|
24
|
+
var label = 'Map';
|
25
|
+
if (buttonLabels === 'fontawesome' || typeof buttonLabels === 'object' && !!(buttonLabels.fontawesome)) {
|
26
|
+
label = '<i class="fa fa-map-marker"></i>';
|
27
|
+
}
|
28
|
+
|
29
|
+
if (typeof buttonLabels === 'object' && buttonLabels.map) {
|
30
|
+
label = buttonLabels.map;
|
31
|
+
}
|
32
|
+
|
33
|
+
return '<button data-addon="maps" data-action="add" class="medium-editor-action mediumInsert-action">'+label+'</button>';
|
34
|
+
},
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Add map to placeholder
|
38
|
+
* @param {element} placeholder Placeholder to add map to
|
39
|
+
* @return {void}
|
40
|
+
*/
|
41
|
+
|
42
|
+
add: function (placeholder) {
|
43
|
+
$.fn.mediumInsert.insert.deselect();
|
44
|
+
|
45
|
+
placeholder.append('<div class="mediumInsert-maps">Map - Coming soon...</div>');
|
46
|
+
}
|
47
|
+
|
48
|
+
});
|
49
|
+
|
50
|
+
}(jQuery));
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*!
|
2
|
+
* medium-editor-insert-plugin v0.3.2 - jQuery insert plugin for MediumEditor
|
3
|
+
*
|
4
|
+
* https://github.com/orthes/medium-editor-insert-plugin
|
5
|
+
*
|
6
|
+
* Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
|
7
|
+
* Released under the MIT license
|
8
|
+
*/
|
9
|
+
|
10
|
+
!function(a){a.fn.mediumInsert.registerAddon("maps",{init:function(){this.$el=a.fn.mediumInsert.insert.$el},insertButton:function(a){var b="Map";return("fontawesome"===a||"object"==typeof a&&a.fontawesome)&&(b='<i class="fa fa-map-marker"></i>'),"object"==typeof a&&a.map&&(b=a.map),'<button data-addon="maps" data-action="add" class="medium-editor-action mediumInsert-action">'+b+"</button>"},add:function(b){a.fn.mediumInsert.insert.deselect(),b.append('<div class="mediumInsert-maps">Map - Coming soon...</div>')}})}(jQuery);
|
@@ -0,0 +1,496 @@
|
|
1
|
+
/*!
|
2
|
+
* medium-editor-insert-plugin v0.3.2 - jQuery insert plugin for MediumEditor
|
3
|
+
*
|
4
|
+
* https://github.com/orthes/medium-editor-insert-plugin
|
5
|
+
*
|
6
|
+
* Copyright (c) 2014 Pavel Linkesch (http://linkesch.sk)
|
7
|
+
* Released under the MIT license
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* global MediumEditor */
|
11
|
+
|
12
|
+
(function ($) {
|
13
|
+
/*
|
14
|
+
* Private storage of registered addons
|
15
|
+
*/
|
16
|
+
var addons = {};
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Extend MediumEditor functions if the editor exists
|
20
|
+
*/
|
21
|
+
if (MediumEditor && typeof(MediumEditor) === "function") {
|
22
|
+
/**
|
23
|
+
* Extend MediumEditor's serialize function to get rid of unnecesarry Medium Editor Insert Plugin stuff
|
24
|
+
*
|
25
|
+
* @return {object} content Object containing HTML content of each element
|
26
|
+
*/
|
27
|
+
|
28
|
+
MediumEditor.prototype.serialize = function () {
|
29
|
+
var i, j,
|
30
|
+
elementid,
|
31
|
+
content = {},
|
32
|
+
$clone, $inserts, $insert, $insertData, html;
|
33
|
+
for (i = 0; i < this.elements.length; i += 1) {
|
34
|
+
elementid = (this.elements[i].id !== '') ? this.elements[i].id : 'element-' + i;
|
35
|
+
|
36
|
+
$clone = $(this.elements[i]).clone();
|
37
|
+
$inserts = $('.mediumInsert', $clone);
|
38
|
+
for (j = 0; j < $inserts.length; j++) {
|
39
|
+
$insert = $($inserts[j]);
|
40
|
+
$insertData = $('.mediumInsert-placeholder', $insert).children();
|
41
|
+
if ($insertData.length === 0) {
|
42
|
+
$insert.remove();
|
43
|
+
} else {
|
44
|
+
$insert.removeAttr('contenteditable');
|
45
|
+
$('img[draggable]', $insert).removeAttr('draggable');
|
46
|
+
if ($insert.hasClass('small')) {
|
47
|
+
$insertData.addClass('small');
|
48
|
+
}
|
49
|
+
$('.mediumInsert-buttons', $insert).remove();
|
50
|
+
$insertData.unwrap();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
html = $clone.html().trim();
|
55
|
+
content[elementid] = {
|
56
|
+
value: html
|
57
|
+
};
|
58
|
+
}
|
59
|
+
return content;
|
60
|
+
};
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Extend MediumEditor's deactivate function to call $.fn.mediumInsert.insert.disable function
|
64
|
+
*
|
65
|
+
* @return {void}
|
66
|
+
*/
|
67
|
+
|
68
|
+
MediumEditor.prototype.deactivate = function () {
|
69
|
+
var i;
|
70
|
+
if (!this.isActive) {
|
71
|
+
return false;
|
72
|
+
}
|
73
|
+
this.isActive = false;
|
74
|
+
|
75
|
+
if (this.toolbar !== undefined) {
|
76
|
+
this.toolbar.style.display = 'none';
|
77
|
+
}
|
78
|
+
|
79
|
+
document.documentElement.removeEventListener('mouseup', this.checkSelectionWrapper);
|
80
|
+
|
81
|
+
for (i = 0; i < this.elements.length; i += 1) {
|
82
|
+
this.elements[i].removeEventListener('keyup', this.checkSelectionWrapper);
|
83
|
+
this.elements[i].removeEventListener('blur', this.checkSelectionWrapper);
|
84
|
+
this.elements[i].removeAttribute('contentEditable');
|
85
|
+
}
|
86
|
+
|
87
|
+
if ($.fn.mediumInsert.insert.$el)
|
88
|
+
$.fn.mediumInsert.insert.$el.mediumInsert('disable');
|
89
|
+
};
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Extend MediumEditor's activate function to call $.fn.mediumInsert.insert.enable function
|
93
|
+
*
|
94
|
+
* @return {void}
|
95
|
+
*/
|
96
|
+
|
97
|
+
MediumEditor.prototype.activate = function () {
|
98
|
+
var i;
|
99
|
+
if (this.isActive) {
|
100
|
+
return false;
|
101
|
+
}
|
102
|
+
|
103
|
+
if (this.toolbar !== undefined) {
|
104
|
+
this.toolbar.style.display = 'block';
|
105
|
+
}
|
106
|
+
|
107
|
+
this.isActive = true;
|
108
|
+
for (i = 0; i < this.elements.length; i += 1) {
|
109
|
+
this.elements[i].setAttribute('contentEditable', true);
|
110
|
+
}
|
111
|
+
this.bindSelect();
|
112
|
+
|
113
|
+
if ($.fn.mediumInsert.insert.$el)
|
114
|
+
$.fn.mediumInsert.insert.$el.mediumInsert('enable');
|
115
|
+
};
|
116
|
+
}
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Medium Editor Insert Plugin
|
120
|
+
*
|
121
|
+
* @param {object} options Options for the plugin
|
122
|
+
* @param {void}
|
123
|
+
*/
|
124
|
+
|
125
|
+
$.fn.mediumInsert = function (options) {
|
126
|
+
|
127
|
+
if (typeof options === 'string' && $.fn.mediumInsert.insert[options]) {
|
128
|
+
$.fn.mediumInsert.insert[options]();
|
129
|
+
} else {
|
130
|
+
$.fn.mediumInsert.settings = $.extend($.fn.mediumInsert.settings, options);
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Initial plugin loop
|
136
|
+
*/
|
137
|
+
|
138
|
+
return this.each(function () {
|
139
|
+
$(this).addClass('medium-editor-insert-plugin');
|
140
|
+
|
141
|
+
var blocks = 'p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote';
|
142
|
+
$(this).on('dragover drop', blocks, function (e) {
|
143
|
+
e.preventDefault();
|
144
|
+
return false;
|
145
|
+
});
|
146
|
+
|
147
|
+
$.fn.mediumInsert.insert.init($(this));
|
148
|
+
|
149
|
+
$.each($.fn.mediumInsert.settings.addons, function (i) {
|
150
|
+
if (typeof addons[i] !== 'undefined') {
|
151
|
+
var addonOptions = $.fn.mediumInsert.settings.addons[i];
|
152
|
+
addonOptions.$el = $.fn.mediumInsert.insert.$el;
|
153
|
+
addons[i].init(addonOptions);
|
154
|
+
}
|
155
|
+
});
|
156
|
+
});
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Settings
|
163
|
+
*/
|
164
|
+
$.fn.mediumInsert.settings = {
|
165
|
+
enabled: true,
|
166
|
+
beginning: false,
|
167
|
+
addons: {
|
168
|
+
images: {},
|
169
|
+
embeds: {}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Register new addon
|
175
|
+
*/
|
176
|
+
$.fn.mediumInsert.registerAddon = function(name, addon){
|
177
|
+
addons[name] = addon;
|
178
|
+
};
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Get registered addon
|
182
|
+
*/
|
183
|
+
$.fn.mediumInsert.getAddon = function(name){
|
184
|
+
return addons[name];
|
185
|
+
};
|
186
|
+
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Addon Initialization
|
190
|
+
*/
|
191
|
+
|
192
|
+
$.fn.mediumInsert.insert = {
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Insert initial function
|
196
|
+
*
|
197
|
+
* @param {element} el Parent container element
|
198
|
+
* @return {void}
|
199
|
+
*/
|
200
|
+
|
201
|
+
init: function ($el) {
|
202
|
+
this.$el = $el;
|
203
|
+
this.isFirefox = navigator.userAgent.match(/firefox/i);
|
204
|
+
this.setPlaceholders();
|
205
|
+
this.setEvents();
|
206
|
+
},
|
207
|
+
|
208
|
+
/**
|
209
|
+
* Deselect selected text
|
210
|
+
*
|
211
|
+
* @return {void}
|
212
|
+
*/
|
213
|
+
|
214
|
+
deselect: function () {
|
215
|
+
document.getSelection().removeAllRanges();
|
216
|
+
},
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Disable the plugin
|
220
|
+
*
|
221
|
+
* @return {void}
|
222
|
+
*/
|
223
|
+
|
224
|
+
disable: function () {
|
225
|
+
$.fn.mediumInsert.settings.enabled = false;
|
226
|
+
|
227
|
+
$.fn.mediumInsert.insert.$el.find('.mediumInsert-buttons').addClass('hide');
|
228
|
+
},
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Enable the plugin
|
232
|
+
*
|
233
|
+
* @return {void}
|
234
|
+
*/
|
235
|
+
|
236
|
+
enable: function () {
|
237
|
+
$.fn.mediumInsert.settings.enabled = true;
|
238
|
+
|
239
|
+
$.fn.mediumInsert.insert.$el.find('.mediumInsert-buttons').removeClass('hide');
|
240
|
+
},
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Return max id in #mediumInsert-*
|
244
|
+
*
|
245
|
+
* @return {int} max (Max number, -1 if no placeholders exist)
|
246
|
+
*/
|
247
|
+
getMaxId: function () {
|
248
|
+
var max = -1;
|
249
|
+
|
250
|
+
$('div[id^="mediumInsert-"]').each(function () {
|
251
|
+
var id = parseInt($(this).attr('id').split('-')[1], 10);
|
252
|
+
if (id > max) {
|
253
|
+
max = id;
|
254
|
+
}
|
255
|
+
});
|
256
|
+
|
257
|
+
return max;
|
258
|
+
},
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Return insert buttons optionally filtered by addon name
|
262
|
+
*
|
263
|
+
* @param {string} addon Addon name of addon to display only
|
264
|
+
* @return {void}
|
265
|
+
*/
|
266
|
+
getButtons: function (addon) {
|
267
|
+
var editor = $.fn.mediumInsert.settings.editor,
|
268
|
+
buttonLabels = (editor && editor.options) ? editor.options.buttonLabels : '';
|
269
|
+
|
270
|
+
var buttons;
|
271
|
+
if($.fn.mediumInsert.settings.enabled) {
|
272
|
+
buttons = '<div class="mediumInsert-buttons">'+
|
273
|
+
'<a class="mediumInsert-buttonsShow">+</a>'+
|
274
|
+
'<ul class="mediumInsert-buttonsOptions medium-editor-toolbar medium-editor-toolbar-active">';
|
275
|
+
} else {
|
276
|
+
buttons = '<div class="mediumInsert-buttons hide">'+
|
277
|
+
'<a class="mediumInsert-buttonsShow">+</a>'+
|
278
|
+
'<ul class="mediumInsert-buttonsOptions medium-editor-toolbar medium-editor-toolbar-active">';
|
279
|
+
}
|
280
|
+
|
281
|
+
if (Object.keys($.fn.mediumInsert.settings.addons).length === 0) {
|
282
|
+
return false;
|
283
|
+
}
|
284
|
+
|
285
|
+
if (typeof addon === 'undefined') {
|
286
|
+
$.each($.fn.mediumInsert.settings.addons, function (i) {
|
287
|
+
if (typeof addons[i] === 'undefined') {
|
288
|
+
console.log('Addon "' + i + '" is not available. Did you forgot to include the related file?');
|
289
|
+
} else {
|
290
|
+
buttons += '<li>' + addons[i].insertButton(buttonLabels) + '</li>';
|
291
|
+
}
|
292
|
+
});
|
293
|
+
} else {
|
294
|
+
buttons += '<li>' + addons[addon].insertButton(buttonLabels) + '</li>';
|
295
|
+
}
|
296
|
+
|
297
|
+
buttons += '</ul></div>';
|
298
|
+
|
299
|
+
return buttons;
|
300
|
+
},
|
301
|
+
|
302
|
+
/**
|
303
|
+
* Method setting placeholders
|
304
|
+
*
|
305
|
+
* @return {void}
|
306
|
+
*/
|
307
|
+
|
308
|
+
setPlaceholders: function () {
|
309
|
+
var that = this,
|
310
|
+
$el = $.fn.mediumInsert.insert.$el,
|
311
|
+
insertBlock = this.getButtons(),
|
312
|
+
$firstEl;
|
313
|
+
|
314
|
+
if (insertBlock === false) {
|
315
|
+
return false;
|
316
|
+
}
|
317
|
+
|
318
|
+
insertBlock = '<div class="mediumInsert" contenteditable="false">'+
|
319
|
+
insertBlock +
|
320
|
+
'<div class="mediumInsert-placeholder"></div>'+
|
321
|
+
'</div>';
|
322
|
+
|
323
|
+
if ($el.is(':empty')) {
|
324
|
+
$el.html('<p><br></p>');
|
325
|
+
}
|
326
|
+
|
327
|
+
$el.keyup(function () {
|
328
|
+
var $lastChild = $el.children(':last'),
|
329
|
+
i;
|
330
|
+
|
331
|
+
// Fix #39
|
332
|
+
// After deleting all content (ctrl+A and delete) in Firefox, all content is deleted and only <br> appears
|
333
|
+
// To force placeholder to appear, set <p><br></p> as content of the $el
|
334
|
+
if ($el.html() === '' || $el.html() === '<br>') {
|
335
|
+
$el.html('<p><br></p>');
|
336
|
+
}
|
337
|
+
|
338
|
+
if ($lastChild.hasClass('mediumInsert') && $lastChild.find('.mediumInsert-placeholder').children().length > 0) {
|
339
|
+
$el.append('<p><br></p>');
|
340
|
+
}
|
341
|
+
|
342
|
+
// Fix not deleting placeholder in Firefox
|
343
|
+
// by removing all empty placeholders
|
344
|
+
if (that.isFirefox){
|
345
|
+
$('.mediumInsert .mediumInsert-placeholder:empty', $el).each(function () {
|
346
|
+
$(this).parent().remove();
|
347
|
+
});
|
348
|
+
}
|
349
|
+
|
350
|
+
i = that.getMaxId() +1;
|
351
|
+
|
352
|
+
var blocks = 'p, h1, h2, h3, h4, h5, h6, ol, ul, blockquote';
|
353
|
+
|
354
|
+
if ($.fn.mediumInsert.settings.beginning) {
|
355
|
+
$firstEl = $el.children(blocks).first();
|
356
|
+
if ($firstEl.prev().hasClass('mediumInsert') === false) {
|
357
|
+
$firstEl.before(insertBlock);
|
358
|
+
$firstEl.prev('.mediumInsert').attr('id', 'mediumInsert-'+ i).addClass('mediumInsert-first');
|
359
|
+
i++;
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
$el.children(blocks).each(function () {
|
364
|
+
if ($(this).next().hasClass('mediumInsert') === false) {
|
365
|
+
$(this).after(insertBlock);
|
366
|
+
$(this).next('.mediumInsert').attr('id', 'mediumInsert-'+ i);
|
367
|
+
}
|
368
|
+
i++;
|
369
|
+
});
|
370
|
+
|
371
|
+
}).keyup();
|
372
|
+
},
|
373
|
+
|
374
|
+
|
375
|
+
/**
|
376
|
+
* Set events on placeholders
|
377
|
+
*
|
378
|
+
* @return {void}
|
379
|
+
*/
|
380
|
+
|
381
|
+
setEvents: function () {
|
382
|
+
var that = this,
|
383
|
+
$el = $.fn.mediumInsert.insert.$el;
|
384
|
+
|
385
|
+
$el.on('selectstart mousedown', '.mediumInsert', function (e) {
|
386
|
+
if ($(e.target).is('img') === false) {
|
387
|
+
e.preventDefault();
|
388
|
+
}
|
389
|
+
});
|
390
|
+
|
391
|
+
$el.on('blur', function () {
|
392
|
+
var $clone = $(this).clone(),
|
393
|
+
cloneHtml;
|
394
|
+
|
395
|
+
$clone.find('.mediumInsert').remove();
|
396
|
+
cloneHtml = $clone.html().replace(/^\s+|\s+$/g, '');
|
397
|
+
|
398
|
+
if (cloneHtml === '' || cloneHtml === '<p><br></p>') {
|
399
|
+
$(this).addClass('medium-editor-placeholder');
|
400
|
+
}
|
401
|
+
});
|
402
|
+
|
403
|
+
|
404
|
+
// Fix #29
|
405
|
+
// Sometimes in Firefox when you hit enter, <br type="_moz"> appears instead of <p><br></p>
|
406
|
+
// If it happens, force to wrap the <br> into a paragraph
|
407
|
+
$el.on('keypress', function (e) {
|
408
|
+
if (that.isFirefox) {
|
409
|
+
if (e.keyCode === 13) {
|
410
|
+
//wrap content text in p to avoid firefox problems
|
411
|
+
$el.contents().each((function() {
|
412
|
+
return function(index, field) {
|
413
|
+
if (field.nodeName === '#text' && field.textContent.trim() !== '') {
|
414
|
+
document.execCommand('insertHTML', false, "<p>" + field.data + "</p>");
|
415
|
+
return field.remove();
|
416
|
+
}
|
417
|
+
};
|
418
|
+
})(this));
|
419
|
+
// Removed because of #94 issue
|
420
|
+
//
|
421
|
+
// Firefox add extra br tag inside p tag
|
422
|
+
// var latestPTag = $el.find('p').last();
|
423
|
+
// if (latestPTag.text().length > 0) {
|
424
|
+
// latestPTag.find('br').remove();
|
425
|
+
// }
|
426
|
+
}
|
427
|
+
}
|
428
|
+
});
|
429
|
+
|
430
|
+
// Fix #39
|
431
|
+
// For some reason Chrome doesn't "select-all", when the last placeholder is visible.
|
432
|
+
// So it's needed to hide it when the user "selects all", and show it again when they presses any other key.
|
433
|
+
$el.on('keydown', function (e) {
|
434
|
+
// Fix Select-all using (ctrl + a) in chrome
|
435
|
+
if (navigator.userAgent.match(/chrome/i)) {
|
436
|
+
$el.children().last().removeClass('hide');
|
437
|
+
if ( (e.ctrlKey || e.metaKey) && e.which === 65) {
|
438
|
+
e.preventDefault();
|
439
|
+
if($el.find('p').text().trim().length === 0) {
|
440
|
+
return false;
|
441
|
+
}
|
442
|
+
|
443
|
+
$el.children().last().addClass('hide');
|
444
|
+
return document.execCommand('selectAll', false, null);
|
445
|
+
}
|
446
|
+
}
|
447
|
+
});
|
448
|
+
|
449
|
+
$el.on('click', '.mediumInsert-buttons a.mediumInsert-buttonsShow', function () {
|
450
|
+
var $options = $(this).siblings('.mediumInsert-buttonsOptions'),
|
451
|
+
$placeholder = $(this).parent().siblings('.mediumInsert-placeholder');
|
452
|
+
|
453
|
+
if ($(this).hasClass('active')) {
|
454
|
+
$(this).removeClass('active');
|
455
|
+
$options.hide();
|
456
|
+
|
457
|
+
$('a', $options).show();
|
458
|
+
} else {
|
459
|
+
$(this).addClass('active');
|
460
|
+
$options.show();
|
461
|
+
|
462
|
+
$('a', $options).each(function () {
|
463
|
+
var aClass = $(this).attr('class').split('action-')[1],
|
464
|
+
plugin = aClass.split('-')[0];
|
465
|
+
if ($('.mediumInsert-'+ plugin, $placeholder).length > 0) {
|
466
|
+
$('a:not(.action-'+ aClass +')', $options).hide();
|
467
|
+
}
|
468
|
+
});
|
469
|
+
}
|
470
|
+
|
471
|
+
that.deselect();
|
472
|
+
});
|
473
|
+
|
474
|
+
$el.on('mouseleave', '.mediumInsert', function () {
|
475
|
+
$('a.mediumInsert-buttonsShow', this).removeClass('active');
|
476
|
+
$('.mediumInsert-buttonsOptions', this).hide();
|
477
|
+
});
|
478
|
+
|
479
|
+
$el.on('click', '.mediumInsert-buttons .mediumInsert-action', function (e) {
|
480
|
+
e.preventDefault();
|
481
|
+
|
482
|
+
var addon = $(this).data('addon'),
|
483
|
+
action = $(this).data('action'),
|
484
|
+
$placeholder = $(this).parents('.mediumInsert-buttons').siblings('.mediumInsert-placeholder');
|
485
|
+
|
486
|
+
if (addons[addon] && addons[addon][action]) {
|
487
|
+
addons[addon][action]($placeholder);
|
488
|
+
}
|
489
|
+
|
490
|
+
$(this).parents('.mediumInsert').mouseleave();
|
491
|
+
});
|
492
|
+
}
|
493
|
+
|
494
|
+
};
|
495
|
+
|
496
|
+
}(jQuery));
|