publify_core 9.1.0 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of publify_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -1
- data/app/assets/javascripts/bootstrap-sprockets.js +8 -0
- data/app/assets/javascripts/bootstrap/affix.js +164 -0
- data/app/assets/javascripts/bootstrap/alert.js +95 -0
- data/app/assets/javascripts/bootstrap/button.js +125 -0
- data/app/assets/javascripts/bootstrap/collapse.js +212 -0
- data/app/assets/javascripts/bootstrap/dropdown.js +165 -0
- data/app/assets/javascripts/bootstrap/modal.js +358 -0
- data/app/assets/javascripts/bootstrap/tab.js +155 -0
- data/app/assets/javascripts/bootstrap/transition.js +59 -0
- data/app/assets/javascripts/lightbox.js +4 -4
- data/app/assets/javascripts/publify_admin.js +1 -35
- data/app/assets/stylesheets/_bootstrap-compass.scss +9 -0
- data/app/assets/stylesheets/_bootstrap-mincer.scss +19 -0
- data/app/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
- data/app/assets/stylesheets/_bootstrap.scss +42 -0
- data/app/assets/stylesheets/administration_structure.css.scss +1 -45
- data/app/assets/stylesheets/bootstrap/_alerts.scss +73 -0
- data/app/assets/stylesheets/bootstrap/_button-groups.scss +242 -0
- data/app/assets/stylesheets/bootstrap/_buttons.scss +168 -0
- data/app/assets/stylesheets/bootstrap/_close.scss +37 -0
- data/app/assets/stylesheets/bootstrap/_code.scss +69 -0
- data/app/assets/stylesheets/bootstrap/_component-animations.scss +38 -0
- data/app/assets/stylesheets/bootstrap/_dropdowns.scss +213 -0
- data/app/assets/stylesheets/bootstrap/_forms.scss +586 -0
- data/app/assets/stylesheets/bootstrap/_grid.scss +94 -0
- data/app/assets/stylesheets/bootstrap/_labels.scss +66 -0
- data/app/assets/stylesheets/bootstrap/_media.scss +66 -0
- data/app/assets/stylesheets/bootstrap/_mixins.scss +37 -0
- data/app/assets/stylesheets/bootstrap/_modals.scss +150 -0
- data/app/assets/stylesheets/bootstrap/_navbar.scss +479 -0
- data/app/assets/stylesheets/bootstrap/_navs.scss +242 -0
- data/app/assets/stylesheets/bootstrap/_normalize.scss +427 -0
- data/app/assets/stylesheets/bootstrap/_pagination.scss +86 -0
- data/app/assets/stylesheets/bootstrap/_panels.scss +222 -0
- data/app/assets/stylesheets/bootstrap/_print.scss +99 -0
- data/app/assets/stylesheets/bootstrap/_scaffolding.scss +160 -0
- data/app/assets/stylesheets/bootstrap/_tables.scss +234 -0
- data/app/assets/stylesheets/bootstrap/_theme.scss +224 -0
- data/app/assets/stylesheets/bootstrap/_type.scss +296 -0
- data/app/assets/stylesheets/bootstrap/_utilities.scss +55 -0
- data/app/assets/stylesheets/bootstrap/_variables.scss +638 -0
- data/app/assets/stylesheets/bootstrap/_wells.scss +29 -0
- data/app/assets/stylesheets/bootstrap/mixins/_alerts.scss +15 -0
- data/app/assets/stylesheets/bootstrap/mixins/_background-variant.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
- data/app/assets/stylesheets/bootstrap/mixins/_buttons.scss +56 -0
- data/app/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
- data/app/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
- data/app/assets/stylesheets/bootstrap/mixins/_forms.scss +82 -0
- data/app/assets/stylesheets/bootstrap/mixins/_gradients.scss +56 -0
- data/app/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
- data/app/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
- data/app/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
- data/app/assets/stylesheets/bootstrap/mixins/_image.scss +28 -0
- data/app/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
- data/app/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/app/assets/stylesheets/bootstrap/mixins/_opacity.scss +7 -0
- data/app/assets/stylesheets/bootstrap/mixins/_pagination.scss +24 -0
- data/app/assets/stylesheets/bootstrap/mixins/_panels.scss +20 -0
- data/app/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
- data/app/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +17 -0
- data/app/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
- data/app/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
- data/app/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
- data/app/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +12 -0
- data/app/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
- data/app/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -0
- data/app/assets/stylesheets/lightbox.css +3 -3
- data/app/assets/stylesheets/publify_admin.css.scss +0 -1
- data/app/controllers/accounts_controller.rb +2 -0
- data/app/controllers/admin/base_controller.rb +8 -5
- data/app/controllers/admin/content_controller.rb +37 -24
- data/app/controllers/admin/dashboard_controller.rb +16 -64
- data/app/controllers/admin/feedback_controller.rb +45 -38
- data/app/controllers/admin/notes_controller.rb +15 -9
- data/app/controllers/admin/pages_controller.rb +18 -15
- data/app/controllers/admin/post_types_controller.rb +7 -5
- data/app/controllers/admin/profiles_controller.rb +4 -2
- data/app/controllers/admin/redirects_controller.rb +9 -5
- data/app/controllers/admin/resources_controller.rb +7 -4
- data/app/controllers/admin/seo_controller.rb +14 -10
- data/app/controllers/admin/settings_controller.rb +7 -5
- data/app/controllers/admin/sidebar_controller.rb +7 -4
- data/app/controllers/admin/tags_controller.rb +6 -3
- data/app/controllers/admin/themes_controller.rb +10 -7
- data/app/controllers/admin/users_controller.rb +9 -6
- data/app/controllers/articles_controller.rb +49 -33
- data/app/controllers/authors_controller.rb +6 -3
- data/app/controllers/base_controller.rb +9 -5
- data/app/controllers/comments_controller.rb +12 -8
- data/app/controllers/content_controller.rb +4 -2
- data/app/controllers/feedback_controller.rb +4 -2
- data/app/controllers/notes_controller.rb +5 -3
- data/app/controllers/setup_controller.rb +14 -10
- data/app/controllers/tags_controller.rb +6 -4
- data/app/controllers/text_controller.rb +2 -4
- data/app/controllers/textfilter_controller.rb +2 -0
- data/app/controllers/theme_controller.rb +14 -12
- data/app/controllers/xml_controller.rb +2 -0
- data/app/helpers/admin/base_helper.rb +28 -28
- data/app/helpers/admin/feedback_helper.rb +34 -24
- data/app/helpers/articles_helper.rb +4 -2
- data/app/helpers/authors_helper.rb +6 -3
- data/app/helpers/base_helper.rb +50 -34
- data/app/helpers/blog_helper.rb +4 -2
- data/app/helpers/xml_helper.rb +2 -0
- data/app/jobs/application_job.rb +2 -0
- data/app/mailers/notification_mailer.rb +5 -3
- data/app/models/ability.rb +25 -23
- data/app/models/archives_sidebar.rb +14 -11
- data/app/models/article.rb +44 -32
- data/app/models/article/factory.rb +14 -6
- data/app/models/blog.rb +85 -65
- data/app/models/comment.rb +10 -7
- data/app/models/config_manager.rb +4 -2
- data/app/models/content.rb +34 -40
- data/app/models/content_base.rb +9 -3
- data/app/models/feedback.rb +19 -16
- data/app/models/meta_sidebar.rb +5 -2
- data/app/models/note.rb +25 -23
- data/app/models/page.rb +8 -6
- data/app/models/page_sidebar.rb +4 -2
- data/app/models/ping.rb +2 -0
- data/app/models/post_type.rb +3 -1
- data/app/models/redirect.rb +11 -6
- data/app/models/redirection.rb +2 -0
- data/app/models/resource.rb +4 -2
- data/app/models/search_sidebar.rb +4 -2
- data/app/models/sidebar.rb +10 -5
- data/app/models/static_sidebar.rb +15 -12
- data/app/models/tag.rb +14 -10
- data/app/models/tag_sidebar.rb +6 -3
- data/app/models/text_filter.rb +85 -11
- data/app/models/trackback.rb +7 -11
- data/app/models/trigger.rb +6 -3
- data/app/models/user.rb +43 -42
- data/app/services/title_builder.rb +56 -45
- data/app/uploaders/resource_uploader.rb +7 -3
- data/app/views/accounts/confirm.html.erb +3 -3
- data/app/views/admin/content/_article_list.html.erb +23 -8
- data/app/views/admin/content/_form.html.erb +71 -47
- data/app/views/admin/content/edit.html.erb +1 -1
- data/app/views/admin/content/index.html.erb +25 -15
- data/app/views/admin/content/new.html.erb +2 -2
- data/app/views/admin/dashboard/_comment.html.erb +5 -5
- data/app/views/admin/dashboard/_comments.html.erb +2 -2
- data/app/views/admin/dashboard/_drafts.html.erb +5 -5
- data/app/views/admin/dashboard/_overview.html.erb +7 -9
- data/app/views/admin/dashboard/_welcome.html.erb +11 -11
- data/app/views/admin/dashboard/index.html.erb +12 -7
- data/app/views/admin/feedback/_button.html.erb +6 -6
- data/app/views/admin/feedback/_feedback.html.erb +3 -3
- data/app/views/admin/feedback/_ham.html.erb +27 -9
- data/app/views/admin/feedback/_spam.html.erb +26 -16
- data/app/views/admin/feedback/article.html.erb +20 -21
- data/app/views/admin/feedback/edit.html.erb +14 -15
- data/app/views/admin/feedback/{ham.js → ham.js.erb} +0 -0
- data/app/views/admin/feedback/index.html.erb +25 -23
- data/app/views/admin/feedback/{spam.js → spam.js.erb} +0 -0
- data/app/views/admin/migrations/show.html.erb +10 -11
- data/app/views/admin/notes/_form.html.erb +13 -13
- data/app/views/admin/notes/_list.html.erb +19 -8
- data/app/views/admin/notes/_note.html.erb +12 -7
- data/app/views/admin/notes/edit.html.erb +6 -1
- data/app/views/admin/notes/index.html.erb +5 -1
- data/app/views/admin/notes/show.html.erb +2 -2
- data/app/views/admin/pages/_form.html.erb +86 -77
- data/app/views/admin/pages/_pages.html.erb +11 -4
- data/app/views/admin/pages/edit.html.erb +3 -1
- data/app/views/admin/pages/index.html.erb +10 -6
- data/app/views/admin/pages/new.html.erb +3 -1
- data/app/views/admin/post_types/_index_and_form.html.erb +15 -16
- data/app/views/admin/post_types/edit.html.erb +1 -1
- data/app/views/admin/post_types/index.html.erb +1 -1
- data/app/views/admin/profiles/index.html.erb +2 -3
- data/app/views/admin/redirects/_index_and_form.html.erb +10 -11
- data/app/views/admin/redirects/edit.html.erb +1 -1
- data/app/views/admin/redirects/index.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +19 -16
- data/app/views/admin/seo/_general.html.erb +23 -47
- data/app/views/admin/seo/_permalinks.html.erb +14 -14
- data/app/views/admin/seo/_titles.html.erb +63 -64
- data/app/views/admin/seo/show.html.erb +14 -19
- data/app/views/admin/settings/display.html.erb +22 -25
- data/app/views/admin/settings/feedback.html.erb +31 -32
- data/app/views/admin/settings/index.html.erb +23 -24
- data/app/views/admin/settings/write.html.erb +21 -22
- data/app/views/admin/shared/_edit.html.erb +3 -3
- data/app/views/admin/shared/_menu.html.erb +26 -26
- data/app/views/admin/shared/_twitter_alert.html.erb +1 -1
- data/app/views/admin/sidebar/_config.html.erb +5 -5
- data/app/views/admin/sidebar/_target_sidebar.html.erb +4 -4
- data/app/views/admin/sidebar/index.html.erb +7 -7
- data/app/views/admin/tags/_index_and_form.html.erb +11 -12
- data/app/views/admin/tags/edit.html.erb +1 -1
- data/app/views/admin/tags/index.html.erb +1 -1
- data/app/views/admin/themes/index.html.erb +5 -6
- data/app/views/admin/users/_form.html.erb +34 -34
- data/app/views/admin/users/edit.html.erb +2 -2
- data/app/views/admin/users/index.html.erb +10 -12
- data/app/views/admin/users/new.html.erb +2 -2
- data/app/views/archives_sidebar/_content.html.erb +2 -2
- data/app/views/articles/_archives_article.html.erb +3 -3
- data/app/views/articles/_article.html.erb +7 -9
- data/app/views/articles/_article_author.html.erb +4 -0
- data/app/views/articles/_article_content.html.erb +2 -2
- data/app/views/articles/_article_excerpt.html.erb +2 -2
- data/app/views/articles/_article_links.html.erb +1 -1
- data/app/views/articles/_comment_errors.html.erb +1 -1
- data/app/views/articles/_comment_form.html.erb +12 -12
- data/app/views/articles/_comment_preview.html.erb +3 -3
- data/app/views/articles/_password_form.html.erb +4 -4
- data/app/views/articles/_trackback.html.erb +2 -2
- data/app/views/articles/archives.html.erb +1 -1
- data/app/views/articles/feedback_atom_feed.atom.builder +3 -1
- data/app/views/articles/feedback_rss_feed.rss.builder +9 -7
- data/app/views/articles/index_atom_feed.atom.builder +5 -3
- data/app/views/articles/index_rss_feed.rss.builder +10 -8
- data/app/views/articles/live_search.html.erb +3 -3
- data/app/views/articles/read.html.erb +16 -8
- data/app/views/articles/search.html.erb +2 -2
- data/app/views/articles/trackback.xml.builder +3 -1
- data/app/views/articles/view_page.html.erb +1 -1
- data/app/views/authors/show.html.erb +9 -9
- data/app/views/authors/show_atom_feed.atom.builder +4 -2
- data/app/views/authors/show_rss_feed.rss.builder +10 -8
- data/app/views/comments/_comment.html.erb +3 -3
- data/app/views/devise/mailer/reset_password_instructions.html.erb +7 -9
- data/app/views/devise/passwords/edit.html.erb +4 -4
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +5 -5
- data/app/views/devise/sessions/new.html.erb +3 -3
- data/app/views/errors/404.html.erb +2 -2
- data/app/views/feedback/index.atom.builder +3 -1
- data/app/views/feedback/index.rss.builder +9 -7
- data/app/views/layouts/accounts.html.erb +26 -26
- data/app/views/layouts/administration.html.erb +31 -31
- data/app/views/layouts/default.html.erb +3 -3
- data/app/views/layouts/editor.html.erb +5 -19
- data/app/views/meta_sidebar/_content.html.erb +2 -2
- data/app/views/notes/_note.html.erb +1 -1
- data/app/views/notes/index.html.erb +1 -1
- data/app/views/notes/show_in_reply.html.erb +1 -1
- data/app/views/notification_mailer/_mail_footer.html.erb +3 -3
- data/app/views/notification_mailer/article.html.erb +2 -2
- data/app/views/notification_mailer/comment.html.erb +5 -5
- data/app/views/notification_mailer/notif_user.html.erb +1 -1
- data/app/views/page_sidebar/_content.html.erb +1 -1
- data/app/views/search_sidebar/_content.html.erb +2 -2
- data/app/views/settings/install.html.erb +2 -2
- data/app/views/setup/index.html.erb +7 -7
- data/app/views/shared/_atom_header.atom.builder +4 -2
- data/app/views/shared/_atom_item_article.atom.builder +11 -6
- data/app/views/shared/_atom_item_comment.atom.builder +4 -2
- data/app/views/shared/_atom_item_trackback.atom.builder +4 -2
- data/app/views/shared/_page_header.html.erb +9 -12
- data/app/views/shared/_rss_item_article.rss.builder +6 -3
- data/app/views/shared/_rss_item_comment.rss.builder +3 -1
- data/app/views/shared/_rss_item_trackback.rss.builder +3 -1
- data/app/views/sidebar/display_plugins.html.erb +1 -1
- data/app/views/tag_sidebar/_content.html.erb +1 -1
- data/app/views/tags/index.html.erb +1 -1
- data/app/views/xml/_googlesitemap_item_article.googlesitemap.builder +2 -0
- data/app/views/xml/_googlesitemap_item_category.googlesitemap.builder +2 -0
- data/app/views/xml/_googlesitemap_item_page.googlesitemap.builder +2 -0
- data/app/views/xml/_googlesitemap_item_tag.googlesitemap.builder +2 -0
- data/app/views/xml/sitemap.googlesitemap.builder +4 -2
- data/config/i18n-tasks.yml +0 -5
- data/config/initializers/devise.rb +10 -4
- data/config/initializers/mime_types.rb +3 -1
- data/config/locales/da.yml +134 -71
- data/config/locales/de.yml +142 -75
- data/config/locales/en.yml +128 -66
- data/config/locales/es-MX.yml +135 -69
- data/config/locales/fr.yml +167 -86
- data/config/locales/he.yml +128 -70
- data/config/locales/it.yml +136 -72
- data/config/locales/ja.yml +110 -64
- data/config/locales/lt.yml +153 -74
- data/config/locales/nb-NO.yml +123 -65
- data/config/locales/nl.yml +140 -75
- data/config/locales/pl.yml +160 -69
- data/config/locales/pt-BR.yml +137 -70
- data/config/locales/ro.yml +148 -70
- data/config/locales/ru.yml +161 -69
- data/config/locales/zh-CN.yml +106 -59
- data/config/locales/zh-TW.yml +109 -61
- data/config/routes.rb +68 -63
- data/db/migrate/113_initial_schema.rb +192 -190
- data/db/migrate/114_fixes_buggy_articles_and_notes.rb +9 -6
- data/db/migrate/115_drops_categories_for_tags.rb +3 -1
- data/db/migrate/20150207131657_add_missing_indexes.rb +2 -0
- data/db/migrate/20150807134129_simplify_redirect_relations.rb +8 -1
- data/db/migrate/20150808052637_add_blog_ids.rb +4 -2
- data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +2 -0
- data/db/migrate/20150810094754_add_blog_id_to_tags.rb +2 -0
- data/db/migrate/20160108111120_add_devise_to_users.rb +4 -2
- data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +2 -0
- data/db/migrate/20160110094906_remove_profiles_rights.rb +2 -0
- data/db/migrate/20160605103918_replace_profile_id_with_string.rb +2 -0
- data/db/migrate/20160605154632_remove_profiles.rb +10 -5
- data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +2 -0
- data/db/migrate/20160701062604_add_blog_id_to_resources.rb +2 -0
- data/db/migrate/20170528093024_move_resources_to_content.rb +2 -0
- data/db/migrate/20170528094923_move_tags_to_content.rb +2 -0
- data/db/migrate/20170528201606_remove_separate_published_flag.rb +2 -0
- data/db/migrate/20170605071626_remove_extra_state_columns_from_feedback.rb +2 -0
- data/db/migrate/20170702105201_remove_published_at_from_feedback.rb +2 -0
- data/db/migrate/20190208151235_add_text_filter_name_fields.rb +9 -0
- data/db/migrate/20190208152646_move_text_filter_to_name.rb +97 -0
- data/db/migrate/20190209155717_remove_text_filter_ids.rb +19 -0
- data/db/migrate/20190209160610_remove_text_filters.rb +17 -0
- data/db/migrate/20200413140440_add_unique_indexes.rb +10 -0
- data/db/seeds.rb +9 -19
- data/lib/email_notify.rb +3 -1
- data/lib/format.rb +4 -2
- data/lib/publify_core.rb +36 -35
- data/lib/publify_core/engine.rb +8 -6
- data/lib/publify_core/lang.rb +5 -1
- data/lib/publify_core/testing_support/dns_mock.rb +15 -0
- data/lib/publify_core/testing_support/factories.rb +240 -0
- data/lib/publify_core/testing_support/feed_assertions.rb +48 -0
- data/lib/publify_core/testing_support/fixtures/exploit.svg +4 -0
- data/lib/publify_core/testing_support/fixtures/fakepng.png +1 -0
- data/lib/publify_core/testing_support/fixtures/otherfile.txt +1 -0
- data/lib/publify_core/testing_support/fixtures/testfile.png +0 -0
- data/lib/publify_core/testing_support/fixtures/testfile.txt +1 -0
- data/lib/publify_core/testing_support/upload_fixtures.rb +15 -0
- data/lib/publify_core/version.rb +3 -1
- data/lib/publify_guid.rb +3 -1
- data/lib/publify_plugins.rb +10 -5
- data/lib/publify_textfilter_markdown.rb +38 -25
- data/lib/publify_textfilter_none.rb +5 -3
- data/lib/publify_textfilter_smartypants.rb +5 -3
- data/lib/publify_textfilter_textile.rb +7 -4
- data/lib/publify_textfilter_twitterfilter.rb +13 -7
- data/lib/publify_time.rb +4 -0
- data/lib/sidebar_field.rb +15 -13
- data/lib/sidebar_registry.rb +5 -3
- data/lib/spam_protection.rb +16 -13
- data/lib/tasks/i18n.rake +9 -0
- data/lib/tasks/manifest.rake +30 -0
- data/lib/tasks/publify_core_tasks.rake +2 -0
- data/lib/text_filter_plugin.rb +27 -25
- data/lib/theme.rb +5 -3
- data/lib/transforms.rb +22 -19
- metadata +217 -87
- data/app/assets/javascripts/widearea.js +0 -486
- data/app/assets/stylesheets/widearea.css +0 -133
- data/app/controllers/admin/textfilters_controller.rb +0 -6
- data/app/views/admin/dashboard/_inbound.html.erb +0 -31
- data/app/views/admin/notes/_header.html.erb +0 -6
- data/app/views/articles/_protected_article_content.html.erb +0 -6
@@ -1,486 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* WideArea v0.3.0
|
3
|
-
* https://github.com/usablica/widearea
|
4
|
-
* MIT licensed
|
5
|
-
*
|
6
|
-
* Copyright (C) 2013 usabli.ca - By Afshin Mehrabani (@afshinmeh)
|
7
|
-
*/
|
8
|
-
|
9
|
-
(function (root, factory) {
|
10
|
-
if (typeof exports === 'object') {
|
11
|
-
// CommonJS
|
12
|
-
factory(exports);
|
13
|
-
} else if (typeof define === 'function' && define.amd) {
|
14
|
-
// AMD. Register as an anonymous module.
|
15
|
-
define(['exports'], factory);
|
16
|
-
} else {
|
17
|
-
// Browser globals
|
18
|
-
factory(root);
|
19
|
-
}
|
20
|
-
} (this, function (exports) {
|
21
|
-
//Default config/variables
|
22
|
-
var VERSION = '0.3.0';
|
23
|
-
|
24
|
-
/**
|
25
|
-
* WideArea main class
|
26
|
-
*
|
27
|
-
* @class WideArea
|
28
|
-
*/
|
29
|
-
function WideArea(obj) {
|
30
|
-
this._targetElement = obj;
|
31
|
-
|
32
|
-
//starts with 1
|
33
|
-
this._wideAreaId = 1;
|
34
|
-
|
35
|
-
this._options = {
|
36
|
-
wideAreaAttr: 'data-widearea',
|
37
|
-
exitOnEsc: true,
|
38
|
-
defaultColorScheme: 'light',
|
39
|
-
closeIconLabel: 'Close WideArea',
|
40
|
-
changeThemeIconLabel: 'Toggle Color Scheme',
|
41
|
-
fullScreenIconLabel: 'WideArea Mode',
|
42
|
-
autoSaveKeyPrefix: 'WDATA-'
|
43
|
-
};
|
44
|
-
|
45
|
-
_enable.call(this);
|
46
|
-
}
|
47
|
-
|
48
|
-
/**
|
49
|
-
* Save textarea data to storage
|
50
|
-
*
|
51
|
-
* @api private
|
52
|
-
* @method _saveToStorage
|
53
|
-
*/
|
54
|
-
function _saveToStorage(id, value) {
|
55
|
-
//save textarea data in localStorage
|
56
|
-
//localStorage.setItem(this._options.autoSaveKeyPrefix + id, value);
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Get data from storage
|
61
|
-
*
|
62
|
-
* @api private
|
63
|
-
* @method _getFromStorage
|
64
|
-
*/
|
65
|
-
function _getFromStorage(id) {
|
66
|
-
// return localStorage.getItem(this._options.autoSaveKeyPrefix + id);
|
67
|
-
}
|
68
|
-
|
69
|
-
/**
|
70
|
-
* Clear specific textarea data from storage
|
71
|
-
*
|
72
|
-
* @api private
|
73
|
-
* @method _clearStorage
|
74
|
-
*/
|
75
|
-
function _clearStorage(value) {
|
76
|
-
|
77
|
-
var currentElement, id;
|
78
|
-
if (typeof(value) == "string") {
|
79
|
-
//with css selector
|
80
|
-
currentElement = this._targetElement.querySelector(value);
|
81
|
-
if (currentElement) {
|
82
|
-
id = parseInt(currentElement.getAttribute("data-widearea-id"));
|
83
|
-
}
|
84
|
-
} else if (typeof(value) == "number") {
|
85
|
-
//first, clear it from storage
|
86
|
-
currentElement = this._targetElement.querySelector('textarea[data-widearea-id="' + value + '"]');
|
87
|
-
id = value;
|
88
|
-
} else if (typeof(value) == "object") {
|
89
|
-
//with DOM
|
90
|
-
currentElement = value;
|
91
|
-
|
92
|
-
if (currentElement) {
|
93
|
-
id = parseInt(currentElement.attr("data-widearea-id"));
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
//and then, clear the textarea
|
98
|
-
if (currentElement && id) {
|
99
|
-
currentElement.val('');
|
100
|
-
localStorage.removeItem(this._options.autoSaveKeyPrefix + id);
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Enable the WideArea
|
106
|
-
*
|
107
|
-
* @api private
|
108
|
-
* @method _enable
|
109
|
-
*/
|
110
|
-
function _enable() {
|
111
|
-
var self = this,
|
112
|
-
//select all textareas in the target element
|
113
|
-
textAreaList = this._targetElement.querySelectorAll('textarea[' + this._options.wideAreaAttr + '=\'enable\']'),
|
114
|
-
|
115
|
-
// don't make functions within a loop.
|
116
|
-
fullscreenIconClickHandler = function() {
|
117
|
-
_enableFullScreen.call(self, this);
|
118
|
-
};
|
119
|
-
|
120
|
-
//to hold all textareas in the page
|
121
|
-
this._textareas = [];
|
122
|
-
|
123
|
-
//then, change all textareas to widearea
|
124
|
-
for (var i = textAreaList.length - 1; i >= 0; i--) {
|
125
|
-
var currentTextArea = textAreaList[i];
|
126
|
-
//create widearea wrapper element
|
127
|
-
var wideAreaWrapper = document.createElement('div'),
|
128
|
-
wideAreaIcons = document.createElement('div'),
|
129
|
-
fullscreenIcon = document.createElement('a');
|
130
|
-
|
131
|
-
wideAreaWrapper.className = 'widearea-wrapper';
|
132
|
-
wideAreaIcons.className = 'widearea-icons';
|
133
|
-
fullscreenIcon.className = 'widearea-icon fullscreen';
|
134
|
-
fullscreenIcon.title = this._options.fullScreenIconLabel;
|
135
|
-
|
136
|
-
//hack!
|
137
|
-
fullscreenIcon.href = 'javascript:void(0);';
|
138
|
-
fullscreenIcon.draggable = false;
|
139
|
-
|
140
|
-
//bind to click event
|
141
|
-
fullscreenIcon.onclick = fullscreenIconClickHandler;
|
142
|
-
|
143
|
-
//add widearea class to textarea
|
144
|
-
currentTextArea.className += (currentTextArea.className + " widearea").replace(/^\s+|\s+$/g, "");
|
145
|
-
|
146
|
-
//set wideArea id and increase the stepper
|
147
|
-
currentTextArea.setAttribute("data-widearea-id", this._wideAreaId);
|
148
|
-
wideAreaIcons.setAttribute("id", "widearea-" + this._wideAreaId);
|
149
|
-
|
150
|
-
//Autosaving
|
151
|
-
if (_getFromStorage.call(this, this._wideAreaId)) {
|
152
|
-
currentTextArea.value = _getFromStorage.call(this, this._wideAreaId);
|
153
|
-
}
|
154
|
-
|
155
|
-
var onTextChanged = function () {
|
156
|
-
_saveToStorage.call(self, this.getAttribute('data-widearea-id'), this.value);
|
157
|
-
};
|
158
|
-
//add textchange listener
|
159
|
-
if (currentTextArea.addEventListener) {
|
160
|
-
currentTextArea.addEventListener('input', onTextChanged, false);
|
161
|
-
} else if (currentTextArea.attachEvent) { //IE hack
|
162
|
-
currentTextArea.attachEvent('onpropertychange', onTextChanged);
|
163
|
-
}
|
164
|
-
|
165
|
-
//go to next wideArea
|
166
|
-
++this._wideAreaId;
|
167
|
-
|
168
|
-
//set icons panel position
|
169
|
-
_renewIconsPosition(currentTextArea, wideAreaIcons);
|
170
|
-
|
171
|
-
//append all prepared div(s)
|
172
|
-
wideAreaIcons.appendChild(fullscreenIcon);
|
173
|
-
wideAreaWrapper.appendChild(wideAreaIcons);
|
174
|
-
|
175
|
-
//and append it to the page
|
176
|
-
document.body.appendChild(wideAreaWrapper);
|
177
|
-
|
178
|
-
//add the textarea to internal variable
|
179
|
-
this._textareas.push(currentTextArea);
|
180
|
-
}
|
181
|
-
|
182
|
-
//set a timer to re-calculate the position of textareas, I don't know whether this is a good approach or not
|
183
|
-
this._timer = setInterval(function() {
|
184
|
-
for (var i = self._textareas.length - 1; i >= 0; i--) {
|
185
|
-
var currentTextArea = self._textareas[i];
|
186
|
-
//get the related icon panel. Using `getElementById` for better performance
|
187
|
-
var wideAreaIcons = document.getElementById("widearea-" + currentTextArea.getAttribute("data-widearea-id"));
|
188
|
-
|
189
|
-
//get old position
|
190
|
-
var oldPosition = _getOffset(wideAreaIcons);
|
191
|
-
|
192
|
-
//get the new element's position
|
193
|
-
var currentTextareaPosition = _getOffset(currentTextArea);
|
194
|
-
|
195
|
-
//only set the new position of old positions changed
|
196
|
-
if((oldPosition.left - currentTextareaPosition.width + 21) != currentTextareaPosition.left || oldPosition.top != currentTextareaPosition.top) {
|
197
|
-
//set icons panel position
|
198
|
-
_renewIconsPosition(currentTextArea, wideAreaIcons, currentTextareaPosition);
|
199
|
-
}
|
200
|
-
};
|
201
|
-
}, 200);
|
202
|
-
}
|
203
|
-
|
204
|
-
/**
|
205
|
-
* Set new position to icons panel
|
206
|
-
*
|
207
|
-
* @api private
|
208
|
-
* @method _renewIconsPosition
|
209
|
-
* @param {Object} textarea
|
210
|
-
* @param {Object} iconPanel
|
211
|
-
*/
|
212
|
-
function _renewIconsPosition(textarea, iconPanel, textAreaPosition) {
|
213
|
-
var currentTextareaPosition = textAreaPosition || _getOffset(textarea);
|
214
|
-
//set icon panel position
|
215
|
-
iconPanel.style.left = currentTextareaPosition.left + currentTextareaPosition.width - 21 + "px";
|
216
|
-
iconPanel.style.top = currentTextareaPosition.top + "px";
|
217
|
-
}
|
218
|
-
|
219
|
-
/**
|
220
|
-
* Get an element position on the page
|
221
|
-
* Thanks to `meouw`: http://stackoverflow.com/a/442474/375966
|
222
|
-
*
|
223
|
-
* @api private
|
224
|
-
* @method _getOffset
|
225
|
-
* @param {Object} element
|
226
|
-
* @returns Element's position info
|
227
|
-
*/
|
228
|
-
function _getOffset(element) {
|
229
|
-
var elementPosition = {};
|
230
|
-
|
231
|
-
//set width
|
232
|
-
elementPosition.width = element.offsetWidth;
|
233
|
-
|
234
|
-
//set height
|
235
|
-
elementPosition.height = element.offsetHeight;
|
236
|
-
|
237
|
-
//calculate element top and left
|
238
|
-
var _x = 0;
|
239
|
-
var _y = 0;
|
240
|
-
while(element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) {
|
241
|
-
_x += element.offsetLeft;
|
242
|
-
_y += element.offsetTop;
|
243
|
-
element = element.offsetParent;
|
244
|
-
}
|
245
|
-
//set top
|
246
|
-
elementPosition.top = _y;
|
247
|
-
//set left
|
248
|
-
elementPosition.left = _x;
|
249
|
-
|
250
|
-
return elementPosition;
|
251
|
-
}
|
252
|
-
|
253
|
-
/**
|
254
|
-
* Get an element CSS property on the page
|
255
|
-
* Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml
|
256
|
-
*
|
257
|
-
* @api private
|
258
|
-
* @method _getPropValue
|
259
|
-
* @param {Object} element
|
260
|
-
* @param {String} propName
|
261
|
-
* @returns Element's property value
|
262
|
-
*/
|
263
|
-
function _getPropValue (element, propName) {
|
264
|
-
var propValue = '';
|
265
|
-
if (element.currentStyle) { //IE
|
266
|
-
propValue = element.currentStyle[propName];
|
267
|
-
} else if (document.defaultView && document.defaultView.getComputedStyle) { //Others
|
268
|
-
propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName);
|
269
|
-
}
|
270
|
-
|
271
|
-
//Prevent exception in IE
|
272
|
-
if(propValue.toLowerCase) {
|
273
|
-
return propValue.toLowerCase();
|
274
|
-
} else {
|
275
|
-
return propValue;
|
276
|
-
}
|
277
|
-
}
|
278
|
-
|
279
|
-
/**
|
280
|
-
* FullScreen the textarea
|
281
|
-
*
|
282
|
-
* @api private
|
283
|
-
* @method _enableFullScreen
|
284
|
-
* @param {Object} link
|
285
|
-
*/
|
286
|
-
function _enableFullScreen(link) {
|
287
|
-
var self = this;
|
288
|
-
|
289
|
-
//first of all, get the textarea id
|
290
|
-
var wideAreaId = parseInt(link.parentNode.id.replace(/widearea\-/, ""));
|
291
|
-
|
292
|
-
//I don't know whether is this correct or not, but I think it's not a bad way
|
293
|
-
var targetTextarea = document.querySelector("textarea[data-widearea-id='" + wideAreaId + "']");
|
294
|
-
|
295
|
-
//clone current textarea
|
296
|
-
var currentTextArea = targetTextarea.cloneNode();
|
297
|
-
|
298
|
-
//add proper css class names
|
299
|
-
currentTextArea.className = ('widearea-fullscreen ' + targetTextarea.className).replace(/^\s+|\s+$/g, "");
|
300
|
-
targetTextarea.className = ('widearea-fullscreened ' + targetTextarea.className).replace(/^\s+|\s+$/g, "");
|
301
|
-
|
302
|
-
var controlPanel = document.createElement('div');
|
303
|
-
controlPanel.className = 'widearea-controlPanel';
|
304
|
-
|
305
|
-
//create close icon
|
306
|
-
var closeIcon = document.createElement('a');
|
307
|
-
closeIcon.href = 'javascript:void(0);';
|
308
|
-
closeIcon.className = 'widearea-icon close';
|
309
|
-
closeIcon.title = this._options.closeIconLabel;
|
310
|
-
closeIcon.onclick = function(){
|
311
|
-
_disableFullScreen.call(self);
|
312
|
-
};
|
313
|
-
|
314
|
-
//disable dragging
|
315
|
-
closeIcon.draggable = false;
|
316
|
-
|
317
|
-
//create close icon
|
318
|
-
var changeThemeIcon = document.createElement('a');
|
319
|
-
changeThemeIcon.href = 'javascript:void(0);';
|
320
|
-
changeThemeIcon.className = 'widearea-icon changeTheme';
|
321
|
-
changeThemeIcon.title = this._options.changeThemeIconLabel;
|
322
|
-
changeThemeIcon.onclick = function() {
|
323
|
-
_toggleColorScheme.call(self);
|
324
|
-
};
|
325
|
-
|
326
|
-
//disable dragging
|
327
|
-
changeThemeIcon.draggable = false;
|
328
|
-
|
329
|
-
controlPanel.appendChild(closeIcon);
|
330
|
-
controlPanel.appendChild(changeThemeIcon);
|
331
|
-
|
332
|
-
//create overlay layer
|
333
|
-
var overlayLayer = document.createElement('div');
|
334
|
-
overlayLayer.className = 'widearea-overlayLayer ' + this._options.defaultColorScheme;
|
335
|
-
|
336
|
-
//add controls to overlay layer
|
337
|
-
overlayLayer.appendChild(currentTextArea);
|
338
|
-
overlayLayer.appendChild(controlPanel);
|
339
|
-
|
340
|
-
//finally add it to the body
|
341
|
-
document.body.appendChild(overlayLayer);
|
342
|
-
|
343
|
-
//set the focus to textarea
|
344
|
-
currentTextArea.focus();
|
345
|
-
|
346
|
-
//set the value of small textarea to fullscreen one
|
347
|
-
currentTextArea.value = targetTextarea.value;
|
348
|
-
|
349
|
-
var onTextChanged = function () {
|
350
|
-
_saveToStorage.call(self, this.getAttribute('data-widearea-id'), this.value);
|
351
|
-
};
|
352
|
-
//add textchange listener
|
353
|
-
if (currentTextArea.addEventListener) {
|
354
|
-
currentTextArea.addEventListener('input', onTextChanged, false);
|
355
|
-
} else if (currentTextArea.attachEvent) { //IE hack
|
356
|
-
currentTextArea.attachEvent('onpropertychange', onTextChanged);
|
357
|
-
}
|
358
|
-
|
359
|
-
//bind to keydown event
|
360
|
-
this._onKeyDown = function(e) {
|
361
|
-
if (e.keyCode === 27 && self._options.exitOnEsc) {
|
362
|
-
//escape key pressed
|
363
|
-
_disableFullScreen.call(self);
|
364
|
-
}
|
365
|
-
if (e.keyCode == 9) {
|
366
|
-
// tab key pressed
|
367
|
-
e.preventDefault();
|
368
|
-
var selectionStart = currentTextArea.selectionStart;
|
369
|
-
currentTextArea.value = currentTextArea.value.substring(0, selectionStart) + "\t" + currentTextArea.value.substring(currentTextArea.selectionEnd);
|
370
|
-
currentTextArea.selectionEnd = selectionStart + 1;
|
371
|
-
}
|
372
|
-
};
|
373
|
-
if (window.addEventListener) {
|
374
|
-
window.addEventListener('keydown', self._onKeyDown, true);
|
375
|
-
} else if (document.attachEvent) { //IE
|
376
|
-
document.attachEvent('onkeydown', self._onKeyDown);
|
377
|
-
}
|
378
|
-
}
|
379
|
-
|
380
|
-
/**
|
381
|
-
* Change/Toggle color scheme of WideArea
|
382
|
-
*
|
383
|
-
* @api private
|
384
|
-
* @method _toggleColorScheme
|
385
|
-
*/
|
386
|
-
function _toggleColorScheme() {
|
387
|
-
var overlayLayer = document.querySelector(".widearea-overlayLayer");
|
388
|
-
if(/dark/gi.test(overlayLayer.className)) {
|
389
|
-
overlayLayer.className = overlayLayer.className.replace('dark', 'light');
|
390
|
-
} else {
|
391
|
-
overlayLayer.className = overlayLayer.className.replace('light', 'dark');
|
392
|
-
}
|
393
|
-
}
|
394
|
-
|
395
|
-
/**
|
396
|
-
* Close FullScreen
|
397
|
-
*
|
398
|
-
* @api private
|
399
|
-
* @method _disableFullScreen
|
400
|
-
*/
|
401
|
-
function _disableFullScreen() {
|
402
|
-
var smallTextArea = document.querySelector("textarea.widearea-fullscreened");
|
403
|
-
var overlayLayer = document.querySelector(".widearea-overlayLayer");
|
404
|
-
var fullscreenTextArea = overlayLayer.querySelector("textarea");
|
405
|
-
|
406
|
-
//change the focus
|
407
|
-
smallTextArea.focus();
|
408
|
-
|
409
|
-
//set fullscreen textarea to small one
|
410
|
-
smallTextArea.value = fullscreenTextArea.value;
|
411
|
-
|
412
|
-
//reset class for targeted text
|
413
|
-
smallTextArea.className = smallTextArea.className.replace(/widearea-fullscreened/gi, "").replace(/^\s+|\s+$/g, "");
|
414
|
-
|
415
|
-
//and then remove the overlay layer
|
416
|
-
overlayLayer.parentNode.removeChild(overlayLayer);
|
417
|
-
|
418
|
-
//clean listeners
|
419
|
-
if (window.removeEventListener) {
|
420
|
-
window.removeEventListener('keydown', this._onKeyDown, true);
|
421
|
-
} else if (document.detachEvent) { //IE
|
422
|
-
document.detachEvent('onkeydown', this._onKeyDown);
|
423
|
-
}
|
424
|
-
|
425
|
-
adaptiveheight(smallTextArea);
|
426
|
-
}
|
427
|
-
|
428
|
-
/**
|
429
|
-
* Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
|
430
|
-
*
|
431
|
-
* @param obj1
|
432
|
-
* @param obj2
|
433
|
-
* @returns obj3 a new object based on obj1 and obj2
|
434
|
-
*/
|
435
|
-
function _mergeOptions(obj1, obj2) {
|
436
|
-
var obj3 = {}, attrname;
|
437
|
-
for (attrname in obj1) { obj3[attrname] = obj1[attrname]; }
|
438
|
-
for (attrname in obj2) { obj3[attrname] = obj2[attrname]; }
|
439
|
-
return obj3;
|
440
|
-
}
|
441
|
-
|
442
|
-
var wideArea = function (selector) {
|
443
|
-
if (typeof (selector) === 'string') {
|
444
|
-
//select the target element with query selector
|
445
|
-
var targetElement = document.querySelector(selector);
|
446
|
-
|
447
|
-
if (targetElement) {
|
448
|
-
return new WideArea(targetElement);
|
449
|
-
} else {
|
450
|
-
throw new Error('There is no element with given selector.');
|
451
|
-
}
|
452
|
-
} else {
|
453
|
-
return new WideArea(document.body);
|
454
|
-
}
|
455
|
-
};
|
456
|
-
|
457
|
-
/**
|
458
|
-
* Current WideArea version
|
459
|
-
*
|
460
|
-
* @property version
|
461
|
-
* @type String
|
462
|
-
*/
|
463
|
-
wideArea.version = VERSION;
|
464
|
-
|
465
|
-
//Prototype
|
466
|
-
wideArea.fn = WideArea.prototype = {
|
467
|
-
clone: function () {
|
468
|
-
return new WideArea(this);
|
469
|
-
},
|
470
|
-
setOption: function(option, value) {
|
471
|
-
this._options[option] = value;
|
472
|
-
return this;
|
473
|
-
},
|
474
|
-
setOptions: function(options) {
|
475
|
-
this._options = _mergeOptions(this._options, options);
|
476
|
-
return this;
|
477
|
-
},
|
478
|
-
clearData: function(value) {
|
479
|
-
_clearStorage.call(this, value);
|
480
|
-
return this;
|
481
|
-
}
|
482
|
-
};
|
483
|
-
|
484
|
-
exports.wideArea = wideArea;
|
485
|
-
return wideArea;
|
486
|
-
}));
|