refinerycms-core 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/refinery/add.png +0 -0
- data/app/assets/images/refinery/admin_bg.png +0 -0
- data/app/assets/images/refinery/ajax-loader.gif +0 -0
- data/app/assets/images/refinery/branch-end.gif +0 -0
- data/app/assets/images/refinery/branch.gif +0 -0
- data/app/assets/images/refinery/cross.png +0 -0
- data/app/assets/images/refinery/dialogLoadingAnimation.gif +0 -0
- data/app/assets/images/refinery/header_background.png +0 -0
- data/app/assets/images/refinery/hover-gradient.jpg +0 -0
- data/app/assets/images/refinery/icons/accept.png +0 -0
- data/app/assets/images/refinery/icons/add.png +0 -0
- data/app/assets/images/refinery/icons/ajax-loader.gif +0 -0
- data/app/assets/images/refinery/icons/application_edit.png +0 -0
- data/app/assets/images/refinery/icons/application_go.png +0 -0
- data/app/assets/images/refinery/icons/arrow_left.png +0 -0
- data/app/assets/images/refinery/icons/arrow_left_right.png +0 -0
- data/app/assets/images/refinery/icons/arrow_switch.png +0 -0
- data/app/assets/images/refinery/icons/arrow_up.png +0 -0
- data/app/assets/images/refinery/icons/arrow_up_down.png +0 -0
- data/app/assets/images/refinery/icons/bin.png +0 -0
- data/app/assets/images/refinery/icons/bin_closed.png +0 -0
- data/app/assets/images/refinery/icons/cancel.png +0 -0
- data/app/assets/images/refinery/icons/cog_add.png +0 -0
- data/app/assets/images/refinery/icons/cog_edit.png +0 -0
- data/app/assets/images/refinery/icons/cross.png +0 -0
- data/app/assets/images/refinery/icons/delete.png +0 -0
- data/app/assets/images/refinery/icons/doc.png +0 -0
- data/app/assets/images/refinery/icons/down.gif +0 -0
- data/app/assets/images/refinery/icons/edit.png +0 -0
- data/app/assets/images/refinery/icons/email.png +0 -0
- data/app/assets/images/refinery/icons/email_edit.png +0 -0
- data/app/assets/images/refinery/icons/email_go.png +0 -0
- data/app/assets/images/refinery/icons/email_open.png +0 -0
- data/app/assets/images/refinery/icons/eye.png +0 -0
- data/app/assets/images/refinery/icons/folder.png +0 -0
- data/app/assets/images/refinery/icons/folder_open.png +0 -0
- data/app/assets/images/refinery/icons/folder_page_white.png +0 -0
- data/app/assets/images/refinery/icons/image_add.png +0 -0
- data/app/assets/images/refinery/icons/image_edit.png +0 -0
- data/app/assets/images/refinery/icons/img.png +0 -0
- data/app/assets/images/refinery/icons/information.png +0 -0
- data/app/assets/images/refinery/icons/layout_add.png +0 -0
- data/app/assets/images/refinery/icons/layout_edit.png +0 -0
- data/app/assets/images/refinery/icons/locale-blue.svg +15 -0
- data/app/assets/images/refinery/icons/locale.svg +11 -0
- data/app/assets/images/refinery/icons/music.png +0 -0
- data/app/assets/images/refinery/icons/page.png +0 -0
- data/app/assets/images/refinery/icons/page_add.png +0 -0
- data/app/assets/images/refinery/icons/page_edit.png +0 -0
- data/app/assets/images/refinery/icons/page_white_edit.png +0 -0
- data/app/assets/images/refinery/icons/page_white_gear.png +0 -0
- data/app/assets/images/refinery/icons/page_white_put.png +0 -0
- data/app/assets/images/refinery/icons/pdf.png +0 -0
- data/app/assets/images/refinery/icons/ppt.png +0 -0
- data/app/assets/images/refinery/icons/star.png +0 -0
- data/app/assets/images/refinery/icons/tick.png +0 -0
- data/app/assets/images/refinery/icons/up.gif +0 -0
- data/app/assets/images/refinery/icons/user_add.png +0 -0
- data/app/assets/images/refinery/icons/user_comment.png +0 -0
- data/app/assets/images/refinery/icons/user_edit.png +0 -0
- data/app/assets/images/refinery/icons/xls.png +0 -0
- data/app/assets/images/refinery/icons/zip.png +0 -0
- data/app/assets/images/refinery/icons/zoom.png +0 -0
- data/app/assets/images/refinery/logo-large.png +0 -0
- data/app/assets/images/refinery/logo-medium.png +0 -0
- data/app/assets/images/refinery/logo-site-bar.png +0 -0
- data/app/assets/images/refinery/logo-small-medium.png +0 -0
- data/app/assets/images/refinery/logo-small.png +0 -0
- data/app/assets/images/refinery/logo-tiny.png +0 -0
- data/app/assets/images/refinery/logo.png +0 -0
- data/app/assets/images/refinery/nav-3-background.gif +0 -0
- data/app/assets/images/refinery/nav_inactive_background.png +0 -0
- data/app/assets/images/refinery/orange_button.png +0 -0
- data/app/assets/images/refinery/page_bg.png +0 -0
- data/app/assets/images/refinery/text_field_background.png +0 -0
- data/app/assets/images/refinery/tooltip-nib.gif +0 -0
- data/app/assets/images/refinery/tooltip-nib.png +0 -0
- data/app/assets/javascripts/admin.js +7 -6
- data/app/assets/javascripts/refinery/admin.js.erb +99 -60
- data/app/assets/javascripts/refinery/ajaxy_pagination.js.coffee +2 -5
- data/app/assets/javascripts/refinery/application.js +8 -0
- data/app/assets/javascripts/refinery/core.js +4 -18
- data/app/assets/javascripts/refinery/interface.js.coffee.erb +5 -29
- data/app/assets/javascripts/refinery/modal_dialogs.js.erb +0 -105
- data/app/assets/javascripts/refinery/nestedsortables.js +183 -110
- data/app/assets/javascripts/refinery/refinery.js.erb +3 -9
- data/app/assets/javascripts/refinery/serializelist.js +1 -1
- data/app/assets/javascripts/refinery/site_bar.js +0 -5
- data/app/assets/javascripts/refinery/sortable_list.js +10 -11
- data/app/assets/javascripts/refinery/submit_continue.js.coffee.erb +1 -1
- data/app/assets/stylesheets/application.scss +2 -0
- data/app/assets/stylesheets/refinery/_colours.scss +18 -0
- data/app/assets/stylesheets/refinery/_icons.scss +85 -0
- data/app/assets/stylesheets/refinery/{layout.css.scss → _layout.scss} +306 -338
- data/app/assets/stylesheets/refinery/_mixins.scss +84 -0
- data/app/assets/stylesheets/refinery/{submenu.css.scss → _submenu.scss} +2 -2
- data/app/assets/stylesheets/refinery/{tooltips.css.scss → _tooltips.scss} +0 -0
- data/app/assets/stylesheets/refinery/_ui.scss +252 -0
- data/app/assets/stylesheets/refinery/{formatting.css.scss → formatting.scss} +0 -0
- data/app/assets/stylesheets/refinery/refinery.scss +10 -0
- data/app/assets/stylesheets/refinery/site_bar.scss +126 -0
- data/app/assets/stylesheets/refinery/{theme.css.scss → theme.scss} +0 -0
- data/app/controllers/refinery/admin/core_controller.rb +2 -7
- data/app/controllers/refinery/admin/dialogs_controller.rb +4 -3
- data/app/controllers/refinery/admin_controller.rb +0 -1
- data/app/controllers/refinery/fast_controller.rb +0 -4
- data/app/helpers/refinery/admin/visual_editor_helper.rb +13 -0
- data/app/helpers/refinery/admin_helper.rb +4 -0
- data/app/helpers/refinery/custom_assets_helper.rb +2 -2
- data/app/helpers/refinery/image_helper.rb +9 -8
- data/app/helpers/refinery/meta_helper.rb +1 -1
- data/app/helpers/refinery/site_bar_helper.rb +16 -2
- data/app/helpers/refinery/tag_helper.rb +38 -5
- data/app/models/refinery/core/base_model.rb +3 -1
- data/app/views/layouts/refinery/admin.html.erb +12 -10
- data/app/views/layouts/refinery/admin_dialog.html.erb +1 -4
- data/app/views/refinery/_content_page.html.erb +1 -1
- data/app/views/refinery/_google_analytics.html.erb +8 -9
- data/app/views/refinery/_head.html.erb +1 -1
- data/app/views/refinery/_javascripts.html.erb +0 -15
- data/app/views/refinery/_message.html.erb +1 -1
- data/app/views/refinery/_site_bar.html.erb +9 -6
- data/app/views/refinery/admin/_error_messages.html.erb +4 -4
- data/app/views/refinery/admin/_form_actions.html.erb +1 -0
- data/app/views/refinery/admin/_form_advanced_options_menu.html.erb +3 -4
- data/app/views/refinery/admin/_head.html.erb +3 -0
- data/app/views/refinery/admin/_image_picker.html.erb +4 -5
- data/app/views/refinery/admin/_javascripts.html.erb +4 -9
- data/app/views/refinery/admin/_locale_picker.html.erb +9 -2
- data/app/views/refinery/admin/_make_sortable.html.erb +8 -6
- data/app/views/refinery/admin/_menu.html.erb +2 -15
- data/app/views/refinery/admin/_menu_item.html.erb +3 -0
- data/app/views/refinery/admin/_resource_picker.html.erb +12 -22
- data/app/views/refinery/admin/_search.html.erb +1 -1
- data/app/views/refinery/admin/_tabbed_fields.html.erb +2 -2
- data/app/views/refinery/admin/_wysiwyg.html.erb +1 -1
- data/{lib/generators/refinery/cms/templates/app/decorators/controllers/refinery/.gitkeep → app/views/refinery/admin/dialog_success.html.erb} +0 -0
- data/app/views/refinery/admin/dialogs/show.html.erb +1 -19
- data/config/initializers/assets.rb +6 -0
- data/config/locales/ca.yml +84 -0
- data/config/locales/cs.yml +12 -5
- data/config/locales/en.yml +6 -2
- data/config/locales/fr.yml +15 -11
- data/config/locales/hu.yml +3 -1
- data/config/locales/it.yml +5 -1
- data/config/locales/ja.yml +2 -2
- data/config/locales/pt.yml +5 -3
- data/config/locales/ru.yml +7 -0
- data/config/locales/sl.yml +0 -3
- data/config/locales/tr.yml +43 -41
- data/config/routes.rb +1 -4
- data/lib/generators/refinery/cms/cms_generator.rb +68 -26
- data/lib/generators/refinery/cms/templates/app/decorators/{models/refinery/.gitkeep → controllers/refinery/.keep} +0 -0
- data/lib/generators/refinery/{form/templates/.gitkeep → cms/templates/app/decorators/models/refinery/.keep} +0 -0
- data/lib/generators/refinery/cms/templates/config/database.yml.mysql +3 -3
- data/lib/generators/refinery/cms/templates/config/database.yml.postgresql +3 -3
- data/lib/generators/refinery/core/templates/config/initializers/refinery/core.rb.erb +18 -5
- data/lib/generators/refinery/dummy/dummy_generator.rb +3 -1
- data/lib/generators/refinery/dummy/templates/rails/application.js +3 -0
- data/lib/generators/refinery/dummy/templates/rails/application.rb.erb +0 -2
- data/lib/generators/refinery/dummy/templates/rails/blank.png +0 -0
- data/lib/generators/refinery/dummy/templates/rails/routes.rb +1 -1
- data/lib/generators/refinery/engine/engine_generator.rb +3 -2
- data/lib/generators/refinery/engine/templates/Gemfile +9 -4
- data/lib/generators/refinery/engine/templates/Rakefile +3 -4
- data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +11 -2
- data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/plural_name_controller.rb.erb +2 -2
- data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb.erb +5 -5
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_actions.html.erb +7 -12
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_form.html.erb +8 -8
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +3 -3
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +6 -11
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +1 -1
- data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/plural_name/show.html.erb +4 -4
- data/lib/generators/refinery/engine/templates/db/migrate/1_create_namespace_plural_name.rb.erb +2 -9
- data/lib/generators/refinery/engine/templates/db/seeds.rb.erb +13 -19
- data/lib/generators/refinery/engine/templates/lib/refinery/plural_name/engine.rb.erb +0 -4
- data/lib/generators/refinery/engine/templates/readme.md +3 -3
- data/lib/generators/refinery/engine/templates/refinerycms-extension_plural_name.gemspec +1 -0
- data/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb +25 -28
- data/lib/generators/refinery/engine/templates/spec/models/refinery/namespace/singular_name_spec.rb.erb +1 -1
- data/lib/generators/refinery/engine/templates/spec/spec_helper.rb +1 -1
- data/lib/refinery.rb +7 -9
- data/lib/refinery/admin/base_controller.rb +42 -32
- data/lib/refinery/application_controller.rb +25 -17
- data/lib/refinery/cli.rb +54 -19
- data/lib/refinery/core.rb +5 -0
- data/lib/refinery/core/authorisation_adapter.rb +11 -0
- data/lib/refinery/core/authorisation_manager.rb +14 -0
- data/lib/refinery/core/configuration.rb +25 -4
- data/lib/refinery/core/default_route.rb +16 -0
- data/lib/refinery/core/engine.rb +44 -25
- data/lib/refinery/core/nil_user.rb +42 -0
- data/lib/refinery/crud.rb +40 -29
- data/lib/refinery/extension_generation.rb +11 -22
- data/lib/refinery/generators/generated_attribute.rb +54 -0
- data/lib/refinery/generators/named_base.rb +16 -0
- data/lib/refinery/menu.rb +3 -2
- data/lib/refinery/menu_item.rb +1 -1
- data/lib/refinery/plugin.rb +27 -43
- data/lib/refinery/plugins.rb +22 -26
- data/lib/refinery/users_manager.rb +8 -0
- data/lib/refinery/version.rb +7 -3
- data/lib/tasks/refinery.rake +7 -0
- data/license.md +1 -1
- data/refinerycms-core.gemspec +11 -8
- data/spec/controllers/refinery/admin/dummy_controller_spec.rb +23 -11
- data/spec/controllers/refinery/sitemap_controller_spec.rb +2 -2
- data/spec/features/refinery/admin/custom_assets_spec.rb +12 -10
- data/spec/features/refinery/admin/dialogs_spec.rb +5 -5
- data/spec/features/refinery/admin/xhr_paging_spec.rb +24 -38
- data/spec/features/refinery/application_layout_spec.rb +3 -3
- data/spec/features/refinery/core_spec.rb +1 -1
- data/spec/features/refinery/site_bar_spec.rb +44 -23
- data/spec/helpers/refinery/admin_helper_spec.rb +15 -0
- data/spec/helpers/refinery/custom_assets_helper_spec.rb +15 -23
- data/spec/helpers/refinery/html_truncation_helper_spec.rb +10 -5
- data/spec/helpers/refinery/meta_helper_spec.rb +3 -3
- data/spec/helpers/refinery/pagination_helper_spec.rb +7 -7
- data/spec/helpers/refinery/tag_helper_spec.rb +4 -4
- data/spec/helpers/refinery/translation_helper_spec.rb +3 -3
- data/spec/lib/generators/refinery/cms/cms_generator_spec.rb +30 -25
- data/spec/lib/generators/refinery/core/core_generator_spec.rb +1 -1
- data/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb +7 -8
- data/spec/lib/generators/refinery/engine/engine_generator_sanity_check_spec.rb +15 -15
- data/spec/lib/generators/refinery/engine/engine_generator_spec.rb +9 -9
- data/spec/lib/generators/refinery/engine/engine_generator_with_i18n_spec.rb +1 -1
- data/spec/lib/generators/refinery/engine/engine_generator_without_frontend_spec.rb +1 -1
- data/spec/lib/refinery/application_controller_spec.rb +16 -16
- data/spec/lib/refinery/authorisation_manager_spec.rb +10 -0
- data/spec/lib/refinery/cli_spec.rb +83 -21
- data/spec/lib/refinery/core/configuration_spec.rb +5 -5
- data/spec/lib/refinery/core/nil_user_spec.rb +39 -0
- data/spec/lib/refinery/core_spec.rb +39 -30
- data/spec/lib/refinery/crud_spec.rb +70 -59
- data/spec/lib/refinery/menu_spec.rb +4 -4
- data/spec/lib/refinery/plugin_spec.rb +56 -45
- data/spec/lib/refinery/plugins_spec.rb +39 -87
- data/spec/lib/refinery/users_manager_spec.rb +9 -0
- data/spec/support/refinery.rb +3 -8
- data/vendor/assets/fonts/font-awesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.svg +565 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/stylesheets/_font-awesome-compass.scss +5 -0
- data/vendor/assets/stylesheets/_font-awesome-sprockets.scss +5 -0
- data/vendor/assets/stylesheets/_font-awesome.scss +17 -0
- data/vendor/assets/stylesheets/font-awesome/_animated.scss +34 -0
- data/vendor/assets/stylesheets/font-awesome/_bordered-pulled.scss +16 -0
- data/vendor/assets/stylesheets/font-awesome/_core.scss +12 -0
- data/vendor/assets/stylesheets/font-awesome/_extras.scss +44 -0
- data/vendor/assets/stylesheets/font-awesome/_fixed-width.scss +6 -0
- data/vendor/assets/stylesheets/font-awesome/_icons.scss +596 -0
- data/vendor/assets/stylesheets/font-awesome/_larger.scss +13 -0
- data/vendor/assets/stylesheets/font-awesome/_list.scss +19 -0
- data/vendor/assets/stylesheets/font-awesome/_mixins.scss +26 -0
- data/vendor/assets/stylesheets/font-awesome/_path.scss +14 -0
- data/vendor/assets/stylesheets/font-awesome/_rotated-flipped.scss +20 -0
- data/vendor/assets/stylesheets/font-awesome/_stacked.scss +20 -0
- data/vendor/assets/stylesheets/font-awesome/_variables.scss +606 -0
- metadata +144 -441
- data/app/assets/images/refinery/carousel-left.png +0 -0
- data/app/assets/images/refinery/carousel-right.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/arrow_redo.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/arrow_undo.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/eye.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/article.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/aside.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/blockquote.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/command.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/details.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/figcaption.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/figure.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/footer.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h1.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h2.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h3.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h4.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h5.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/h6.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/header.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/hgroup.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/mark.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/meter.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/nav.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/p.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/pre.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/progress.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/readme.md +0 -1
- data/app/assets/images/wymeditor/skins/refinery/html5/rp.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/rt.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/ruby.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/section.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/summary.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/html5/time.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-blockquote.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h1.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h2.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h3.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h4.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h5.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h6.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-p.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-pre.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/link_add.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/link_break.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/page_code.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/page_paste.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/photo_add.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/right.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/style.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/table_add.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_align_center.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_align_justify.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_align_left.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_align_right.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_bold.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_1.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_2.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_3.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_4.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_5.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_heading_6.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_indent.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_indent_remove.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_italic.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_list_bullets.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_list_numbers.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_paragraph.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_strikethrough.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_subscript.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_superscript.png +0 -0
- data/app/assets/images/wymeditor/skins/refinery/text_underline.png +0 -0
- data/app/assets/images/wymeditor/skins/wymeditor_icon.png +0 -0
- data/app/assets/javascripts/refinery/boot_wym.js.erb +0 -285
- data/app/assets/javascripts/refinery/sortable_menu.js.coffee.erb +0 -20
- data/app/assets/javascripts/refinery/wymeditor.js +0 -37
- data/app/assets/javascripts/wymeditor/GPL-license.txt +0 -278
- data/app/assets/javascripts/wymeditor/MIT-license.txt +0 -20
- data/app/assets/javascripts/wymeditor/README +0 -35
- data/app/assets/javascripts/wymeditor/browsers/ie.js.erb +0 -224
- data/app/assets/javascripts/wymeditor/browsers/mozilla.js.erb +0 -292
- data/app/assets/javascripts/wymeditor/browsers/opera.js.erb +0 -123
- data/app/assets/javascripts/wymeditor/browsers/webkit.js.erb +0 -283
- data/app/assets/javascripts/wymeditor/classes.js.erb +0 -1575
- data/app/assets/javascripts/wymeditor/functions.js.erb +0 -222
- data/app/assets/javascripts/wymeditor/lang/bg.js +0 -57
- data/app/assets/javascripts/wymeditor/lang/ca.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/cs.js +0 -58
- data/app/assets/javascripts/wymeditor/lang/da.js +0 -48
- data/app/assets/javascripts/wymeditor/lang/de.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/en.js +0 -57
- data/app/assets/javascripts/wymeditor/lang/es.js +0 -58
- data/app/assets/javascripts/wymeditor/lang/fa.js +0 -46
- data/app/assets/javascripts/wymeditor/lang/fi.js +0 -57
- data/app/assets/javascripts/wymeditor/lang/fr.js +0 -58
- data/app/assets/javascripts/wymeditor/lang/he.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/hu.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/it.js +0 -48
- data/app/assets/javascripts/wymeditor/lang/ja.js +0 -47
- data/app/assets/javascripts/wymeditor/lang/lv.js +0 -47
- data/app/assets/javascripts/wymeditor/lang/nb.js +0 -48
- data/app/assets/javascripts/wymeditor/lang/nl.js +0 -57
- data/app/assets/javascripts/wymeditor/lang/nn.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/pl.js +0 -56
- data/app/assets/javascripts/wymeditor/lang/pt-BR.js +0 -58
- data/app/assets/javascripts/wymeditor/lang/pt.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/rs.js +0 -47
- data/app/assets/javascripts/wymeditor/lang/ru.js +0 -57
- data/app/assets/javascripts/wymeditor/lang/sk.js +0 -56
- data/app/assets/javascripts/wymeditor/lang/sl.js +0 -47
- data/app/assets/javascripts/wymeditor/lang/sv.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/tr.js +0 -45
- data/app/assets/javascripts/wymeditor/lang/vi.js +0 -47
- data/app/assets/javascripts/wymeditor/lang/zh-CN.js +0 -47
- data/app/assets/javascripts/wymeditor/prototypes.js.erb +0 -1103
- data/app/assets/javascripts/wymeditor/setup.js.erb +0 -622
- data/app/assets/javascripts/wymeditor/skins/refinery/skin.js +0 -45
- data/app/assets/javascripts/wymeditor/validators.js.erb +0 -777
- data/app/assets/stylesheets/refinery/refinery.css +0 -15
- data/app/assets/stylesheets/refinery/site_bar.css.scss +0 -92
- data/app/assets/stylesheets/refinery/ui.css.scss +0 -103
- data/app/assets/stylesheets/wymeditor/skins/refinery/skin.css.scss +0 -530
- data/app/assets/stylesheets/wymeditor/skins/refinery/wymiframe.css.scss +0 -156
- data/app/helpers/refinery/admin/core_helper.rb +0 -6
- data/app/helpers/refinery/admin/dialogs_helper.rb +0 -6
- data/app/helpers/refinery/fast_helper.rb +0 -4
- data/app/helpers/refinery/sitemap_helper.rb +0 -4
- data/app/views/refinery/wymiframe.html.erb +0 -14
- data/lib/generators/refinery/form/USAGE +0 -20
- data/lib/generators/refinery/form/form_generator.rb +0 -25
- data/lib/generators/refinery/form/templates/.gitignore +0 -2
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +0 -54
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/admin/settings_controller.rb.erb +0 -45
- data/lib/generators/refinery/form/templates/app/controllers/refinery/namespace/plural_name_controller.rb.erb +0 -53
- data/lib/generators/refinery/form/templates/app/mailers/refinery/namespace/mailer.rb.erb +0 -22
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/setting.rb.erb +0 -34
- data/lib/generators/refinery/form/templates/app/models/refinery/namespace/singular_name.rb.erb +0 -49
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_records.html.erb +0 -23
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_singular_name.html.erb +0 -25
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/_submenu.html.erb +0 -29
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/index.html.erb +0 -4
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/show.html.erb +0 -52
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/plural_name/spam.html.erb +0 -27
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_confirmation_email_form.html.erb +0 -51
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/_notification_recipients_form.html.erb +0 -21
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/admin/settings/edit.html.erb +0 -5
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/confirmation.html.erb +0 -1
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/mailer/notification.html.erb +0 -17
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/new.html.erb +0 -43
- data/lib/generators/refinery/form/templates/app/views/refinery/namespace/plural_name/thank_you.html.erb +0 -1
- data/lib/generators/refinery/form/templates/config/locales/cs.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/da.yml +0 -66
- data/lib/generators/refinery/form/templates/config/locales/de.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/en.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/es.yml +0 -66
- data/lib/generators/refinery/form/templates/config/locales/fr.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/it.yml +0 -66
- data/lib/generators/refinery/form/templates/config/locales/lv.yml +0 -77
- data/lib/generators/refinery/form/templates/config/locales/nb.yml +0 -75
- data/lib/generators/refinery/form/templates/config/locales/nl.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/pt-BR.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/ru.yml +0 -77
- data/lib/generators/refinery/form/templates/config/locales/sk.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/sl.yml +0 -67
- data/lib/generators/refinery/form/templates/config/locales/tr.yml +0 -78
- data/lib/generators/refinery/form/templates/config/locales/zh-CN.yml +0 -78
- data/lib/generators/refinery/form/templates/config/routes.rb.erb +0 -26
- data/lib/generators/refinery/form/templates/db/migrate/1_create_plural_name.rb.erb +0 -39
- data/lib/generators/refinery/form/templates/db/seeds.rb.erb +0 -31
- data/lib/generators/refinery/form/templates/lib/generators/refinery/plural_name_generator.rb.erb +0 -20
- data/lib/generators/refinery/form/templates/lib/refinery/plural_name.rb.erb +0 -18
- data/lib/generators/refinery/form/templates/lib/refinery/plural_name/engine.rb.erb +0 -27
- data/lib/generators/refinery/form/templates/lib/refinerycms-plural_name.rb.erb +0 -1
- data/lib/generators/refinery/form/templates/refinerycms-plural_name.gemspec +0 -16
- data/lib/generators/refinery/form/templates/script/rails +0 -10
- data/lib/refinery/activity.rb +0 -113
- data/lib/refinery/ext/action_view/helpers/form_builder.rb +0 -9
- data/lib/refinery/ext/action_view/helpers/form_helper.rb +0 -20
- data/lib/refinery/ext/action_view/helpers/form_tag_helper.rb +0 -10
- data/spec/controllers/refinery/admin/refinery_core_controller_spec.rb +0 -19
- data/spec/controllers/refinery/fast_controller_spec.rb +0 -12
- data/spec/lib/generators/refinery/form/form_generator_spec.rb +0 -99
- data/spec/lib/refinery/activity_spec.rb +0 -46
- data/spec/support/background_selenium_firefox_driver.rb +0 -14
- data/vendor/assets/javascripts/jquery/jquery.jcarousel.js +0 -900
@@ -1,1575 +0,0 @@
|
|
1
|
-
/********** XHTML LEXER/PARSER **********/
|
2
|
-
|
3
|
-
/*
|
4
|
-
* @name xml
|
5
|
-
* @description Use these methods to generate XML and XHTML compliant tags and
|
6
|
-
* escape tag attributes correctly
|
7
|
-
* @author Bermi Ferrer - http://bermi.org
|
8
|
-
* @author David Heinemeier Hansson http://loudthinking.com
|
9
|
-
*/
|
10
|
-
WYMeditor.XmlHelper = function()
|
11
|
-
{
|
12
|
-
this._entitiesDiv = document.createElement('div');
|
13
|
-
return this;
|
14
|
-
};
|
15
|
-
|
16
|
-
|
17
|
-
/*
|
18
|
-
* @name tag
|
19
|
-
* @description
|
20
|
-
* Returns an empty HTML tag of type *name* which by default is XHTML
|
21
|
-
* compliant. Setting *open* to true will create an open tag compatible
|
22
|
-
* with HTML 4.0 and below. Add HTML attributes by passing an attributes
|
23
|
-
* array to *options*. For attributes with no value like (disabled and
|
24
|
-
* readonly), give it a value of true in the *options* array.
|
25
|
-
*
|
26
|
-
* Examples:
|
27
|
-
*
|
28
|
-
* this.tag('br')
|
29
|
-
* # => <br />
|
30
|
-
* this.tag ('br', false, true)
|
31
|
-
* # => <br>
|
32
|
-
* this.tag ('input', $({type:'text',disabled:true }) )
|
33
|
-
* # => <input type="text" disabled="disabled" />
|
34
|
-
*/
|
35
|
-
WYMeditor.XmlHelper.prototype.tag = function(name, options, open)
|
36
|
-
{
|
37
|
-
options = options || false;
|
38
|
-
open = open || false;
|
39
|
-
return '<'+name+(options ? this.tagOptions(options) : '')+(open ? '>' : ' />');
|
40
|
-
};
|
41
|
-
|
42
|
-
/*
|
43
|
-
* @name contentTag
|
44
|
-
* @description
|
45
|
-
* Returns a XML block tag of type *name* surrounding the *content*. Add
|
46
|
-
* XML attributes by passing an attributes array to *options*. For attributes
|
47
|
-
* with no value like (disabled and readonly), give it a value of true in
|
48
|
-
* the *options* array. You can use symbols or strings for the attribute names.
|
49
|
-
*
|
50
|
-
* this.contentTag ('p', 'Hello world!' )
|
51
|
-
* # => <p>Hello world!</p>
|
52
|
-
* this.contentTag('div', this.contentTag('p', "Hello world!"), $({class : "strong"}))
|
53
|
-
* # => <div class="strong"><p>Hello world!</p></div>
|
54
|
-
* this.contentTag("select", options, $({multiple : true}))
|
55
|
-
* # => <select multiple="multiple">...options...</select>
|
56
|
-
*/
|
57
|
-
WYMeditor.XmlHelper.prototype.contentTag = function(name, content, options)
|
58
|
-
{
|
59
|
-
options = options || false;
|
60
|
-
return '<'+name+(options ? this.tagOptions(options) : '')+'>'+content+'</'+name+'>';
|
61
|
-
};
|
62
|
-
|
63
|
-
/*
|
64
|
-
* @name cdataSection
|
65
|
-
* @description
|
66
|
-
* Returns a CDATA section for the given +content+. CDATA sections
|
67
|
-
* are used to escape blocks of text containing characters which would
|
68
|
-
* otherwise be recognized as markup. CDATA sections begin with the string
|
69
|
-
* <tt><![CDATA[</tt> and } with (and may not contain) the string
|
70
|
-
* <tt>]]></tt>.
|
71
|
-
*/
|
72
|
-
WYMeditor.XmlHelper.prototype.cdataSection = function(content)
|
73
|
-
{
|
74
|
-
return '<![CDATA['+content+']]>';
|
75
|
-
};
|
76
|
-
|
77
|
-
|
78
|
-
/*
|
79
|
-
* @name escapeOnce
|
80
|
-
* @description
|
81
|
-
* Returns the escaped +xml+ without affecting existing escaped entities.
|
82
|
-
*
|
83
|
-
* this.escapeOnce( "1 > 2 & 3")
|
84
|
-
* # => "1 > 2 & 3"
|
85
|
-
*/
|
86
|
-
WYMeditor.XmlHelper.prototype.escapeOnce = function(xml)
|
87
|
-
{
|
88
|
-
return this._fixDoubleEscape(this.escapeEntities(xml));
|
89
|
-
};
|
90
|
-
|
91
|
-
/*
|
92
|
-
* @name _fixDoubleEscape
|
93
|
-
* @description
|
94
|
-
* Fix double-escaped entities, such as &amp;, &#123;, etc.
|
95
|
-
*/
|
96
|
-
WYMeditor.XmlHelper.prototype._fixDoubleEscape = function(escaped)
|
97
|
-
{
|
98
|
-
return escaped.replace(/&([a-z]+|(#\d+));/ig, "&$1;");
|
99
|
-
};
|
100
|
-
|
101
|
-
/*
|
102
|
-
* @name tagOptions
|
103
|
-
* @description
|
104
|
-
* Takes an array like the one generated by Tag.parseAttributes
|
105
|
-
* [["src", "http://www.editam.com/?a=b&c=d&f=g"], ["title", "Editam, <Simplified> CMS"]]
|
106
|
-
* or an object like {src:"http://www.editam.com/?a=b&c=d&f=g", title:"Editam, <Simplified> CMS"}
|
107
|
-
* and returns a string properly escaped like
|
108
|
-
* ' src = "http://www.editam.com/?a=b&c=d&f=g" title = "Editam, <Simplified> CMS"'
|
109
|
-
* which is valid for strict XHTML
|
110
|
-
*/
|
111
|
-
WYMeditor.XmlHelper.prototype.tagOptions = function(options)
|
112
|
-
{
|
113
|
-
var xml = this;
|
114
|
-
xml._formated_options = '';
|
115
|
-
|
116
|
-
for (var key in options) {
|
117
|
-
var formated_options = '';
|
118
|
-
var value = options[key];
|
119
|
-
if(typeof value != 'function' && value.length > 0) {
|
120
|
-
|
121
|
-
if(parseInt(key) == key && typeof value == 'object'){
|
122
|
-
key = value.shift();
|
123
|
-
value = value.pop();
|
124
|
-
}
|
125
|
-
if(key != '' && value != ''){
|
126
|
-
xml._formated_options += ' '+key+'="'+xml.escapeOnce(value)+'"';
|
127
|
-
}
|
128
|
-
}
|
129
|
-
}
|
130
|
-
return xml._formated_options;
|
131
|
-
};
|
132
|
-
|
133
|
-
/*
|
134
|
-
* @name escapeEntities
|
135
|
-
* @description
|
136
|
-
* Escapes XML/HTML entities <, >, & and ". If seccond parameter is set to false it
|
137
|
-
* will not escape ". If set to true it will also escape '
|
138
|
-
*/
|
139
|
-
WYMeditor.XmlHelper.prototype.escapeEntities = function(string, escape_quotes)
|
140
|
-
{
|
141
|
-
this._entitiesDiv.innerHTML = string;
|
142
|
-
this._entitiesDiv.textContent = string;
|
143
|
-
var result = this._entitiesDiv.innerHTML;
|
144
|
-
if(typeof escape_quotes == 'undefined'){
|
145
|
-
if(escape_quotes != false) result = result.replace('"', '"');
|
146
|
-
if(escape_quotes == true) result = result.replace('"', ''');
|
147
|
-
}
|
148
|
-
return result;
|
149
|
-
};
|
150
|
-
|
151
|
-
/*
|
152
|
-
* Parses a string conatining tag attributes and values an returns an array formated like
|
153
|
-
* [["src", "http://www.editam.com"], ["title", "Editam, Simplified CMS"]]
|
154
|
-
*/
|
155
|
-
WYMeditor.XmlHelper.prototype.parseAttributes = function(tag_attributes)
|
156
|
-
{
|
157
|
-
// Use a compounded regex to match single quoted, double quoted and unquoted attribute pairs
|
158
|
-
var result = [];
|
159
|
-
var matches = tag_attributes.split(/((=\s*")(")("))|((=\s*\')(\')(\'))|((=\s*[^>\s]*))/g);
|
160
|
-
if(matches.toString() != tag_attributes){
|
161
|
-
for (var k in matches) {
|
162
|
-
var v = matches[k];
|
163
|
-
if(typeof v != 'function' && v.length != 0){
|
164
|
-
var re = new RegExp('(\\w+)\\s*'+v);
|
165
|
-
if(match = tag_attributes.match(re) ){
|
166
|
-
var value = v.replace(/^[\s=]+/, "");
|
167
|
-
var delimiter = value.charAt(0);
|
168
|
-
delimiter = delimiter == '"' ? '"' : (delimiter=="'"?"'":'');
|
169
|
-
if(delimiter != ''){
|
170
|
-
value = delimiter == '"' ? value.replace(/^"|"+$/g, '') : value.replace(/^'|'+$/g, '');
|
171
|
-
}
|
172
|
-
tag_attributes = tag_attributes.replace(match[0],'');
|
173
|
-
result.push([match[1] , value]);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
177
|
-
}
|
178
|
-
return result;
|
179
|
-
};
|
180
|
-
|
181
|
-
/**
|
182
|
-
* Compounded regular expression. Any of
|
183
|
-
* the contained patterns could match and
|
184
|
-
* when one does, it's label is returned.
|
185
|
-
*
|
186
|
-
* Constructor. Starts with no patterns.
|
187
|
-
* @param boolean case True for case sensitive, false
|
188
|
-
* for insensitive.
|
189
|
-
* @access public
|
190
|
-
* @author Marcus Baker (http://lastcraft.com)
|
191
|
-
* @author Bermi Ferrer (http://bermi.org)
|
192
|
-
*/
|
193
|
-
WYMeditor.ParallelRegex = function(case_sensitive)
|
194
|
-
{
|
195
|
-
this._case = case_sensitive;
|
196
|
-
this._patterns = [];
|
197
|
-
this._labels = [];
|
198
|
-
this._regex = null;
|
199
|
-
return this;
|
200
|
-
};
|
201
|
-
|
202
|
-
|
203
|
-
/**
|
204
|
-
* Adds a pattern with an optional label.
|
205
|
-
* @param string pattern Perl style regex, but ( and )
|
206
|
-
* lose the usual meaning.
|
207
|
-
* @param string label Label of regex to be returned
|
208
|
-
* on a match.
|
209
|
-
* @access public
|
210
|
-
*/
|
211
|
-
WYMeditor.ParallelRegex.prototype.addPattern = function(pattern, label)
|
212
|
-
{
|
213
|
-
label = label || true;
|
214
|
-
var count = this._patterns.length;
|
215
|
-
this._patterns[count] = pattern;
|
216
|
-
this._labels[count] = label;
|
217
|
-
this._regex = null;
|
218
|
-
};
|
219
|
-
|
220
|
-
/**
|
221
|
-
* Attempts to match all patterns at once against
|
222
|
-
* a string.
|
223
|
-
* @param string subject String to match against.
|
224
|
-
*
|
225
|
-
* @return boolean True on success.
|
226
|
-
* @return string match First matched portion of
|
227
|
-
* subject.
|
228
|
-
* @access public
|
229
|
-
*/
|
230
|
-
WYMeditor.ParallelRegex.prototype.match = function(subject)
|
231
|
-
{
|
232
|
-
if (this._patterns.length == 0) {
|
233
|
-
return [false, ''];
|
234
|
-
}
|
235
|
-
var matches = subject.match(this._getCompoundedRegex());
|
236
|
-
|
237
|
-
if(!matches){
|
238
|
-
return [false, ''];
|
239
|
-
}
|
240
|
-
var match = matches[0];
|
241
|
-
for (var i = 1; i < matches.length; i++) {
|
242
|
-
if (matches[i]) {
|
243
|
-
return [this._labels[i-1], match];
|
244
|
-
}
|
245
|
-
}
|
246
|
-
return [true, matches[0]];
|
247
|
-
};
|
248
|
-
|
249
|
-
/**
|
250
|
-
* Compounds the patterns into a single
|
251
|
-
* regular expression separated with the
|
252
|
-
* "or" operator. Caches the regex.
|
253
|
-
* Will automatically escape (, ) and / tokens.
|
254
|
-
* @param array patterns List of patterns in order.
|
255
|
-
* @access private
|
256
|
-
*/
|
257
|
-
WYMeditor.ParallelRegex.prototype._getCompoundedRegex = function()
|
258
|
-
{
|
259
|
-
if (this._regex == null) {
|
260
|
-
for (var i = 0, count = this._patterns.length; i < count; i++) {
|
261
|
-
this._patterns[i] = '(' + this._untokenizeRegex(this._tokenizeRegex(this._patterns[i]).replace(/([\/\(\)])/g,'\\$1')) + ')';
|
262
|
-
}
|
263
|
-
this._regex = new RegExp(this._patterns.join("|") ,this._getPerlMatchingFlags());
|
264
|
-
}
|
265
|
-
return this._regex;
|
266
|
-
};
|
267
|
-
|
268
|
-
/**
|
269
|
-
* Escape lookahead/lookbehind blocks
|
270
|
-
*/
|
271
|
-
WYMeditor.ParallelRegex.prototype._tokenizeRegex = function(regex)
|
272
|
-
{
|
273
|
-
return regex.
|
274
|
-
replace(/\(\?(i|m|s|x|U)\)/, '~~~~~~Tk1\$1~~~~~~').
|
275
|
-
replace(/\(\?(\-[i|m|s|x|U])\)/, '~~~~~~Tk2\$1~~~~~~').
|
276
|
-
replace(/\(\?\=(.*)\)/, '~~~~~~Tk3\$1~~~~~~').
|
277
|
-
replace(/\(\?\!(.*)\)/, '~~~~~~Tk4\$1~~~~~~').
|
278
|
-
replace(/\(\?\<\=(.*)\)/, '~~~~~~Tk5\$1~~~~~~').
|
279
|
-
replace(/\(\?\<\!(.*)\)/, '~~~~~~Tk6\$1~~~~~~').
|
280
|
-
replace(/\(\?\:(.*)\)/, '~~~~~~Tk7\$1~~~~~~');
|
281
|
-
};
|
282
|
-
|
283
|
-
/**
|
284
|
-
* Unscape lookahead/lookbehind blocks
|
285
|
-
*/
|
286
|
-
WYMeditor.ParallelRegex.prototype._untokenizeRegex = function(regex)
|
287
|
-
{
|
288
|
-
return regex.
|
289
|
-
replace(/~~~~~~Tk1(.{1})~~~~~~/, "(?\$1)").
|
290
|
-
replace(/~~~~~~Tk2(.{2})~~~~~~/, "(?\$1)").
|
291
|
-
replace(/~~~~~~Tk3(.*)~~~~~~/, "(?=\$1)").
|
292
|
-
replace(/~~~~~~Tk4(.*)~~~~~~/, "(?!\$1)").
|
293
|
-
replace(/~~~~~~Tk5(.*)~~~~~~/, "(?<=\$1)").
|
294
|
-
replace(/~~~~~~Tk6(.*)~~~~~~/, "(?<!\$1)").
|
295
|
-
replace(/~~~~~~Tk7(.*)~~~~~~/, "(?:\$1)");
|
296
|
-
};
|
297
|
-
|
298
|
-
|
299
|
-
/**
|
300
|
-
* Accessor for perl regex mode flags to use.
|
301
|
-
* @return string Perl regex flags.
|
302
|
-
* @access private
|
303
|
-
*/
|
304
|
-
WYMeditor.ParallelRegex.prototype._getPerlMatchingFlags = function()
|
305
|
-
{
|
306
|
-
return (this._case ? "m" : "mi");
|
307
|
-
};
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
/**
|
312
|
-
* States for a stack machine.
|
313
|
-
*
|
314
|
-
* Constructor. Starts in named state.
|
315
|
-
* @param string start Starting state name.
|
316
|
-
* @access public
|
317
|
-
* @author Marcus Baker (http://lastcraft.com)
|
318
|
-
* @author Bermi Ferrer (http://bermi.org)
|
319
|
-
*/
|
320
|
-
WYMeditor.StateStack = function(start)
|
321
|
-
{
|
322
|
-
this._stack = [start];
|
323
|
-
return this;
|
324
|
-
};
|
325
|
-
|
326
|
-
/**
|
327
|
-
* Accessor for current state.
|
328
|
-
* @return string State.
|
329
|
-
* @access public
|
330
|
-
*/
|
331
|
-
WYMeditor.StateStack.prototype.getCurrent = function()
|
332
|
-
{
|
333
|
-
return this._stack[this._stack.length - 1];
|
334
|
-
};
|
335
|
-
|
336
|
-
/**
|
337
|
-
* Adds a state to the stack and sets it
|
338
|
-
* to be the current state.
|
339
|
-
* @param string state New state.
|
340
|
-
* @access public
|
341
|
-
*/
|
342
|
-
WYMeditor.StateStack.prototype.enter = function(state)
|
343
|
-
{
|
344
|
-
this._stack.push(state);
|
345
|
-
};
|
346
|
-
|
347
|
-
/**
|
348
|
-
* Leaves the current state and reverts
|
349
|
-
* to the previous one.
|
350
|
-
* @return boolean False if we drop off
|
351
|
-
* the bottom of the list.
|
352
|
-
* @access public
|
353
|
-
*/
|
354
|
-
WYMeditor.StateStack.prototype.leave = function()
|
355
|
-
{
|
356
|
-
if (this._stack.length == 1) {
|
357
|
-
return false;
|
358
|
-
}
|
359
|
-
this._stack.pop();
|
360
|
-
return true;
|
361
|
-
};
|
362
|
-
|
363
|
-
|
364
|
-
// GLOBALS
|
365
|
-
WYMeditor.LEXER_ENTER = 1;
|
366
|
-
WYMeditor.LEXER_MATCHED = 2;
|
367
|
-
WYMeditor.LEXER_UNMATCHED = 3;
|
368
|
-
WYMeditor.LEXER_EXIT = 4;
|
369
|
-
WYMeditor.LEXER_SPECIAL = 5;
|
370
|
-
|
371
|
-
|
372
|
-
/**
|
373
|
-
* Accepts text and breaks it into tokens.
|
374
|
-
* Some optimisation to make the sure the
|
375
|
-
* content is only scanned by the PHP regex
|
376
|
-
* parser once. Lexer modes must not start
|
377
|
-
* with leading underscores.
|
378
|
-
*
|
379
|
-
* Sets up the lexer in case insensitive matching
|
380
|
-
* by default.
|
381
|
-
* @param Parser parser Handling strategy by reference.
|
382
|
-
* @param string start Starting handler.
|
383
|
-
* @param boolean case True for case sensitive.
|
384
|
-
* @access public
|
385
|
-
* @author Marcus Baker (http://lastcraft.com)
|
386
|
-
* @author Bermi Ferrer (http://bermi.org)
|
387
|
-
*/
|
388
|
-
WYMeditor.Lexer = function(parser, start, case_sensitive)
|
389
|
-
{
|
390
|
-
start = start || 'accept';
|
391
|
-
this._case = case_sensitive || false;
|
392
|
-
this._regexes = {};
|
393
|
-
this._parser = parser;
|
394
|
-
this._mode = new WYMeditor.StateStack(start);
|
395
|
-
this._mode_handlers = {};
|
396
|
-
this._mode_handlers[start] = start;
|
397
|
-
return this;
|
398
|
-
};
|
399
|
-
|
400
|
-
/**
|
401
|
-
* Adds a token search pattern for a particular
|
402
|
-
* parsing mode. The pattern does not change the
|
403
|
-
* current mode.
|
404
|
-
* @param string pattern Perl style regex, but ( and )
|
405
|
-
* lose the usual meaning.
|
406
|
-
* @param string mode Should only apply this
|
407
|
-
* pattern when dealing with
|
408
|
-
* this type of input.
|
409
|
-
* @access public
|
410
|
-
*/
|
411
|
-
WYMeditor.Lexer.prototype.addPattern = function(pattern, mode)
|
412
|
-
{
|
413
|
-
var mode = mode || "accept";
|
414
|
-
if (typeof this._regexes[mode] == 'undefined') {
|
415
|
-
this._regexes[mode] = new WYMeditor.ParallelRegex(this._case);
|
416
|
-
}
|
417
|
-
this._regexes[mode].addPattern(pattern);
|
418
|
-
if (typeof this._mode_handlers[mode] == 'undefined') {
|
419
|
-
this._mode_handlers[mode] = mode;
|
420
|
-
}
|
421
|
-
};
|
422
|
-
|
423
|
-
/**
|
424
|
-
* Adds a pattern that will enter a new parsing
|
425
|
-
* mode. Useful for entering parenthesis, strings,
|
426
|
-
* tags, etc.
|
427
|
-
* @param string pattern Perl style regex, but ( and )
|
428
|
-
* lose the usual meaning.
|
429
|
-
* @param string mode Should only apply this
|
430
|
-
* pattern when dealing with
|
431
|
-
* this type of input.
|
432
|
-
* @param string new_mode Change parsing to this new
|
433
|
-
* nested mode.
|
434
|
-
* @access public
|
435
|
-
*/
|
436
|
-
WYMeditor.Lexer.prototype.addEntryPattern = function(pattern, mode, new_mode)
|
437
|
-
{
|
438
|
-
if (typeof this._regexes[mode] == 'undefined') {
|
439
|
-
this._regexes[mode] = new WYMeditor.ParallelRegex(this._case);
|
440
|
-
}
|
441
|
-
this._regexes[mode].addPattern(pattern, new_mode);
|
442
|
-
if (typeof this._mode_handlers[new_mode] == 'undefined') {
|
443
|
-
this._mode_handlers[new_mode] = new_mode;
|
444
|
-
}
|
445
|
-
};
|
446
|
-
|
447
|
-
/**
|
448
|
-
* Adds a pattern that will exit the current mode
|
449
|
-
* and re-enter the previous one.
|
450
|
-
* @param string pattern Perl style regex, but ( and )
|
451
|
-
* lose the usual meaning.
|
452
|
-
* @param string mode Mode to leave.
|
453
|
-
* @access public
|
454
|
-
*/
|
455
|
-
WYMeditor.Lexer.prototype.addExitPattern = function(pattern, mode)
|
456
|
-
{
|
457
|
-
if (typeof this._regexes[mode] == 'undefined') {
|
458
|
-
this._regexes[mode] = new WYMeditor.ParallelRegex(this._case);
|
459
|
-
}
|
460
|
-
this._regexes[mode].addPattern(pattern, "__exit");
|
461
|
-
if (typeof this._mode_handlers[mode] == 'undefined') {
|
462
|
-
this._mode_handlers[mode] = mode;
|
463
|
-
}
|
464
|
-
};
|
465
|
-
|
466
|
-
/**
|
467
|
-
* Adds a pattern that has a special mode. Acts as an entry
|
468
|
-
* and exit pattern in one go, effectively calling a special
|
469
|
-
* parser handler for this token only.
|
470
|
-
* @param string pattern Perl style regex, but ( and )
|
471
|
-
* lose the usual meaning.
|
472
|
-
* @param string mode Should only apply this
|
473
|
-
* pattern when dealing with
|
474
|
-
* this type of input.
|
475
|
-
* @param string special Use this mode for this one token.
|
476
|
-
* @access public
|
477
|
-
*/
|
478
|
-
WYMeditor.Lexer.prototype.addSpecialPattern = function(pattern, mode, special)
|
479
|
-
{
|
480
|
-
if (typeof this._regexes[mode] == 'undefined') {
|
481
|
-
this._regexes[mode] = new WYMeditor.ParallelRegex(this._case);
|
482
|
-
}
|
483
|
-
this._regexes[mode].addPattern(pattern, '_'+special);
|
484
|
-
if (typeof this._mode_handlers[special] == 'undefined') {
|
485
|
-
this._mode_handlers[special] = special;
|
486
|
-
}
|
487
|
-
};
|
488
|
-
|
489
|
-
/**
|
490
|
-
* Adds a mapping from a mode to another handler.
|
491
|
-
* @param string mode Mode to be remapped.
|
492
|
-
* @param string handler New target handler.
|
493
|
-
* @access public
|
494
|
-
*/
|
495
|
-
WYMeditor.Lexer.prototype.mapHandler = function(mode, handler)
|
496
|
-
{
|
497
|
-
this._mode_handlers[mode] = handler;
|
498
|
-
};
|
499
|
-
|
500
|
-
/**
|
501
|
-
* Splits the page text into tokens. Will fail
|
502
|
-
* if the handlers report an error or if no
|
503
|
-
* content is consumed. If successful then each
|
504
|
-
* unparsed and parsed token invokes a call to the
|
505
|
-
* held listener.
|
506
|
-
* @param string raw Raw HTML text.
|
507
|
-
* @return boolean True on success, else false.
|
508
|
-
* @access public
|
509
|
-
*/
|
510
|
-
WYMeditor.Lexer.prototype.parse = function(raw)
|
511
|
-
{
|
512
|
-
if (typeof this._parser == 'undefined') {
|
513
|
-
return false;
|
514
|
-
}
|
515
|
-
|
516
|
-
var length = raw.length;
|
517
|
-
var parsed;
|
518
|
-
while (typeof (parsed = this._reduce(raw)) == 'object') {
|
519
|
-
var raw = parsed[0];
|
520
|
-
var unmatched = parsed[1];
|
521
|
-
var matched = parsed[2];
|
522
|
-
var mode = parsed[3];
|
523
|
-
|
524
|
-
if (! this._dispatchTokens(unmatched, matched, mode)) {
|
525
|
-
return false;
|
526
|
-
}
|
527
|
-
|
528
|
-
if (raw == '') {
|
529
|
-
return true;
|
530
|
-
}
|
531
|
-
if (raw.length == length) {
|
532
|
-
return false;
|
533
|
-
}
|
534
|
-
length = raw.length;
|
535
|
-
}
|
536
|
-
if (! parsed ) {
|
537
|
-
return false;
|
538
|
-
}
|
539
|
-
|
540
|
-
return this._invokeParser(raw, WYMeditor.LEXER_UNMATCHED);
|
541
|
-
};
|
542
|
-
|
543
|
-
/**
|
544
|
-
* Sends the matched token and any leading unmatched
|
545
|
-
* text to the parser changing the lexer to a new
|
546
|
-
* mode if one is listed.
|
547
|
-
* @param string unmatched Unmatched leading portion.
|
548
|
-
* @param string matched Actual token match.
|
549
|
-
* @param string mode Mode after match. A boolean
|
550
|
-
* false mode causes no change.
|
551
|
-
* @return boolean False if there was any error
|
552
|
-
* from the parser.
|
553
|
-
* @access private
|
554
|
-
*/
|
555
|
-
WYMeditor.Lexer.prototype._dispatchTokens = function(unmatched, matched, mode)
|
556
|
-
{
|
557
|
-
mode = mode || false;
|
558
|
-
|
559
|
-
if (! this._invokeParser(unmatched, WYMeditor.LEXER_UNMATCHED)) {
|
560
|
-
return false;
|
561
|
-
}
|
562
|
-
|
563
|
-
if (typeof mode == 'boolean') {
|
564
|
-
return this._invokeParser(matched, WYMeditor.LEXER_MATCHED);
|
565
|
-
}
|
566
|
-
if (this._isModeEnd(mode)) {
|
567
|
-
if (! this._invokeParser(matched, WYMeditor.LEXER_EXIT)) {
|
568
|
-
return false;
|
569
|
-
}
|
570
|
-
return this._mode.leave();
|
571
|
-
}
|
572
|
-
if (this._isSpecialMode(mode)) {
|
573
|
-
this._mode.enter(this._decodeSpecial(mode));
|
574
|
-
if (! this._invokeParser(matched, WYMeditor.LEXER_SPECIAL)) {
|
575
|
-
return false;
|
576
|
-
}
|
577
|
-
return this._mode.leave();
|
578
|
-
}
|
579
|
-
this._mode.enter(mode);
|
580
|
-
|
581
|
-
return this._invokeParser(matched, WYMeditor.LEXER_ENTER);
|
582
|
-
};
|
583
|
-
|
584
|
-
/**
|
585
|
-
* Tests to see if the new mode is actually to leave
|
586
|
-
* the current mode and pop an item from the matching
|
587
|
-
* mode stack.
|
588
|
-
* @param string mode Mode to test.
|
589
|
-
* @return boolean True if this is the exit mode.
|
590
|
-
* @access private
|
591
|
-
*/
|
592
|
-
WYMeditor.Lexer.prototype._isModeEnd = function(mode)
|
593
|
-
{
|
594
|
-
return (mode === "__exit");
|
595
|
-
};
|
596
|
-
|
597
|
-
/**
|
598
|
-
* Test to see if the mode is one where this mode
|
599
|
-
* is entered for this token only and automatically
|
600
|
-
* leaves immediately afterwoods.
|
601
|
-
* @param string mode Mode to test.
|
602
|
-
* @return boolean True if this is the exit mode.
|
603
|
-
* @access private
|
604
|
-
*/
|
605
|
-
WYMeditor.Lexer.prototype._isSpecialMode = function(mode)
|
606
|
-
{
|
607
|
-
return (mode.substring(0,1) == "_");
|
608
|
-
};
|
609
|
-
|
610
|
-
/**
|
611
|
-
* Strips the magic underscore marking single token
|
612
|
-
* modes.
|
613
|
-
* @param string mode Mode to decode.
|
614
|
-
* @return string Underlying mode name.
|
615
|
-
* @access private
|
616
|
-
*/
|
617
|
-
WYMeditor.Lexer.prototype._decodeSpecial = function(mode)
|
618
|
-
{
|
619
|
-
return mode.substring(1);
|
620
|
-
};
|
621
|
-
|
622
|
-
/**
|
623
|
-
* Calls the parser method named after the current
|
624
|
-
* mode. Empty content will be ignored. The lexer
|
625
|
-
* has a parser handler for each mode in the lexer.
|
626
|
-
* @param string content Text parsed.
|
627
|
-
* @param boolean is_match Token is recognised rather
|
628
|
-
* than unparsed data.
|
629
|
-
* @access private
|
630
|
-
*/
|
631
|
-
WYMeditor.Lexer.prototype._invokeParser = function(content, is_match)
|
632
|
-
{
|
633
|
-
|
634
|
-
if (content === '') {
|
635
|
-
return true;
|
636
|
-
}
|
637
|
-
var current = this._mode.getCurrent();
|
638
|
-
var handler = this._mode_handlers[current];
|
639
|
-
return this._parser[handler](content, is_match);
|
640
|
-
};
|
641
|
-
|
642
|
-
/**
|
643
|
-
* Tries to match a chunk of text and if successful
|
644
|
-
* removes the recognised chunk and any leading
|
645
|
-
* unparsed data. Empty strings will not be matched.
|
646
|
-
* @param string raw The subject to parse. This is the
|
647
|
-
* content that will be eaten.
|
648
|
-
* @return array/boolean Three item list of unparsed
|
649
|
-
* content followed by the
|
650
|
-
* recognised token and finally the
|
651
|
-
* action the parser is to take.
|
652
|
-
* True if no match, false if there
|
653
|
-
* is a parsing error.
|
654
|
-
* @access private
|
655
|
-
*/
|
656
|
-
WYMeditor.Lexer.prototype._reduce = function(raw)
|
657
|
-
{
|
658
|
-
var matched = this._regexes[this._mode.getCurrent()].match(raw);
|
659
|
-
var match = matched[1];
|
660
|
-
var action = matched[0];
|
661
|
-
if (action) {
|
662
|
-
var unparsed_character_count = raw.indexOf(match);
|
663
|
-
var unparsed = raw.substr(0, unparsed_character_count);
|
664
|
-
raw = raw.substring(unparsed_character_count + match.length);
|
665
|
-
return [raw, unparsed, match, action];
|
666
|
-
}
|
667
|
-
return true;
|
668
|
-
};
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
/**
|
673
|
-
* This are the rules for breaking the XHTML code into events
|
674
|
-
* handled by the provided parser.
|
675
|
-
*
|
676
|
-
* @author Marcus Baker (http://lastcraft.com)
|
677
|
-
* @author Bermi Ferrer (http://bermi.org)
|
678
|
-
*/
|
679
|
-
WYMeditor.XhtmlLexer = function(parser)
|
680
|
-
{
|
681
|
-
$.extend(this, new WYMeditor.Lexer(parser, 'Text'));
|
682
|
-
|
683
|
-
this.mapHandler('Text', 'Text');
|
684
|
-
|
685
|
-
this.addTokens();
|
686
|
-
|
687
|
-
this.init();
|
688
|
-
|
689
|
-
return this;
|
690
|
-
};
|
691
|
-
|
692
|
-
|
693
|
-
WYMeditor.XhtmlLexer.prototype.init = function()
|
694
|
-
{
|
695
|
-
};
|
696
|
-
|
697
|
-
WYMeditor.XhtmlLexer.prototype.addTokens = function()
|
698
|
-
{
|
699
|
-
this.addCommentTokens('Text');
|
700
|
-
this.addScriptTokens('Text');
|
701
|
-
this.addCssTokens('Text');
|
702
|
-
this.addTagTokens('Text');
|
703
|
-
};
|
704
|
-
|
705
|
-
WYMeditor.XhtmlLexer.prototype.addCommentTokens = function(scope)
|
706
|
-
{
|
707
|
-
this.addEntryPattern("<!--", scope, 'Comment');
|
708
|
-
this.addExitPattern("-->", 'Comment');
|
709
|
-
};
|
710
|
-
|
711
|
-
WYMeditor.XhtmlLexer.prototype.addScriptTokens = function(scope)
|
712
|
-
{
|
713
|
-
this.addEntryPattern("<script", scope, 'Script');
|
714
|
-
this.addExitPattern("</script>", 'Script');
|
715
|
-
};
|
716
|
-
|
717
|
-
WYMeditor.XhtmlLexer.prototype.addCssTokens = function(scope)
|
718
|
-
{
|
719
|
-
this.addEntryPattern("<style", scope, 'Css');
|
720
|
-
this.addExitPattern("</style>", 'Css');
|
721
|
-
};
|
722
|
-
|
723
|
-
WYMeditor.XhtmlLexer.prototype.addTagTokens = function(scope)
|
724
|
-
{
|
725
|
-
this.addSpecialPattern("<\\s*[a-z0-9:\-]+\\s*>", scope, 'OpeningTag');
|
726
|
-
this.addEntryPattern("<[a-z0-9:\-]+"+'[\\\/ \\\>]+', scope, 'OpeningTag');
|
727
|
-
this.addInTagDeclarationTokens('OpeningTag');
|
728
|
-
|
729
|
-
this.addSpecialPattern("</\\s*[a-z0-9:\-]+\\s*>", scope, 'ClosingTag');
|
730
|
-
|
731
|
-
};
|
732
|
-
|
733
|
-
WYMeditor.XhtmlLexer.prototype.addInTagDeclarationTokens = function(scope)
|
734
|
-
{
|
735
|
-
this.addSpecialPattern('\\s+', scope, 'Ignore');
|
736
|
-
|
737
|
-
this.addAttributeTokens(scope);
|
738
|
-
|
739
|
-
this.addExitPattern('/>', scope);
|
740
|
-
this.addExitPattern('>', scope);
|
741
|
-
|
742
|
-
};
|
743
|
-
|
744
|
-
WYMeditor.XhtmlLexer.prototype.addAttributeTokens = function(scope)
|
745
|
-
{
|
746
|
-
this.addSpecialPattern("\\s*[a-z-_0-9]*:?[a-z-_0-9]+\\s*(?=\=)\\s*", scope, 'TagAttributes');
|
747
|
-
|
748
|
-
this.addEntryPattern('=\\s*"', scope, 'DoubleQuotedAttribute');
|
749
|
-
this.addPattern("\\\\\"", 'DoubleQuotedAttribute');
|
750
|
-
this.addExitPattern('"', 'DoubleQuotedAttribute');
|
751
|
-
|
752
|
-
this.addEntryPattern("=\\s*'", scope, 'SingleQuotedAttribute');
|
753
|
-
this.addPattern("\\\\'", 'SingleQuotedAttribute');
|
754
|
-
this.addExitPattern("'", 'SingleQuotedAttribute');
|
755
|
-
|
756
|
-
this.addSpecialPattern('=\\s*[^>\\s]*', scope, 'UnquotedAttribute');
|
757
|
-
};
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
/**
|
762
|
-
* XHTML Parser.
|
763
|
-
*
|
764
|
-
* This XHTML parser will trigger the events available on on
|
765
|
-
* current SaxListener
|
766
|
-
*
|
767
|
-
* @author Bermi Ferrer (http://bermi.org)
|
768
|
-
*/
|
769
|
-
WYMeditor.XhtmlParser = function(Listener, mode)
|
770
|
-
{
|
771
|
-
var mode = mode || 'Text';
|
772
|
-
this._Lexer = new WYMeditor.XhtmlLexer(this);
|
773
|
-
this._Listener = Listener;
|
774
|
-
this._mode = mode;
|
775
|
-
this._matches = [];
|
776
|
-
this._last_match = '';
|
777
|
-
this._current_match = '';
|
778
|
-
|
779
|
-
return this;
|
780
|
-
};
|
781
|
-
|
782
|
-
WYMeditor.XhtmlParser.prototype.parse = function(raw)
|
783
|
-
{
|
784
|
-
this._Lexer.parse(this.beforeParsing(raw));
|
785
|
-
return this.afterParsing(this._Listener.getResult());
|
786
|
-
};
|
787
|
-
|
788
|
-
WYMeditor.XhtmlParser.prototype.beforeParsing = function(raw)
|
789
|
-
{
|
790
|
-
if(raw.match(/class="MsoNormal"/) || raw.match(/ns = "urn:schemas-microsoft-com/)){
|
791
|
-
// Useful for cleaning up content pasted from other sources (MSWord)
|
792
|
-
this._Listener.avoidStylingTagsAndAttributes();
|
793
|
-
}
|
794
|
-
return this._Listener.beforeParsing(raw);
|
795
|
-
};
|
796
|
-
|
797
|
-
WYMeditor.XhtmlParser.prototype.afterParsing = function(parsed)
|
798
|
-
{
|
799
|
-
if(this._Listener._avoiding_tags_implicitly){
|
800
|
-
this._Listener.allowStylingTagsAndAttributes();
|
801
|
-
}
|
802
|
-
return this._Listener.afterParsing(parsed);
|
803
|
-
};
|
804
|
-
|
805
|
-
|
806
|
-
WYMeditor.XhtmlParser.prototype.Ignore = function(match, state)
|
807
|
-
{
|
808
|
-
return true;
|
809
|
-
};
|
810
|
-
|
811
|
-
WYMeditor.XhtmlParser.prototype.Text = function(text)
|
812
|
-
{
|
813
|
-
this._Listener.addContent(text);
|
814
|
-
return true;
|
815
|
-
};
|
816
|
-
|
817
|
-
WYMeditor.XhtmlParser.prototype.Comment = function(match, status)
|
818
|
-
{
|
819
|
-
return this._addNonTagBlock(match, status, 'addComment');
|
820
|
-
};
|
821
|
-
|
822
|
-
WYMeditor.XhtmlParser.prototype.Script = function(match, status)
|
823
|
-
{
|
824
|
-
return this._addNonTagBlock(match, status, 'addScript');
|
825
|
-
};
|
826
|
-
|
827
|
-
WYMeditor.XhtmlParser.prototype.Css = function(match, status)
|
828
|
-
{
|
829
|
-
return this._addNonTagBlock(match, status, 'addCss');
|
830
|
-
};
|
831
|
-
|
832
|
-
WYMeditor.XhtmlParser.prototype._addNonTagBlock = function(match, state, type)
|
833
|
-
{
|
834
|
-
switch (state){
|
835
|
-
case WYMeditor.LEXER_ENTER:
|
836
|
-
this._non_tag = match;
|
837
|
-
break;
|
838
|
-
case WYMeditor.LEXER_UNMATCHED:
|
839
|
-
this._non_tag += match;
|
840
|
-
break;
|
841
|
-
case WYMeditor.LEXER_EXIT:
|
842
|
-
switch(type) {
|
843
|
-
case 'addComment':
|
844
|
-
this._Listener.addComment(this._non_tag+match);
|
845
|
-
break;
|
846
|
-
case 'addScript':
|
847
|
-
this._Listener.addScript(this._non_tag+match);
|
848
|
-
break;
|
849
|
-
case 'addCss':
|
850
|
-
this._Listener.addCss(this._non_tag+match);
|
851
|
-
break;
|
852
|
-
}
|
853
|
-
}
|
854
|
-
return true;
|
855
|
-
};
|
856
|
-
|
857
|
-
WYMeditor.XhtmlParser.prototype.OpeningTag = function(match, state)
|
858
|
-
{
|
859
|
-
switch (state){
|
860
|
-
case WYMeditor.LEXER_ENTER:
|
861
|
-
this._tag = this.normalizeTag(match);
|
862
|
-
this._tag_attributes = {};
|
863
|
-
break;
|
864
|
-
case WYMeditor.LEXER_SPECIAL:
|
865
|
-
this._callOpenTagListener(this.normalizeTag(match));
|
866
|
-
break;
|
867
|
-
case WYMeditor.LEXER_EXIT:
|
868
|
-
this._callOpenTagListener(this._tag, this._tag_attributes);
|
869
|
-
}
|
870
|
-
return true;
|
871
|
-
};
|
872
|
-
|
873
|
-
WYMeditor.XhtmlParser.prototype.ClosingTag = function(match, state)
|
874
|
-
{
|
875
|
-
this._callCloseTagListener(this.normalizeTag(match));
|
876
|
-
return true;
|
877
|
-
};
|
878
|
-
|
879
|
-
WYMeditor.XhtmlParser.prototype._callOpenTagListener = function(tag, attributes)
|
880
|
-
{
|
881
|
-
var attributes = attributes || {};
|
882
|
-
this.autoCloseUnclosedBeforeNewOpening(tag);
|
883
|
-
|
884
|
-
if(this._Listener.isBlockTag(tag)){
|
885
|
-
this._Listener._tag_stack.push(tag);
|
886
|
-
this._Listener.fixNestingBeforeOpeningBlockTag(tag, attributes);
|
887
|
-
this._Listener.openBlockTag(tag, attributes);
|
888
|
-
this._increaseOpenTagCounter(tag);
|
889
|
-
}else if(this._Listener.isInlineTag(tag)){
|
890
|
-
this._Listener.inlineTag(tag, attributes);
|
891
|
-
}else{
|
892
|
-
this._Listener.openUnknownTag(tag, attributes);
|
893
|
-
this._increaseOpenTagCounter(tag);
|
894
|
-
}
|
895
|
-
this._Listener.last_tag = tag;
|
896
|
-
this._Listener.last_tag_opened = true;
|
897
|
-
this._Listener.last_tag_attributes = attributes;
|
898
|
-
};
|
899
|
-
|
900
|
-
WYMeditor.XhtmlParser.prototype._callCloseTagListener = function(tag)
|
901
|
-
{
|
902
|
-
if(this._decreaseOpenTagCounter(tag)){
|
903
|
-
this.autoCloseUnclosedBeforeTagClosing(tag);
|
904
|
-
|
905
|
-
if(this._Listener.isBlockTag(tag)){
|
906
|
-
var expected_tag = this._Listener._tag_stack.pop();
|
907
|
-
if(expected_tag == false){
|
908
|
-
return;
|
909
|
-
}else if(expected_tag != tag){
|
910
|
-
tag = expected_tag;
|
911
|
-
}
|
912
|
-
this._Listener.closeBlockTag(tag);
|
913
|
-
}else{
|
914
|
-
this._Listener.closeUnknownTag(tag);
|
915
|
-
}
|
916
|
-
}else{
|
917
|
-
this._Listener.closeUnopenedTag(tag);
|
918
|
-
}
|
919
|
-
this._Listener.last_tag = tag;
|
920
|
-
this._Listener.last_tag_opened = false;
|
921
|
-
};
|
922
|
-
|
923
|
-
WYMeditor.XhtmlParser.prototype._increaseOpenTagCounter = function(tag)
|
924
|
-
{
|
925
|
-
this._Listener._open_tags[tag] = this._Listener._open_tags[tag] || 0;
|
926
|
-
this._Listener._open_tags[tag]++;
|
927
|
-
};
|
928
|
-
|
929
|
-
WYMeditor.XhtmlParser.prototype._decreaseOpenTagCounter = function(tag)
|
930
|
-
{
|
931
|
-
if(this._Listener._open_tags[tag]){
|
932
|
-
this._Listener._open_tags[tag]--;
|
933
|
-
if(this._Listener._open_tags[tag] == 0){
|
934
|
-
this._Listener._open_tags[tag] = undefined;
|
935
|
-
}
|
936
|
-
return true;
|
937
|
-
}
|
938
|
-
return false;
|
939
|
-
};
|
940
|
-
|
941
|
-
WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeNewOpening = function(new_tag)
|
942
|
-
{
|
943
|
-
this._autoCloseUnclosed(new_tag, false);
|
944
|
-
};
|
945
|
-
|
946
|
-
WYMeditor.XhtmlParser.prototype.autoCloseUnclosedBeforeTagClosing = function(tag)
|
947
|
-
{
|
948
|
-
this._autoCloseUnclosed(tag, true);
|
949
|
-
};
|
950
|
-
|
951
|
-
WYMeditor.XhtmlParser.prototype._autoCloseUnclosed = function(new_tag, closing)
|
952
|
-
{
|
953
|
-
var closing = closing || false;
|
954
|
-
if(this._Listener._open_tags){
|
955
|
-
for (var tag in this._Listener._open_tags) {
|
956
|
-
var counter = this._Listener._open_tags[tag];
|
957
|
-
if(counter > 0 && this._Listener.shouldCloseTagAutomatically(tag, new_tag, closing)){
|
958
|
-
this._callCloseTagListener(tag, true);
|
959
|
-
}
|
960
|
-
}
|
961
|
-
}
|
962
|
-
};
|
963
|
-
|
964
|
-
WYMeditor.XhtmlParser.prototype.getTagReplacements = function()
|
965
|
-
{
|
966
|
-
return this._Listener.getTagReplacements();
|
967
|
-
};
|
968
|
-
|
969
|
-
WYMeditor.XhtmlParser.prototype.normalizeTag = function(tag)
|
970
|
-
{
|
971
|
-
tag = tag.replace(/^([\s<\/>]*)|([\s<\/>]*)$/gm,'').toLowerCase();
|
972
|
-
var tags = this._Listener.getTagReplacements();
|
973
|
-
if(tags[tag]){
|
974
|
-
return tags[tag];
|
975
|
-
}
|
976
|
-
return tag;
|
977
|
-
};
|
978
|
-
|
979
|
-
WYMeditor.XhtmlParser.prototype.TagAttributes = function(match, state)
|
980
|
-
{
|
981
|
-
if(WYMeditor.LEXER_SPECIAL == state){
|
982
|
-
this._current_attribute = match;
|
983
|
-
}
|
984
|
-
return true;
|
985
|
-
};
|
986
|
-
|
987
|
-
WYMeditor.XhtmlParser.prototype.DoubleQuotedAttribute = function(match, state)
|
988
|
-
{
|
989
|
-
if(WYMeditor.LEXER_UNMATCHED == state){
|
990
|
-
this._tag_attributes[this._current_attribute] = match;
|
991
|
-
}
|
992
|
-
return true;
|
993
|
-
};
|
994
|
-
|
995
|
-
WYMeditor.XhtmlParser.prototype.SingleQuotedAttribute = function(match, state)
|
996
|
-
{
|
997
|
-
if(WYMeditor.LEXER_UNMATCHED == state){
|
998
|
-
this._tag_attributes[this._current_attribute] = match;
|
999
|
-
}
|
1000
|
-
return true;
|
1001
|
-
};
|
1002
|
-
|
1003
|
-
WYMeditor.XhtmlParser.prototype.UnquotedAttribute = function(match, state)
|
1004
|
-
{
|
1005
|
-
this._tag_attributes[this._current_attribute] = match.replace(/^=/,'');
|
1006
|
-
return true;
|
1007
|
-
};
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
/**
|
1012
|
-
* XHTML Sax parser.
|
1013
|
-
*
|
1014
|
-
* @author Bermi Ferrer (http://bermi.org)
|
1015
|
-
*/
|
1016
|
-
WYMeditor.XhtmlSaxListener = function()
|
1017
|
-
{
|
1018
|
-
this.output = '';
|
1019
|
-
this.helper = new WYMeditor.XmlHelper();
|
1020
|
-
this._open_tags = {};
|
1021
|
-
this.validator = WYMeditor.XhtmlValidator;
|
1022
|
-
this._tag_stack = [];
|
1023
|
-
|
1024
|
-
this.avoided_tags = ['area'];
|
1025
|
-
|
1026
|
-
this.entities = {
|
1027
|
-
' ':' ','¡':'¡','¢':'¢',
|
1028
|
-
'£':'£','¤':'¤','¥':'¥',
|
1029
|
-
'¦':'¦','§':'§','¨':'¨',
|
1030
|
-
'©':'©','ª':'ª','«':'«',
|
1031
|
-
'¬':'¬','­':'­','®':'®',
|
1032
|
-
'¯':'¯','°':'°','±':'±',
|
1033
|
-
'²':'²','³':'³','´':'´',
|
1034
|
-
'µ':'µ','¶':'¶','·':'·',
|
1035
|
-
'¸':'¸','¹':'¹','º':'º',
|
1036
|
-
'»':'»','¼':'¼','½':'½',
|
1037
|
-
'¾':'¾','¿':'¿','À':'À',
|
1038
|
-
'Á':'Á','Â':'Â','Ã':'Ã',
|
1039
|
-
'Ä':'Ä','Å':'Å','Æ':'Æ',
|
1040
|
-
'Ç':'Ç','È':'È','É':'É',
|
1041
|
-
'Ê':'Ê','Ë':'Ë','Ì':'Ì',
|
1042
|
-
'Í':'Í','Î':'Î','Ï':'Ï',
|
1043
|
-
'Ð':'Ð','Ñ':'Ñ','Ò':'Ò',
|
1044
|
-
'Ó':'Ó','Ô':'Ô','Õ':'Õ',
|
1045
|
-
'Ö':'Ö','×':'×','Ø':'Ø',
|
1046
|
-
'Ù':'Ù','Ú':'Ú','Û':'Û',
|
1047
|
-
'Ü':'Ü','Ý':'Ý','Þ':'Þ',
|
1048
|
-
'ß':'ß','à':'à','á':'á',
|
1049
|
-
'â':'â','ã':'ã','ä':'ä',
|
1050
|
-
'å':'å','æ':'æ','ç':'ç',
|
1051
|
-
'è':'è','é':'é','ê':'ê',
|
1052
|
-
'ë':'ë','ì':'ì','í':'í',
|
1053
|
-
'î':'î','ï':'ï','ð':'ð',
|
1054
|
-
'ñ':'ñ','ò':'ò','ó':'ó',
|
1055
|
-
'ô':'ô','õ':'õ','ö':'ö',
|
1056
|
-
'÷':'÷','ø':'ø','ù':'ù',
|
1057
|
-
'ú':'ú','û':'û','ü':'ü',
|
1058
|
-
'ý':'ý','þ':'þ','ÿ':'ÿ',
|
1059
|
-
'Œ':'Œ','œ':'œ','Š':'Š',
|
1060
|
-
'š':'š','Ÿ':'Ÿ','ƒ':'ƒ',
|
1061
|
-
'ˆ':'ˆ','˜':'˜','Α':'Α',
|
1062
|
-
'Β':'Β','Γ':'Γ','Δ':'Δ',
|
1063
|
-
'Ε':'Ε','Ζ':'Ζ','Η':'Η',
|
1064
|
-
'Θ':'Θ','Ι':'Ι','Κ':'Κ',
|
1065
|
-
'Λ':'Λ','Μ':'Μ','Ν':'Ν',
|
1066
|
-
'Ξ':'Ξ','Ο':'Ο','Π':'Π',
|
1067
|
-
'Ρ':'Ρ','Σ':'Σ','Τ':'Τ',
|
1068
|
-
'Υ':'Υ','Φ':'Φ','Χ':'Χ',
|
1069
|
-
'Ψ':'Ψ','Ω':'Ω','α':'α',
|
1070
|
-
'β':'β','γ':'γ','δ':'δ',
|
1071
|
-
'ε':'ε','ζ':'ζ','η':'η',
|
1072
|
-
'θ':'θ','ι':'ι','κ':'κ',
|
1073
|
-
'λ':'λ','μ':'μ','ν':'ν',
|
1074
|
-
'ξ':'ξ','ο':'ο','π':'π',
|
1075
|
-
'ρ':'ρ','ς':'ς','σ':'σ',
|
1076
|
-
'τ':'τ','υ':'υ','φ':'φ',
|
1077
|
-
'χ':'χ','ψ':'ψ','ω':'ω',
|
1078
|
-
'ϑ':'ϑ','ϒ':'ϒ','ϖ':'ϖ',
|
1079
|
-
' ':' ',' ':' ',' ':' ',
|
1080
|
-
'‌':'‌','‍':'‍','‎':'‎',
|
1081
|
-
'‏':'‏','–':'–','—':'—',
|
1082
|
-
'‘':'‘','’':'’','‚':'‚',
|
1083
|
-
'“':'“','”':'”','„':'„',
|
1084
|
-
'†':'†','‡':'‡','•':'•',
|
1085
|
-
'…':'…','‰':'‰','′':'′',
|
1086
|
-
'″':'″','‹':'‹','›':'›',
|
1087
|
-
'‾':'‾','⁄':'⁄','€':'€',
|
1088
|
-
'ℑ':'ℑ','℘':'℘','ℜ':'ℜ',
|
1089
|
-
'™':'™','ℵ':'ℵ','←':'←',
|
1090
|
-
'↑':'↑','→':'→','↓':'↓',
|
1091
|
-
'↔':'↔','↵':'↵','⇐':'⇐',
|
1092
|
-
'⇑':'⇑','⇒':'⇒','⇓':'⇓',
|
1093
|
-
'⇔':'⇔','∀':'∀','∂':'∂',
|
1094
|
-
'∃':'∃','∅':'∅','∇':'∇',
|
1095
|
-
'∈':'∈','∉':'∉','∋':'∋',
|
1096
|
-
'∏':'∏','∑':'∑','−':'−',
|
1097
|
-
'∗':'∗','√':'√','∝':'∝',
|
1098
|
-
'∞':'∞','∠':'∠','∧':'∧',
|
1099
|
-
'∨':'∨','∩':'∩','∪':'∪',
|
1100
|
-
'∫':'∫','∴':'∴','∼':'∼',
|
1101
|
-
'≅':'≅','≈':'≈','≠':'≠',
|
1102
|
-
'≡':'≡','≤':'≤','≥':'≥',
|
1103
|
-
'⊂':'⊂','⊃':'⊃','⊄':'⊄',
|
1104
|
-
'⊆':'⊆','⊇':'⊇','⊕':'⊕',
|
1105
|
-
'⊗':'⊗','⊥':'⊥','⋅':'⋅',
|
1106
|
-
'⌈':'⌈','⌉':'⌉','⌊':'⌊',
|
1107
|
-
'⌋':'⌋','⟨':'〈','⟩':'〉',
|
1108
|
-
'◊':'◊','♠':'♠','♣':'♣',
|
1109
|
-
'♥':'♥','♦':'♦'};
|
1110
|
-
|
1111
|
-
this.block_tags = ["a", "abbr", "acronym", "address", "area", "b",
|
1112
|
-
"base", "bdo", "big", "blockquote", "body", "button",
|
1113
|
-
"caption", "cite", "code", "col", "colgroup", "dd", "del", "div",
|
1114
|
-
"dfn", "dl", "dt", "em", "fieldset", "form", "head", "h1", "h2",
|
1115
|
-
"h3", "h4", "h5", "h6", "html", "i", "iframe", "ins",
|
1116
|
-
"kbd", "label", "legend", "li", "map", "noscript",
|
1117
|
-
"object", "ol", "optgroup", "option", "p", "pre", "q",
|
1118
|
-
"samp", "script", "select", "small", "span", "strong", "style",
|
1119
|
-
"sub", "sup", "table", "tbody", "td", "textarea", "tfoot", "th",
|
1120
|
-
"thead", "title", "tr", "tt", "ul", "var", "extends", "meter",
|
1121
|
-
"section", "article", "aside", "details", "header", "footer",
|
1122
|
-
"nav", "dialog", "figure", "figcaption", "address", "hgroup",
|
1123
|
-
"mark", "time", "canvas", "audio", "video", "output",
|
1124
|
-
"progress", "ruby", "rt", "rp", "summary", "command"];
|
1125
|
-
|
1126
|
-
|
1127
|
-
// Defines self-closing tags.
|
1128
|
-
this.inline_tags = ["br", "embed", "hr", "img", "input", "param", "source", "wbr"];
|
1129
|
-
|
1130
|
-
return this;
|
1131
|
-
};
|
1132
|
-
|
1133
|
-
WYMeditor.XhtmlSaxListener.prototype.shouldCloseTagAutomatically = function(tag, now_on_tag, closing)
|
1134
|
-
{
|
1135
|
-
var closing = closing || false;
|
1136
|
-
if(tag == 'td'){
|
1137
|
-
if((closing && now_on_tag == 'tr') || (!closing && now_on_tag == 'td')){
|
1138
|
-
return true;
|
1139
|
-
}
|
1140
|
-
}
|
1141
|
-
if(tag == 'option'){
|
1142
|
-
if((closing && now_on_tag == 'select') || (!closing && now_on_tag == 'option')){
|
1143
|
-
return true;
|
1144
|
-
}
|
1145
|
-
}
|
1146
|
-
return false;
|
1147
|
-
};
|
1148
|
-
|
1149
|
-
WYMeditor.XhtmlSaxListener.prototype.beforeParsing = function(raw)
|
1150
|
-
{
|
1151
|
-
this.output = '';
|
1152
|
-
return raw;
|
1153
|
-
};
|
1154
|
-
|
1155
|
-
WYMeditor.XhtmlSaxListener.prototype.afterParsing = function(xhtml)
|
1156
|
-
{
|
1157
|
-
xhtml = this.replaceNamedEntities(xhtml);
|
1158
|
-
xhtml = this.joinRepeatedEntities(xhtml);
|
1159
|
-
xhtml = this.removeEmptyTags(xhtml);
|
1160
|
-
return xhtml;
|
1161
|
-
};
|
1162
|
-
|
1163
|
-
WYMeditor.XhtmlSaxListener.prototype.replaceNamedEntities = function(xhtml)
|
1164
|
-
{
|
1165
|
-
for (var entity in this.entities) {
|
1166
|
-
xhtml = xhtml.replace(new RegExp(entity, 'g'), this.entities[entity]);
|
1167
|
-
}
|
1168
|
-
return xhtml;
|
1169
|
-
};
|
1170
|
-
|
1171
|
-
WYMeditor.XhtmlSaxListener.prototype.joinRepeatedEntities = function(xhtml)
|
1172
|
-
{
|
1173
|
-
var tags = 'em|strong|sub|sup|acronym|pre|del|address';
|
1174
|
-
return xhtml.replace(new RegExp('<\/('+tags+')><\\1>' ,''),'').
|
1175
|
-
replace(new RegExp('(\s*<('+tags+')>\s*){2}(.*)(\s*<\/\\2>\s*){2}' ,''),'<\$2>\$3<\$2>');
|
1176
|
-
};
|
1177
|
-
|
1178
|
-
WYMeditor.XhtmlSaxListener.prototype.removeEmptyTags = function(xhtml)
|
1179
|
-
{
|
1180
|
-
return xhtml.replace(new RegExp('<('+this.block_tags.join("|").replace(/\|td/,'').replace(/\|th/, '')+')>(<br \/>| | |\\s)*<\/\\1>' ,'g'),'');
|
1181
|
-
};
|
1182
|
-
|
1183
|
-
WYMeditor.XhtmlSaxListener.prototype.removeBrInPre = function(xhtml)
|
1184
|
-
{
|
1185
|
-
var matches = xhtml.match(new RegExp('<pre[^>]*>(.*?)<\/pre>','gmi'));
|
1186
|
-
if(matches) {
|
1187
|
-
for(var i=0; i<matches.length; i++) {
|
1188
|
-
xhtml = xhtml.replace(matches[i], matches[i].replace(new RegExp('<br \/>', 'g'), String.fromCharCode(13,10)));
|
1189
|
-
}
|
1190
|
-
}
|
1191
|
-
return xhtml;
|
1192
|
-
};
|
1193
|
-
|
1194
|
-
WYMeditor.XhtmlSaxListener.prototype.getResult = function()
|
1195
|
-
{
|
1196
|
-
return this.output;
|
1197
|
-
};
|
1198
|
-
|
1199
|
-
WYMeditor.XhtmlSaxListener.prototype.getTagReplacements = function()
|
1200
|
-
{
|
1201
|
-
return {'b':'strong', 'i':'em'};
|
1202
|
-
};
|
1203
|
-
|
1204
|
-
WYMeditor.XhtmlSaxListener.prototype.addContent = function(text)
|
1205
|
-
{
|
1206
|
-
this.output += text;
|
1207
|
-
};
|
1208
|
-
|
1209
|
-
WYMeditor.XhtmlSaxListener.prototype.addComment = function(text)
|
1210
|
-
{
|
1211
|
-
if(this.remove_comments){
|
1212
|
-
this.output += text;
|
1213
|
-
}
|
1214
|
-
};
|
1215
|
-
|
1216
|
-
WYMeditor.XhtmlSaxListener.prototype.addScript = function(text)
|
1217
|
-
{
|
1218
|
-
if(!this.remove_scripts){
|
1219
|
-
this.output += text;
|
1220
|
-
}
|
1221
|
-
};
|
1222
|
-
|
1223
|
-
WYMeditor.XhtmlSaxListener.prototype.addCss = function(text)
|
1224
|
-
{
|
1225
|
-
if(!this.remove_embeded_styles){
|
1226
|
-
this.output += text;
|
1227
|
-
}
|
1228
|
-
};
|
1229
|
-
|
1230
|
-
WYMeditor.XhtmlSaxListener.prototype.openBlockTag = function(tag, attributes)
|
1231
|
-
{
|
1232
|
-
this.output += this.helper.tag(tag, this.validator.getValidTagAttributes(tag, attributes), true);
|
1233
|
-
};
|
1234
|
-
|
1235
|
-
WYMeditor.XhtmlSaxListener.prototype.inlineTag = function(tag, attributes)
|
1236
|
-
{
|
1237
|
-
this.output += this.helper.tag(tag, this.validator.getValidTagAttributes(tag, attributes));
|
1238
|
-
};
|
1239
|
-
|
1240
|
-
WYMeditor.XhtmlSaxListener.prototype.openUnknownTag = function(tag, attributes)
|
1241
|
-
{
|
1242
|
-
if(tag === 'area') {
|
1243
|
-
this.output += this.helper.tag(tag, attributes, true);
|
1244
|
-
}
|
1245
|
-
};
|
1246
|
-
|
1247
|
-
WYMeditor.XhtmlSaxListener.prototype.closeBlockTag = function(tag)
|
1248
|
-
{
|
1249
|
-
this.output = this.output.replace(/<br \/>$/, '')+this._getClosingTagContent('before', tag)+"</"+tag+">"+this._getClosingTagContent('after', tag);
|
1250
|
-
};
|
1251
|
-
|
1252
|
-
WYMeditor.XhtmlSaxListener.prototype.closeUnknownTag = function(tag)
|
1253
|
-
{
|
1254
|
-
//this.output += "</"+tag+">";
|
1255
|
-
};
|
1256
|
-
|
1257
|
-
WYMeditor.XhtmlSaxListener.prototype.closeUnopenedTag = function(tag)
|
1258
|
-
{
|
1259
|
-
this.output += "</"+tag+">";
|
1260
|
-
};
|
1261
|
-
|
1262
|
-
WYMeditor.XhtmlSaxListener.prototype.avoidStylingTagsAndAttributes = function()
|
1263
|
-
{
|
1264
|
-
this.avoided_tags = ['div','span'];
|
1265
|
-
this.validator.skipped_attributes = ['style'];
|
1266
|
-
this.validator.skipped_attribute_values = ['MsoNormal','main1']; // MS Word attributes for class
|
1267
|
-
this._avoiding_tags_implicitly = true;
|
1268
|
-
};
|
1269
|
-
|
1270
|
-
WYMeditor.XhtmlSaxListener.prototype.allowStylingTagsAndAttributes = function()
|
1271
|
-
{
|
1272
|
-
this.avoided_tags = [];
|
1273
|
-
this.validator.skipped_attributes = [];
|
1274
|
-
this.validator.skipped_attribute_values = [];
|
1275
|
-
this._avoiding_tags_implicitly = false;
|
1276
|
-
};
|
1277
|
-
|
1278
|
-
WYMeditor.XhtmlSaxListener.prototype.isBlockTag = function(tag)
|
1279
|
-
{
|
1280
|
-
return !WYMeditor.Helper.contains(this.avoided_tags, tag) && WYMeditor.Helper.contains(this.block_tags, tag);
|
1281
|
-
};
|
1282
|
-
|
1283
|
-
WYMeditor.XhtmlSaxListener.prototype.isInlineTag = function(tag)
|
1284
|
-
{
|
1285
|
-
return !WYMeditor.Helper.contains(this.avoided_tags, tag) && WYMeditor.Helper.contains(this.inline_tags, tag);
|
1286
|
-
};
|
1287
|
-
|
1288
|
-
WYMeditor.XhtmlSaxListener.prototype.insertContentAfterClosingTag = function(tag, content)
|
1289
|
-
{
|
1290
|
-
this._insertContentWhenClosingTag('after', tag, content);
|
1291
|
-
};
|
1292
|
-
|
1293
|
-
WYMeditor.XhtmlSaxListener.prototype.insertContentBeforeClosingTag = function(tag, content)
|
1294
|
-
{
|
1295
|
-
this._insertContentWhenClosingTag('before', tag, content);
|
1296
|
-
};
|
1297
|
-
|
1298
|
-
WYMeditor.XhtmlSaxListener.prototype.fixNestingBeforeOpeningBlockTag = function(tag, attributes)
|
1299
|
-
{
|
1300
|
-
if(tag != 'li' && (tag == 'ul' || tag == 'ol') && this.last_tag && !this.last_tag_opened && this.last_tag == 'li'){
|
1301
|
-
this.output = this.output.replace(/<\/li>$/, '');
|
1302
|
-
this.insertContentAfterClosingTag(tag, '</li>');
|
1303
|
-
}
|
1304
|
-
};
|
1305
|
-
|
1306
|
-
WYMeditor.XhtmlSaxListener.prototype._insertContentWhenClosingTag = function(position, tag, content)
|
1307
|
-
{
|
1308
|
-
if(!this['_insert_'+position+'_closing']){
|
1309
|
-
this['_insert_'+position+'_closing'] = [];
|
1310
|
-
}
|
1311
|
-
if(!this['_insert_'+position+'_closing'][tag]){
|
1312
|
-
this['_insert_'+position+'_closing'][tag] = [];
|
1313
|
-
}
|
1314
|
-
this['_insert_'+position+'_closing'][tag].push(content);
|
1315
|
-
};
|
1316
|
-
|
1317
|
-
WYMeditor.XhtmlSaxListener.prototype._getClosingTagContent = function(position, tag)
|
1318
|
-
{
|
1319
|
-
if( this['_insert_'+position+'_closing'] &&
|
1320
|
-
this['_insert_'+position+'_closing'][tag] &&
|
1321
|
-
this['_insert_'+position+'_closing'][tag].length > 0){
|
1322
|
-
return this['_insert_'+position+'_closing'][tag].pop();
|
1323
|
-
}
|
1324
|
-
return '';
|
1325
|
-
};
|
1326
|
-
|
1327
|
-
|
1328
|
-
/********** CSS PARSER **********/
|
1329
|
-
|
1330
|
-
|
1331
|
-
WYMeditor.WymCssLexer = function(parser, only_wym_blocks)
|
1332
|
-
{
|
1333
|
-
var only_wym_blocks = (typeof only_wym_blocks == 'undefined' ? true : only_wym_blocks);
|
1334
|
-
|
1335
|
-
$.extend(this, new WYMeditor.Lexer(parser, (only_wym_blocks?'Ignore':'WymCss')));
|
1336
|
-
|
1337
|
-
this.mapHandler('WymCss', 'Ignore');
|
1338
|
-
|
1339
|
-
if(only_wym_blocks == true){
|
1340
|
-
this.addEntryPattern("/\\\x2a[<\\s]*WYMeditor[>\\s]*\\\x2a/", 'Ignore', 'WymCss');
|
1341
|
-
this.addExitPattern("/\\\x2a[<\/\\s]*WYMeditor[>\\s]*\\\x2a/", 'WymCss');
|
1342
|
-
}
|
1343
|
-
|
1344
|
-
this.addSpecialPattern("[\\sa-z1-6]*\\\x2e[a-z-_0-9]+", 'WymCss', 'WymCssStyleDeclaration');
|
1345
|
-
|
1346
|
-
this.addEntryPattern("/\\\x2a", 'WymCss', 'WymCssComment');
|
1347
|
-
this.addExitPattern("\\\x2a/", 'WymCssComment');
|
1348
|
-
|
1349
|
-
this.addEntryPattern("\x7b", 'WymCss', 'WymCssStyle');
|
1350
|
-
this.addExitPattern("\x7d", 'WymCssStyle');
|
1351
|
-
|
1352
|
-
this.addEntryPattern("/\\\x2a", 'WymCssStyle', 'WymCssFeedbackStyle');
|
1353
|
-
this.addExitPattern("\\\x2a/", 'WymCssFeedbackStyle');
|
1354
|
-
|
1355
|
-
return this;
|
1356
|
-
};
|
1357
|
-
|
1358
|
-
WYMeditor.WymCssParser = function()
|
1359
|
-
{
|
1360
|
-
this._in_style = false;
|
1361
|
-
this._has_title = false;
|
1362
|
-
this.only_wym_blocks = true;
|
1363
|
-
this.css_settings = {'classesItems':[], 'editorStyles':[], 'dialogStyles':[]};
|
1364
|
-
return this;
|
1365
|
-
};
|
1366
|
-
|
1367
|
-
WYMeditor.WymCssParser.prototype.parse = function(raw, only_wym_blocks)
|
1368
|
-
{
|
1369
|
-
var only_wym_blocks = (typeof only_wym_blocks == 'undefined' ? this.only_wym_blocks : only_wym_blocks);
|
1370
|
-
this._Lexer = new WYMeditor.WymCssLexer(this, only_wym_blocks);
|
1371
|
-
this._Lexer.parse(raw);
|
1372
|
-
};
|
1373
|
-
|
1374
|
-
WYMeditor.WymCssParser.prototype.Ignore = function(match, state)
|
1375
|
-
{
|
1376
|
-
return true;
|
1377
|
-
};
|
1378
|
-
|
1379
|
-
WYMeditor.WymCssParser.prototype.WymCssComment = function(text, status)
|
1380
|
-
{
|
1381
|
-
if(text.match(/end[a-z0-9\s]*wym[a-z0-9\s]*/mi)){
|
1382
|
-
return false;
|
1383
|
-
}
|
1384
|
-
if(status == WYMeditor.LEXER_UNMATCHED){
|
1385
|
-
if(!this._in_style){
|
1386
|
-
this._has_title = true;
|
1387
|
-
this._current_item = {'title':WYMeditor.Helper.trim(text)};
|
1388
|
-
}else{
|
1389
|
-
if(this._current_item[this._current_element]){
|
1390
|
-
if(!this._current_item[this._current_element].expressions){
|
1391
|
-
this._current_item[this._current_element].expressions = [text];
|
1392
|
-
}else{
|
1393
|
-
this._current_item[this._current_element].expressions.push(text);
|
1394
|
-
}
|
1395
|
-
}
|
1396
|
-
}
|
1397
|
-
this._in_style = true;
|
1398
|
-
}
|
1399
|
-
return true;
|
1400
|
-
};
|
1401
|
-
|
1402
|
-
WYMeditor.WymCssParser.prototype.WymCssStyle = function(match, status)
|
1403
|
-
{
|
1404
|
-
if(status == WYMeditor.LEXER_UNMATCHED){
|
1405
|
-
match = WYMeditor.Helper.trim(match);
|
1406
|
-
if(match != ''){
|
1407
|
-
this._current_item[this._current_element].style = match;
|
1408
|
-
}
|
1409
|
-
}else if (status == WYMeditor.LEXER_EXIT){
|
1410
|
-
this._in_style = false;
|
1411
|
-
this._has_title = false;
|
1412
|
-
this.addStyleSetting(this._current_item);
|
1413
|
-
}
|
1414
|
-
return true;
|
1415
|
-
};
|
1416
|
-
|
1417
|
-
WYMeditor.WymCssParser.prototype.WymCssFeedbackStyle = function(match, status)
|
1418
|
-
{
|
1419
|
-
if(status == WYMeditor.LEXER_UNMATCHED){
|
1420
|
-
this._current_item[this._current_element].feedback_style = match.replace(/^([\s\/\*]*)|([\s\/\*]*)$/gm,'');
|
1421
|
-
}
|
1422
|
-
return true;
|
1423
|
-
};
|
1424
|
-
|
1425
|
-
WYMeditor.WymCssParser.prototype.WymCssStyleDeclaration = function(match)
|
1426
|
-
{
|
1427
|
-
match = match.replace(/^([\s\.]*)|([\s\.*]*)$/gm, '');
|
1428
|
-
|
1429
|
-
var tag = '';
|
1430
|
-
if(match.indexOf('.') > 0){
|
1431
|
-
var parts = match.split('.');
|
1432
|
-
this._current_element = parts[1];
|
1433
|
-
var tag = parts[0];
|
1434
|
-
}else{
|
1435
|
-
this._current_element = match;
|
1436
|
-
}
|
1437
|
-
|
1438
|
-
if(!this._has_title){
|
1439
|
-
this._current_item = {'title':(!tag?'':tag.toUpperCase()+': ')+this._current_element};
|
1440
|
-
this._has_title = true;
|
1441
|
-
}
|
1442
|
-
|
1443
|
-
if(!this._current_item[this._current_element]){
|
1444
|
-
this._current_item[this._current_element] = {'name':this._current_element};
|
1445
|
-
}
|
1446
|
-
if(tag){
|
1447
|
-
if(!this._current_item[this._current_element].tags){
|
1448
|
-
this._current_item[this._current_element].tags = [tag];
|
1449
|
-
}else{
|
1450
|
-
this._current_item[this._current_element].tags.push(tag);
|
1451
|
-
}
|
1452
|
-
}
|
1453
|
-
return true;
|
1454
|
-
};
|
1455
|
-
|
1456
|
-
WYMeditor.WymCssParser.prototype.addStyleSetting = function(style_details)
|
1457
|
-
{
|
1458
|
-
for (var name in style_details){
|
1459
|
-
var details = style_details[name];
|
1460
|
-
if(typeof details == 'object' && name != 'title'){
|
1461
|
-
|
1462
|
-
this.css_settings.classesItems.push({
|
1463
|
-
'name': WYMeditor.Helper.trim(details.name),
|
1464
|
-
'title': style_details.title,
|
1465
|
-
'expr' : WYMeditor.Helper.trim((details.expressions||details.tags).join(', '))
|
1466
|
-
});
|
1467
|
-
if(details.feedback_style){
|
1468
|
-
this.css_settings.editorStyles.push({
|
1469
|
-
'name': '.'+ WYMeditor.Helper.trim(details.name),
|
1470
|
-
'css': details.feedback_style
|
1471
|
-
});
|
1472
|
-
}
|
1473
|
-
if(details.style){
|
1474
|
-
this.css_settings.dialogStyles.push({
|
1475
|
-
'name': '.'+ WYMeditor.Helper.trim(details.name),
|
1476
|
-
'css': details.style
|
1477
|
-
});
|
1478
|
-
}
|
1479
|
-
}
|
1480
|
-
}
|
1481
|
-
};
|
1482
|
-
|
1483
|
-
/********** HELPERS **********/
|
1484
|
-
|
1485
|
-
// Returns true if it is a text node with whitespaces only
|
1486
|
-
$.fn.isPhantomNode = function() {
|
1487
|
-
if (this[0].nodeType == 3)
|
1488
|
-
return !(/[^\t\n\r ]/.test(this[0].data));
|
1489
|
-
|
1490
|
-
return false;
|
1491
|
-
};
|
1492
|
-
|
1493
|
-
WYMeditor.isPhantomNode = function(n) {
|
1494
|
-
if (n.nodeType == 3)
|
1495
|
-
return !(/[^\t\n\r ]/.test(n.data));
|
1496
|
-
|
1497
|
-
return false;
|
1498
|
-
};
|
1499
|
-
|
1500
|
-
WYMeditor.isPhantomString = function(str) {
|
1501
|
-
return !(/[^\t\n\r ]/.test(str));
|
1502
|
-
};
|
1503
|
-
|
1504
|
-
// Returns the Parents or the node itself
|
1505
|
-
// jqexpr = a jQuery expression
|
1506
|
-
$.fn.parentsOrSelf = function(jqexpr) {
|
1507
|
-
var n = this;
|
1508
|
-
|
1509
|
-
if (n[0].nodeType == 3)
|
1510
|
-
n = n.parents().slice(0,1);
|
1511
|
-
|
1512
|
-
// if (n.is(jqexpr)) // XXX should work, but doesn't (probably a jQuery bug)
|
1513
|
-
if (n.filter(jqexpr).size() == 1)
|
1514
|
-
return n;
|
1515
|
-
else
|
1516
|
-
return n.parents(jqexpr).slice(0,1);
|
1517
|
-
};
|
1518
|
-
|
1519
|
-
// String & array helpers
|
1520
|
-
|
1521
|
-
WYMeditor.Helper = {
|
1522
|
-
|
1523
|
-
//replace all instances of 'old' by 'rep' in 'str' string
|
1524
|
-
replaceAll: function(str, old, rep) {
|
1525
|
-
return(str.replace(new RegExp(old, "g"), rep));
|
1526
|
-
},
|
1527
|
-
|
1528
|
-
//insert 'inserted' at position 'pos' in 'str' string
|
1529
|
-
insertAt: function(str, inserted, pos) {
|
1530
|
-
return(str.substr(0,pos) + inserted + str.substring(pos));
|
1531
|
-
},
|
1532
|
-
|
1533
|
-
//trim 'str' string
|
1534
|
-
trim: function(str) {
|
1535
|
-
return str.replace(/^(\s*)|(\s*)$/gm,'');
|
1536
|
-
},
|
1537
|
-
|
1538
|
-
//return true if 'arr' array contains 'elem', or false
|
1539
|
-
contains: function(arr, elem) {
|
1540
|
-
for (var i = 0; i < arr.length; i++) {
|
1541
|
-
if (arr[i] === elem) return true;
|
1542
|
-
}
|
1543
|
-
return false;
|
1544
|
-
},
|
1545
|
-
|
1546
|
-
//return 'item' position in 'arr' array, or -1
|
1547
|
-
indexOf: function(arr, item) {
|
1548
|
-
var ret=-1;
|
1549
|
-
for(var i = 0; i < arr.length; i++) {
|
1550
|
-
if (arr[i] == item) {
|
1551
|
-
ret = i;
|
1552
|
-
break;
|
1553
|
-
}
|
1554
|
-
}
|
1555
|
-
return ret;
|
1556
|
-
},
|
1557
|
-
|
1558
|
-
//return 'item' object in 'arr' array, checking its 'name' property, or null
|
1559
|
-
findByName: function(arr, name) {
|
1560
|
-
for(var i = 0; i < arr.length; i++) {
|
1561
|
-
var item = arr[i];
|
1562
|
-
if(item.name == name) return(item);
|
1563
|
-
}
|
1564
|
-
return null;
|
1565
|
-
}
|
1566
|
-
};
|
1567
|
-
|
1568
|
-
function titleize(words) {
|
1569
|
-
if (words == null) return words;
|
1570
|
-
parts = [];
|
1571
|
-
$.each(words.replace(/\./, '').replace(/[-_]/, ' ').split(' '), function(index, part){
|
1572
|
-
parts.push(part.substring(0,1).toUpperCase() + part.substring(1));
|
1573
|
-
});
|
1574
|
-
return parts.join(" ");
|
1575
|
-
}
|