kiteditor 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/POST_INSTALL +21 -0
- data/{vendor → app}/assets/images/mercury/button.png +0 -0
- data/{vendor → app}/assets/images/mercury/close.png +0 -0
- data/app/assets/images/mercury/default-snippet.png +0 -0
- data/{vendor → app}/assets/images/mercury/loading-dark.gif +0 -0
- data/{vendor → app}/assets/images/mercury/loading-light.gif +0 -0
- data/{vendor → app}/assets/images/mercury/missing-image.png +0 -0
- data/{vendor → app}/assets/images/mercury/search-icon.png +0 -0
- data/{vendor → app}/assets/images/mercury/temp-logo.png +0 -0
- data/app/assets/images/mercury/toolbar/editable/buttons.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_expander.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/_pressed.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/action.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/historypanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertcharacter.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertlink.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/insertmedia.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inserttable.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/inspectorpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/notespanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/preview.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/redo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/save.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/snippetpanel.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/tools.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/undo.png +0 -0
- data/app/assets/images/mercury/toolbar/primary/user.png +0 -0
- data/app/assets/images/mercury/toolbar/snippets/buttons.png +0 -0
- data/{vendor/assets/javascripts/mercury/dependencies → app/assets/javascripts}/jquery-1.7.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury.js +60 -87
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery-ui-1.8.13.custom.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.additions.js +103 -13
- data/{vendor → app}/assets/javascripts/mercury/dependencies/jquery.htmlClean.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/liquidmetal.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dependencies/showdown.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialog.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/backcolor.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/forecolor.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/formatblock.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/dialogs/snippetpanel.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/dialogs/style.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/finalize.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/history_buffer.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/lightview.js.coffee +38 -17
- data/app/assets/javascripts/mercury/locales/ar.locale.js.coffee +201 -0
- data/app/assets/javascripts/mercury/locales/da.locale.js.coffee +208 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/de.locale.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/es.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/example.local.js.coffee +3 -5
- data/{vendor → app}/assets/javascripts/mercury/locales/fr.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/hu.locale.js.coffee +209 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/it.locale.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/ko.local.js.coffee +4 -10
- data/{vendor → app}/assets/javascripts/mercury/locales/nl.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/pl.locale.js.coffee +213 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/pt.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/ru.locale.js.coffee +200 -0
- data/{vendor → app}/assets/javascripts/mercury/locales/sv.local.js.coffee +3 -9
- data/{vendor → app}/assets/javascripts/mercury/locales/swedish_chef.locale.js.coffee +3 -9
- data/app/assets/javascripts/mercury/locales/uk.locale.js.coffee +200 -0
- data/app/assets/javascripts/mercury/locales/zh.local.js.coffee +203 -0
- data/app/assets/javascripts/mercury/mercury-compiled.js +10720 -0
- data/{vendor → app}/assets/javascripts/mercury/mercury.js.coffee +10 -1
- data/{vendor → app}/assets/javascripts/mercury/modal.js.coffee +62 -40
- data/{vendor → app}/assets/javascripts/mercury/modals/htmleditor.js.coffee +1 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertcharacter.js.coffee +1 -0
- data/app/assets/javascripts/mercury/modals/insertlink.js.coffee +152 -0
- data/app/assets/javascripts/mercury/modals/insertmedia.js.coffee +132 -0
- data/{vendor → app}/assets/javascripts/mercury/modals/insertsnippet.js.coffee +2 -0
- data/app/assets/javascripts/mercury/modals/inserttable.js.coffee +68 -0
- data/{vendor → app}/assets/javascripts/mercury/native_extensions.js.coffee +0 -6
- data/{vendor → app}/assets/javascripts/mercury/page_editor.js.coffee +84 -50
- data/{vendor → app}/assets/javascripts/mercury/palette.js.coffee +1 -1
- data/{vendor → app}/assets/javascripts/mercury/panel.js.coffee +3 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/mercury/page_editor.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/plugins/save_as_xml/plugin.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/region.js.coffee +18 -17
- data/{vendor/assets/javascripts/mercury/regions/editable.js.coffee → app/assets/javascripts/mercury/regions/full.js.coffee} +41 -31
- data/app/assets/javascripts/mercury/regions/image.js.coffee +93 -0
- data/{vendor/assets/javascripts/mercury/regions/markupable.js.coffee → app/assets/javascripts/mercury/regions/markdown.js.coffee} +29 -24
- data/{vendor → app}/assets/javascripts/mercury/regions/simple.js.coffee +11 -54
- data/{vendor/assets/javascripts/mercury/regions/snippetable.js.coffee → app/assets/javascripts/mercury/regions/snippets.js.coffee} +10 -9
- data/{vendor → app}/assets/javascripts/mercury/select.js.coffee +1 -1
- data/app/assets/javascripts/mercury/snippet.js.coffee +136 -0
- data/{vendor → app}/assets/javascripts/mercury/snippet_toolbar.js.coffee +19 -6
- data/{vendor → app}/assets/javascripts/mercury/statusbar.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/support/history.js +0 -0
- data/{vendor → app}/assets/javascripts/mercury/table_editor.js.coffee +16 -0
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button.js.coffee +45 -30
- data/{vendor → app}/assets/javascripts/mercury/toolbar.button_group.js.coffee +2 -2
- data/{vendor → app}/assets/javascripts/mercury/toolbar.expander.js.coffee +4 -4
- data/{vendor → app}/assets/javascripts/mercury/toolbar.js.coffee +10 -6
- data/{vendor → app}/assets/javascripts/mercury/tooltip.js.coffee +0 -0
- data/{vendor → app}/assets/javascripts/mercury/uploader.js.coffee +37 -19
- data/app/assets/stylesheets/_mercury-bootstrap-overrides.scss +61 -0
- data/app/assets/stylesheets/_mercury-sass.scss +33 -0
- data/{vendor → app}/assets/stylesheets/mercury.css +1 -5
- data/{vendor → app}/assets/stylesheets/mercury/all_images.css.erb +6 -2
- data/app/assets/stylesheets/mercury/bootstrap-ish.css +1367 -0
- data/app/assets/stylesheets/mercury/bootstrap-overrides.css +61 -0
- data/{vendor → app}/assets/stylesheets/mercury/dialog.css +21 -8
- data/{vendor → app}/assets/stylesheets/mercury/lightview.css +6 -56
- data/app/assets/stylesheets/mercury/mercury.css +43 -0
- data/{vendor → app}/assets/stylesheets/mercury/modal.css +15 -32
- data/{vendor → app}/assets/stylesheets/mercury/statusbar.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/toolbar.css +4 -1
- data/{vendor → app}/assets/stylesheets/mercury/tooltip.css +0 -0
- data/{vendor → app}/assets/stylesheets/mercury/uploader.css +4 -4
- data/app/helpers/mercury_helper.rb +7 -0
- data/app/views/layouts/mercury.html.erb +10 -20
- data/app/views/layouts/mercury.html.haml +19 -0
- data/app/views/layouts/mercury.html.slim +19 -0
- data/app/views/mercury/modals/character.html +1 -1
- data/app/views/mercury/modals/htmleditor.html +3 -7
- data/app/views/mercury/modals/link.html +37 -51
- data/app/views/mercury/modals/media.html +102 -0
- data/app/views/mercury/modals/table.html +79 -73
- data/app/views/mercury/panels/snippets.html +6 -1
- data/app/views/mercury/snippets/example/options.html.erb +23 -27
- data/app/views/mercury/snippets/no_options/preview.html.erb +1 -0
- data/config/routes.rb +9 -0
- data/features/generators/authentication.feature +10 -0
- data/features/generators/images.feature +41 -0
- data/features/generators/install.feature +21 -0
- data/features/loading/loading.feature +5 -2
- data/features/loading/user_interface.feature +9 -7
- data/features/regions/{editable → full}/advanced_editing.feature +0 -0
- data/features/regions/full/basic_editing.feature +198 -0
- data/features/regions/{editable → full}/inserting_links.feature +20 -19
- data/features/regions/{editable → full}/inserting_media.feature +36 -18
- data/features/regions/{editable → full}/inserting_snippets.feature +28 -18
- data/features/regions/{editable → full}/inserting_special_characters.feature +2 -2
- data/features/regions/full/inserting_tables.feature +109 -0
- data/features/regions/{editable → full}/pasting.feature +0 -0
- data/features/regions/{editable → full}/uploading_images.feature +0 -0
- data/features/regions/{markupable → image}/uploading_images.feature +0 -0
- data/features/regions/{markupable → markdown}/advanced_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/basic_editing.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_links.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_media.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_snippets.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_special_characters.feature +0 -0
- data/features/regions/{markupable → markdown}/inserting_tables.feature +0 -0
- data/features/regions/{snippetable/advanced_editing.feature → markdown/uploading_images.feature} +0 -0
- data/features/regions/simple/basic_editing.feature +5 -0
- data/features/regions/{snippetable/basic_editing.feature → snippets/advanced_editing.feature} +0 -0
- data/features/regions/{snippetable/inserting_snippets.feature → snippets/basic_editing.feature} +0 -0
- data/{vendor/assets/javascripts/mercury/locales/da.locale.js.coffee → features/regions/snippets/inserting_snippets.feature} +0 -0
- data/features/saving/saving.feature +8 -8
- data/features/step_definitions/custom_web_steps.rb +22 -0
- data/features/step_definitions/generator_steps.rb +23 -0
- data/features/step_definitions/mercury_steps.rb +1 -438
- data/features/support/aruba.rb +28 -0
- data/features/support/env.rb +11 -1
- data/features/support/selectors.rb +23 -0
- data/lib/generators/mercury/install/authentication/authentication_generator.rb +17 -0
- data/lib/generators/mercury/install/images/images_generator.rb +47 -0
- data/{app/models/mercury/image.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image.rb} +7 -0
- data/{db/migrate/20110526035601_create_mercury_images.rb → lib/generators/mercury/install/images/templates/ar_paperclip_image_migration.rb} +0 -0
- data/{app/controllers/mercury → lib/generators/mercury/install/images/templates}/images_controller.rb +0 -0
- data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb +0 -0
- data/lib/generators/mercury/install/install_generator.rb +12 -23
- data/lib/mercury-rails.rb +1 -2
- data/lib/mercury/authentication.rb +1 -0
- data/lib/mercury/cucumber/step_definitions.rb +13 -0
- data/lib/mercury/cucumber/step_definitions/mercury_steps.rb +408 -0
- data/{features → lib/mercury/cucumber}/support/mercury_contents.rb +3 -3
- data/{features → lib/mercury/cucumber}/support/mercury_selectors.rb +0 -20
- data/lib/mercury/engine.rb +19 -0
- data/lib/mercury/rails.rb +5 -0
- data/lib/mercury/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -0
- data/spec/dummy/app/assets/javascripts/prototype.js +6082 -0
- data/spec/dummy/app/assets/stylesheets/application.css.scss +110 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/mercury.html.erb +28 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +58 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/teabag.rb +9 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/blank.html +1 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/images/bunny.gif +0 -0
- data/spec/dummy/public/images/bunny2.jpg +0 -0
- data/spec/dummy/public/index.html +279 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialog.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/backcolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/forecolor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/formatblock.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/snippetpanel.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/dialogs/style.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/lightview.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modal.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/htmleditor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertcharacter.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/insertlink.html +67 -0
- data/spec/javascripts/fixtures/mercury/modals/insertmedia.html +87 -0
- data/spec/javascripts/{templates → fixtures}/mercury/modals/insertsnippet.html +0 -0
- data/spec/javascripts/fixtures/mercury/modals/inserttable.html +73 -0
- data/spec/javascripts/{templates → fixtures}/mercury/page_editor.html +4 -4
- data/spec/javascripts/{templates → fixtures}/mercury/palette.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/panel.html +0 -0
- data/spec/javascripts/fixtures/mercury/region.html +6 -0
- data/spec/javascripts/fixtures/mercury/regions/full.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/image.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/markdown.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/simple.html +1 -0
- data/spec/javascripts/fixtures/mercury/regions/snippets.html +4 -0
- data/spec/javascripts/{templates → fixtures}/mercury/select.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/snippet_toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/statusbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/table_editor.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.button_group.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.expander.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/toolbar.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/tooltip.html +0 -0
- data/spec/javascripts/{templates → fixtures}/mercury/uploader.html +0 -0
- data/spec/javascripts/mercury/{dialog_spec.js.coffee → dialog_spec.coffee} +11 -12
- data/spec/javascripts/mercury/dialogs/backcolor_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/forecolor_spec.js.coffee +3 -4
- data/spec/javascripts/mercury/dialogs/formatblock_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/snippetpanel_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/dialogs/style_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/lightview_spec.js.coffee +180 -142
- data/spec/javascripts/mercury/mercury_spec.js.coffee +19 -13
- data/spec/javascripts/mercury/modal_spec.js.coffee +192 -148
- data/spec/javascripts/mercury/modals/htmleditor_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/modals/insertcharacter_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/insertlink_spec.js.coffee +107 -34
- data/spec/javascripts/mercury/modals/insertmedia_spec.js.coffee +106 -26
- data/spec/javascripts/mercury/modals/insertsnippet_spec.js.coffee +2 -3
- data/spec/javascripts/mercury/modals/inserttable_spec.js.coffee +50 -40
- data/spec/javascripts/mercury/page_editor_spec.js.coffee +124 -80
- data/spec/javascripts/mercury/palette_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/panel_spec.js.coffee +9 -12
- data/spec/javascripts/mercury/region_spec.js.coffee +22 -17
- data/spec/javascripts/mercury/regions/{editable_spec.js.coffee → full_spec.js.coffee} +26 -28
- data/spec/javascripts/mercury/regions/image_spec.js.coffee +33 -0
- data/spec/javascripts/mercury/regions/{markupable_spec.js.coffee → markdown_spec.js.coffee} +32 -34
- data/spec/javascripts/mercury/regions/simple_spec.js.coffee +32 -0
- data/spec/javascripts/mercury/regions/{snippetable_spec.js.coffee → snippets_spec.js.coffee} +54 -55
- data/spec/javascripts/mercury/select_spec.js.coffee +4 -5
- data/spec/javascripts/mercury/snippet_spec.js.coffee +92 -16
- data/spec/javascripts/mercury/snippet_toolbar_spec.js.coffee +31 -16
- data/spec/javascripts/mercury/statusbar_spec.js.coffee +9 -10
- data/spec/javascripts/mercury/table_editor_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/toolbar.button_group_spec.js.coffee +7 -9
- data/spec/javascripts/mercury/toolbar.button_spec.js.coffee +55 -26
- data/spec/javascripts/mercury/toolbar.expander_spec.js.coffee +13 -13
- data/spec/javascripts/mercury/toolbar_spec.js.coffee +43 -14
- data/spec/javascripts/mercury/tooltip_spec.js.coffee +1 -2
- data/spec/javascripts/mercury/uploader_spec.js.coffee +47 -33
- data/spec/javascripts/spec_helper.coffee +4 -0
- data/spec/javascripts/{spec_helper.js → support/event_simulation.js} +0 -2
- data/spec/teabag_env.rb +32 -0
- metadata +366 -196
- data/features/regions/editable/basic_editing.feature +0 -195
- data/features/regions/editable/inserting_tables.feature +0 -109
- data/spec/javascripts/templates/mercury/modals/insertlink.html +0 -30
- data/spec/javascripts/templates/mercury/modals/insertmedia.html +0 -35
- data/spec/javascripts/templates/mercury/modals/inserttable.html +0 -27
- data/spec/javascripts/templates/mercury/region.html +0 -2
- data/spec/javascripts/templates/mercury/regions/editable.html +0 -3
- data/spec/javascripts/templates/mercury/regions/snippetable.html +0 -4
- data/vendor/assets/javascripts/mercury/modals/inserttable.js.coffee +0 -54
- data/vendor/assets/javascripts/mercury_loader.js +0 -193
- data/vendor/assets/javascripts/mercury_overrides.js +0 -6
- data/vendor/assets/stylesheets/mercury/mercury.css +0 -151
- data/vendor/assets/stylesheets/mercury_overrides.css +0 -17
@@ -0,0 +1,28 @@
|
|
1
|
+
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
|
2
|
+
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]
|
3
|
+
|
4
|
+
Before do
|
5
|
+
if ! ENV['BUNDLE_GEMFILE'].include?(Dir.pwd)
|
6
|
+
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE'])
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
After do
|
11
|
+
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
|
12
|
+
ENV[key] = value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
When /^I reset Bundler environment variable$/ do
|
17
|
+
BUNDLE_ENV_VARS.each do |key|
|
18
|
+
ENV[key] = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Before do
|
23
|
+
@aruba_timeout_seconds = 20
|
24
|
+
end
|
25
|
+
|
26
|
+
Before('@slow') do
|
27
|
+
@aruba_timeout_seconds = 180
|
28
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -4,14 +4,16 @@
|
|
4
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
7
|
+
ENV["RAILS_ROOT"] = File.expand_path('../../../spec/dummy', __FILE__)
|
7
8
|
require 'cucumber/rails'
|
8
9
|
require 'capybara/firebug'
|
10
|
+
require 'aruba/cucumber'
|
9
11
|
|
10
12
|
# You can enable firebug in your tests by tagging them @firebug.
|
11
13
|
# To change the version of firebug use the FIREBUG_VERSION environment variable.
|
12
14
|
# For firefox 4+ use 1.7.0
|
13
15
|
# For firefox 3 use 1.6.2
|
14
|
-
Selenium::WebDriver::Firefox::Profile.firebug_version = ENV['FIREBUG_VERSION'] || '1.8.3'
|
16
|
+
# Selenium::WebDriver::Firefox::Profile.firebug_version = ENV['FIREBUG_VERSION'] || '1.8.3'
|
15
17
|
|
16
18
|
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
17
19
|
# order to ease the transition to Capybara we set the default here. If you'd
|
@@ -44,3 +46,11 @@ begin
|
|
44
46
|
rescue NameError
|
45
47
|
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
|
46
48
|
end
|
49
|
+
|
50
|
+
Before('@use_hidden_elements') do
|
51
|
+
Capybara.ignore_hidden_elements = false
|
52
|
+
end
|
53
|
+
|
54
|
+
After('@use_hidden_elements') do
|
55
|
+
Capybara.ignore_hidden_elements = true
|
56
|
+
end
|
@@ -39,6 +39,29 @@ module HtmlSelectorsHelpers
|
|
39
39
|
"Now, go and add a mapping in #{__FILE__}"
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
def region_selector_for(locator)
|
44
|
+
return '#full_1' if locator.blank? || locator == 'the region'
|
45
|
+
case locator.downcase
|
46
|
+
|
47
|
+
when 'the first full region', 'the full region' then '#full_1'
|
48
|
+
when 'the first markdown region', 'the markdown region' then '#markdown_1'
|
49
|
+
when 'the first snippets region', 'the first snippet region', 'the snippets region', 'the snippet region' then '#snippets_1'
|
50
|
+
|
51
|
+
else locator
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def snippet_name_for(locator)
|
56
|
+
case locator.downcase
|
57
|
+
|
58
|
+
when 'the example snippet' then 'example'
|
59
|
+
when 'the snippet with no options' then 'no_options'
|
60
|
+
|
61
|
+
else locator
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
42
65
|
end
|
43
66
|
|
44
67
|
World(HtmlSelectorsHelpers)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "mercury/engine"
|
2
|
+
|
3
|
+
module Mercury
|
4
|
+
module Generators
|
5
|
+
module Install
|
6
|
+
class AuthenticationGenerator < Rails::Generators::Base
|
7
|
+
source_root Mercury::Engine.root
|
8
|
+
|
9
|
+
desc "Installs an authentication example so you can restrict access to editing."
|
10
|
+
|
11
|
+
def copy_authentication_overrides
|
12
|
+
copy_file 'lib/mercury/authentication.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
module Mercury
|
3
|
+
module Generators
|
4
|
+
module Install
|
5
|
+
class ImagesGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
|
9
|
+
desc "Installs image processing migrations and model."
|
10
|
+
|
11
|
+
class_option :orm, :default => 'active_record', :banner => 'mongoid',
|
12
|
+
:desc => 'ORM for required models -- active_record, or mongoid'
|
13
|
+
|
14
|
+
def copy_models
|
15
|
+
if options[:orm] == 'mongoid'
|
16
|
+
copy_file 'mongoid_paperclip_image.rb', 'app/models/mercury/image.rb'
|
17
|
+
else
|
18
|
+
copy_file 'ar_paperclip_image.rb', 'app/models/mercury/image.rb'
|
19
|
+
migration_template 'ar_paperclip_image_migration.rb', 'db/migrate/create_mercury_images.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_controller
|
24
|
+
copy_file 'images_controller.rb', 'app/controllers/mercury/images_controller.rb'
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_routes
|
28
|
+
route %Q{ namespace :mercury do
|
29
|
+
resources :images
|
30
|
+
end}
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_gemfile_dependencies
|
34
|
+
append_to_file "Gemfile", %Q{gem 'paperclip'}
|
35
|
+
if options[:orm] == 'mongoid'
|
36
|
+
append_to_file "Gemfile", %Q{gem 'mongoid-paperclip', :require => 'mongoid_paperclip'}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Implement the required interface for Rails::Generators::Migration.
|
41
|
+
def self.next_migration_number(dirname) #:nodoc:
|
42
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,9 +1,16 @@
|
|
1
|
+
# not used maybe???
|
2
|
+
#
|
1
3
|
class Mercury::Image < ActiveRecord::Base
|
2
4
|
|
3
5
|
|
4
6
|
#self.table_name = :mercury_images
|
5
7
|
|
6
8
|
#has_attached_file :image, :styles => { :medium => "300x300>", :large=>"600x600>", :thumb => "100x100>" }
|
9
|
+
attr_accessible :image
|
10
|
+
|
11
|
+
has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" },
|
12
|
+
:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
|
13
|
+
:url => "/system/:attachment/:id/:style/:filename"
|
7
14
|
|
8
15
|
#delegate :url, :to => :image
|
9
16
|
|
File without changes
|
File without changes
|
data/lib/generators/mercury/install/{templates → images/templates}/mongoid_paperclip_image.rb
RENAMED
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "mercury/engine"
|
2
|
+
|
1
3
|
module Mercury
|
2
4
|
module Generators
|
3
5
|
class InstallGenerator < Rails::Generators::Base
|
@@ -5,38 +7,25 @@ module Mercury
|
|
5
7
|
|
6
8
|
desc "Installs Mercury into your application by copying the configuration file."
|
7
9
|
|
8
|
-
class_option :orm, :default => 'active_record', :banner => 'mongoid',
|
9
|
-
:desc => 'ORM for required models -- active_record, or mongoid'
|
10
|
-
|
11
10
|
class_option :full, :type => :boolean, :aliases => '-g',
|
12
|
-
:desc => 'Full installation will install the layout and css
|
11
|
+
:desc => 'Full installation will install the layout and css files for easier customization.'
|
12
|
+
|
13
|
+
class_option :template_engine, :type => :string,
|
14
|
+
:desc => 'Set preferred template engine for layout instead of ERB (haml or slim)'
|
13
15
|
|
14
16
|
def copy_config
|
15
|
-
copy_file '
|
17
|
+
copy_file 'app/assets/javascripts/mercury.js'
|
16
18
|
end
|
17
19
|
|
18
20
|
def add_routes
|
19
|
-
route %Q{Mercury::Engine
|
20
|
-
end
|
21
|
-
|
22
|
-
def copy_models
|
23
|
-
if options[:orm] == 'mongoid'
|
24
|
-
copy_file 'lib/generators/mercury/install/templates/mongoid_paperclip_image.rb', 'app/models/mercury/image.rb'
|
25
|
-
else
|
26
|
-
copy_file 'app/models/mercury/image.rb' if options[:full]
|
27
|
-
end
|
21
|
+
route %Q{mount Mercury::Engine => '/'}
|
28
22
|
end
|
29
23
|
|
30
24
|
def copy_layout_and_css_overrides
|
31
|
-
if options[:full] || yes?("Install the layout and CSS
|
32
|
-
|
33
|
-
copy_file
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def copy_authentication_overrides
|
38
|
-
if options[:full] || yes?("Install the authentication file so you can restrict access to editing? [yN]")
|
39
|
-
copy_file 'lib/mercury/authentication.rb'
|
25
|
+
if options[:full] || yes?("Install the layout file and CSS? [yN]")
|
26
|
+
layout_ext = options[:template_engine] || 'erb'
|
27
|
+
copy_file "app/views/layouts/mercury.html.#{layout_ext}"
|
28
|
+
copy_file 'app/assets/stylesheets/mercury.css'
|
40
29
|
end
|
41
30
|
end
|
42
31
|
|
data/lib/mercury-rails.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'xpath'
|
2
|
+
|
3
|
+
World(ActionController::RecordIdentifier)
|
4
|
+
|
5
|
+
# require support files
|
6
|
+
Dir[File.join(File.dirname(__FILE__), 'support', '*')].each do |file|
|
7
|
+
require file
|
8
|
+
end
|
9
|
+
|
10
|
+
# require the common step defintions
|
11
|
+
Dir[File.join(File.dirname(__FILE__), 'step_definitions', '*')].each do |file|
|
12
|
+
require file
|
13
|
+
end
|
@@ -0,0 +1,408 @@
|
|
1
|
+
## Mercury general steps
|
2
|
+
#------------------------------------------------------------------------------
|
3
|
+
Given /^(?:|I )adjust the configuration to have: \{([^\}]*)\}$/ do |javascript|
|
4
|
+
Rails.application.config.mercury_config = JSON.parse("{#{javascript}}")
|
5
|
+
end
|
6
|
+
|
7
|
+
# scoping step for the mercury content frame
|
8
|
+
When /^(.*) in the content frame$/ do |s|
|
9
|
+
page.driver.within_frame('mercury_iframe') do
|
10
|
+
step(s)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# silence mercury's onbeforeunload confirmation
|
15
|
+
Given /^the editor won't prompt when leaving the page$/ do
|
16
|
+
page.driver.execute_script('Mercury.silent = true;')
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
## Toolbar specific steps
|
21
|
+
#------------------------------------------------------------------------------
|
22
|
+
# for the select dropdowns
|
23
|
+
When /^(?:|I )select (.*?) from the dropdown$/ do |locator|
|
24
|
+
selector = selector_for(locator)
|
25
|
+
find(selector, :message => "Unable to locate the element '#{selector}' to click on").click
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
## Panel specific steps
|
30
|
+
#------------------------------------------------------------------------------
|
31
|
+
When /^(?:I )(?:open|close|toggle) the (.*?) panel$/ do |panel_locator|
|
32
|
+
step(%Q{I click on the "#{panel_locator}" button})
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
## Modal specific steps
|
37
|
+
#------------------------------------------------------------------------------
|
38
|
+
When /^(?:I )close the modal(?: window)?$/ do
|
39
|
+
step(%Q{I click on the modal close button})
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
## Region specific steps
|
44
|
+
#------------------------------------------------------------------------------
|
45
|
+
# setting content
|
46
|
+
Given /^the content of (.*?) (?:is|are|has|includes) (.*?)$/ do |region_locator, contents|
|
47
|
+
step(%Q{I set the contents of #{region_locator} to #{contents}})
|
48
|
+
end
|
49
|
+
|
50
|
+
When /^(?:|I )(?:change|set) the contents? of (.*?) to (.*?)$/ do |region_locator, contents|
|
51
|
+
region_id = region_selector_for(region_locator).gsub('#', '')
|
52
|
+
content = contents[0] == '"' ? contents : "\"#{contents_for(contents)}\""
|
53
|
+
page.driver.within_frame('mercury_iframe') do
|
54
|
+
find("##{region_id}", :message => "Unable to locate a region matching '##{region_id}'")
|
55
|
+
page.driver.execute_script <<-JAVASCRIPT
|
56
|
+
var element = top.jQuery(document).find('##{region_id}');
|
57
|
+
if (element.data('type') == 'markdown') {
|
58
|
+
element.find('textarea').val(#{content});
|
59
|
+
} else {
|
60
|
+
var region = top.mercuryInstance.getRegionByName('#{region_id}');
|
61
|
+
region.content(#{content});
|
62
|
+
}
|
63
|
+
JAVASCRIPT
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
When /^(?:|I )focus on (.*?)$/ do |region_locator|
|
68
|
+
step(%Q{I can simulate complex javascript events})
|
69
|
+
region_selector = region_selector_for(region_locator)
|
70
|
+
page.driver.within_frame('mercury_iframe') do
|
71
|
+
page.driver.execute_script <<-JAVASCRIPT
|
72
|
+
top.jQuery(document).find('#{region_selector}').simulate('mouseup')
|
73
|
+
JAVASCRIPT
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# setting/making selections
|
78
|
+
When /^(?:|I )(?:make|have) a selection$/ do
|
79
|
+
step(%Q{I have a selection for "span"})
|
80
|
+
end
|
81
|
+
|
82
|
+
When /^(?:|I )(?:make|have) a selection (?:in (.*?) )?for "([^"]*)"$/ do |region_locator, selector|
|
83
|
+
step(%Q{I can simulate complex javascript events})
|
84
|
+
# assume the first full region if one wasn't provided'
|
85
|
+
region_selector = region_selector_for(region_locator)
|
86
|
+
page.driver.within_frame('mercury_iframe') do
|
87
|
+
find("#{region_selector}", :message => "Unable to locate a region matching '#{region_selector}'")
|
88
|
+
find("#{region_selector} #{selector}", :message => "Unable to locate a match for '#{selector}' inside '#{region_locator}'")
|
89
|
+
page.driver.execute_script <<-JAVASCRIPT
|
90
|
+
var element = top.jQuery(document).find('#{region_selector}');
|
91
|
+
if (element.data('type') == 'markdown') {
|
92
|
+
alert('unimplemented');
|
93
|
+
throw('unimplemented');
|
94
|
+
} else {
|
95
|
+
var selectedElement = element.find('#{selector}');
|
96
|
+
var selection = new top.Mercury.Regions.Full.Selection(window.getSelection(), document);
|
97
|
+
selection.selectNode(selectedElement.get(0));
|
98
|
+
selectedElement.simulate('mouseup');
|
99
|
+
}
|
100
|
+
JAVASCRIPT
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# other events
|
105
|
+
When /^(?:|I )double click on (.*?) in (.*?)$/ do |locator, region_locator|
|
106
|
+
step(%Q{I can simulate complex javascript events})
|
107
|
+
selector = selector_for(locator)
|
108
|
+
# assume the first full region if one wasn't provided'
|
109
|
+
region_selector = region_selector_for(region_locator)
|
110
|
+
page.driver.within_frame('mercury_iframe') do
|
111
|
+
find("#{region_selector}", :message => "Unable to locate a region matching '#{region_selector}'")
|
112
|
+
find("#{region_selector} #{selector}", :message => "Unable to locate a match for '#{selector}' inside '#{region_selector}'")
|
113
|
+
page.driver.execute_script <<-JAVASCRIPT
|
114
|
+
top.jQuery(document).find('#{region_selector} #{selector}').simulate('dblclick');
|
115
|
+
JAVASCRIPT
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# getting contents
|
120
|
+
Then /^the contents? of (.*?) should be "([^"]*)"$/ do |region_locator, content|
|
121
|
+
region_selector = region_selector_for(region_locator)
|
122
|
+
page.driver.within_frame('mercury_iframe') do
|
123
|
+
find("#{region_selector}", :message => "Unable to locate a region matching '#{region_selector}'")
|
124
|
+
results = page.driver.execute_script <<-JAVASCRIPT
|
125
|
+
var element = top.jQuery(document).find('#{region_selector}');
|
126
|
+
if (element.data('type') == 'markdown') {
|
127
|
+
return element.find('textarea').val();
|
128
|
+
} else {
|
129
|
+
return element.html();
|
130
|
+
}
|
131
|
+
JAVASCRIPT
|
132
|
+
assert_equal content, results.gsub('"', "'").gsub("\n", '')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
## Saving specific steps
|
138
|
+
#------------------------------------------------------------------------------
|
139
|
+
# caching for the last save -- a request will still be made
|
140
|
+
Given /^save results will be cached$/ do
|
141
|
+
page.driver.execute_script <<-JAVASCRIPT
|
142
|
+
Mercury.PageEditor.prototype.save = function() {
|
143
|
+
window.cachedResults = this.serialize();
|
144
|
+
Mercury.changes = false;
|
145
|
+
}
|
146
|
+
JAVASCRIPT
|
147
|
+
end
|
148
|
+
|
149
|
+
# check for the last save cached results
|
150
|
+
Then /^the save should have (.*?) for (.*?)$/ do |contents, region_locator|
|
151
|
+
region_id = region_selector_for(region_locator).gsub('#', '')
|
152
|
+
content = contents[0] == '"' ? contents : "\"#{contents_for(contents)}\""
|
153
|
+
results = page.driver.execute_script <<-JAVASCRIPT
|
154
|
+
return (window.cachedResults['#{region_id}']) ?
|
155
|
+
window.cachedResults['#{region_id}']['value'] : null;
|
156
|
+
JAVASCRIPT
|
157
|
+
assert_equal content, "\"#{results}\""
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
## Table editing specific steps
|
162
|
+
#------------------------------------------------------------------------------
|
163
|
+
# in the modal window
|
164
|
+
When /^(?:|I )(?:add|insert) a (row|column) (before|after)(?: it)?$/ do |row_or_column, before_or_after|
|
165
|
+
name = "add_#{row_or_column}_#{before_or_after}".camelcase(:lower)
|
166
|
+
step(%Q{I click on ".mercury-modal-content button[data-action='#{name}']"})
|
167
|
+
end
|
168
|
+
|
169
|
+
When /^(?:|I )delete the(?: current)? (row|column)$/ do |row_or_column|
|
170
|
+
name = "remove_#{row_or_column}".camelcase(:lower)
|
171
|
+
step(%Q{I click on ".mercury-modal-content button[data-action='#{name}']"})
|
172
|
+
end
|
173
|
+
|
174
|
+
When /^(?:|I )(increase|decrease) the (rowspan|colspan)$/ do |increase_or_decrease, rowspan_or_colspan|
|
175
|
+
name = "#{increase_or_decrease}_#{rowspan_or_colspan}".camelcase(:lower)
|
176
|
+
step(%Q{I click on ".mercury-modal-content button[data-action=#{name}]"})
|
177
|
+
end
|
178
|
+
|
179
|
+
Then /^the selected cell should be (.*?)$/ do |locator|
|
180
|
+
selector = selector_for(locator).gsub('td:', 'td.selected:')
|
181
|
+
find("#{selector}", :message => "Unable to locate the selected cell for '#{selector}'")
|
182
|
+
end
|
183
|
+
|
184
|
+
# in general
|
185
|
+
Then /^the(?: table)? (row|column) count should be (\d+)$/ do |row_or_column, expected_count|
|
186
|
+
method = "get_#{row_or_column}_count".camelcase(:lower)
|
187
|
+
actual_count = page.driver.execute_script("return Mercury.tableEditor.#{method}()")
|
188
|
+
assert_equal expected_count.to_i, actual_count.to_i
|
189
|
+
end
|
190
|
+
|
191
|
+
|
192
|
+
## Snippet specific steps
|
193
|
+
#------------------------------------------------------------------------------
|
194
|
+
# setting snippet options
|
195
|
+
Given /^the options for the (.*?) snippet "([^"]*)" are (.*?)$/ do |snippet_name, snippet_id, options|
|
196
|
+
@snippet_id = snippet_id
|
197
|
+
options_json = parse_snippet_options_from(options)
|
198
|
+
page.driver.execute_script <<-JAVASCRIPT
|
199
|
+
Mercury.Snippet.load({#{snippet_id}: {name: '#{snippet_name}', options: #{options_json}}});
|
200
|
+
JAVASCRIPT
|
201
|
+
end
|
202
|
+
|
203
|
+
# dragging/dropping
|
204
|
+
When /^(?:|I )(?:drag|drop) (.*?) (?:into|on) (.*?)$/ do |snippet_locator, region_locator|
|
205
|
+
snippet_name = snippet_name_for(snippet_locator)
|
206
|
+
region_id = region_selector_for(region_locator).gsub('#', '')
|
207
|
+
page.driver.within_frame('mercury_iframe') do
|
208
|
+
find("##{region_id}", :message => "Unable to locate a region matching '##{region_id}'")
|
209
|
+
data = " data-snippet=\"#{snippet_name}\""
|
210
|
+
data << ' data-options="false"' if snippet_name == 'no_options'
|
211
|
+
|
212
|
+
page.driver.execute_script <<-JAVASCRIPT
|
213
|
+
var element = top.jQuery(document).find('##{region_id}');
|
214
|
+
if (element.data('type') == 'markdown') {
|
215
|
+
alert('unimplemented');
|
216
|
+
throw('unimplemented');
|
217
|
+
} else {
|
218
|
+
var region = top.mercuryInstance.getRegionByName('#{region_id}');
|
219
|
+
region.selection().range.collapse(true);
|
220
|
+
document.execCommand('insertHTML', false, '<img #{data} src="/assets/mercury/default-snippet.png">');
|
221
|
+
element.trigger('possible:drop');
|
222
|
+
}
|
223
|
+
JAVASCRIPT
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
When /^(?:|I )hover over (.*?)(?: in (.*?))?$/ do |locator, region_locator|
|
228
|
+
step(%Q{I can simulate complex javascript events})
|
229
|
+
selector = selector_for(locator)
|
230
|
+
region_selector = region_selector_for(region_locator)
|
231
|
+
page.driver.within_frame('mercury_iframe') do
|
232
|
+
find("#{region_selector}", :message => "Unable to locate a region matching '#{region_selector}'")
|
233
|
+
page.driver.execute_script <<-JAVASCRIPT
|
234
|
+
var element = top.jQuery(document).find('#{region_selector}');
|
235
|
+
if (element.data('type') == 'markdown') {
|
236
|
+
alert('unimplemented');
|
237
|
+
throw('unimplemented');
|
238
|
+
} else {
|
239
|
+
element.find('#{selector}').simulate('mousemove');
|
240
|
+
}
|
241
|
+
JAVASCRIPT
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
When /^(?:|I )edit the snippet$/ do
|
246
|
+
step(%{I hover over the snippet})
|
247
|
+
step(%{I click on the edit snippet settings toolbar button})
|
248
|
+
end
|
249
|
+
|
250
|
+
|
251
|
+
## Javascript event simulation steps
|
252
|
+
#------------------------------------------------------------------------------
|
253
|
+
Given /^(?:|I )can simulate complex javascript events$/ do
|
254
|
+
page.driver.execute_script(JQUERY_EVENT_SIMULATION_JAVASCRIPT)
|
255
|
+
end
|
256
|
+
|
257
|
+
#------------------------------------------------------------------------------
|
258
|
+
|
259
|
+
JQUERY_EVENT_SIMULATION_JAVASCRIPT = <<-JAVASCRIPT
|
260
|
+
/*
|
261
|
+
* jquery.simulate - simulate browser mouse and keyboard events
|
262
|
+
*
|
263
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
264
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
265
|
+
* http://jquery.org/license
|
266
|
+
*
|
267
|
+
*/
|
268
|
+
;(function($) {
|
269
|
+
|
270
|
+
$.fn.extend({
|
271
|
+
simulate: function(type, options) {
|
272
|
+
return this.each(function() {
|
273
|
+
var opt = $.extend({}, $.simulate.defaults, options || {});
|
274
|
+
new $.simulate(this, type, opt);
|
275
|
+
});
|
276
|
+
}
|
277
|
+
});
|
278
|
+
|
279
|
+
$.simulate = function(el, type, options) {
|
280
|
+
this.target = el;
|
281
|
+
this.options = options;
|
282
|
+
|
283
|
+
if (/^drag$/.test(type)) {
|
284
|
+
this[type].apply(this, [this.target, options]);
|
285
|
+
} else {
|
286
|
+
this.simulateEvent(el, type, options);
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
$.extend($.simulate.prototype, {
|
291
|
+
simulateEvent: function(el, type, options) {
|
292
|
+
var evt = this.createEvent(type, options);
|
293
|
+
this.dispatchEvent(el, type, evt, options);
|
294
|
+
return evt;
|
295
|
+
},
|
296
|
+
createEvent: function(type, options) {
|
297
|
+
if (/^mouse(over|out|down|up|move)|(dbl)?click$/.test(type)) {
|
298
|
+
return this.mouseEvent(type, options);
|
299
|
+
} else if (/^key(up|down|press)$/.test(type)) {
|
300
|
+
return this.keyboardEvent(type, options);
|
301
|
+
}
|
302
|
+
},
|
303
|
+
mouseEvent: function(type, options) {
|
304
|
+
var evt;
|
305
|
+
var e = $.extend({
|
306
|
+
bubbles: true, cancelable: (type != "mousemove"), view: window, detail: 0,
|
307
|
+
screenX: 0, screenY: 0, clientX: 0, clientY: 0,
|
308
|
+
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
|
309
|
+
button: 0, relatedTarget: undefined
|
310
|
+
}, options);
|
311
|
+
|
312
|
+
var relatedTarget = $(e.relatedTarget)[0];
|
313
|
+
|
314
|
+
if ($.isFunction(document.createEvent)) {
|
315
|
+
evt = document.createEvent("MouseEvents");
|
316
|
+
evt.initMouseEvent(type, e.bubbles, e.cancelable, e.view, e.detail,
|
317
|
+
e.screenX, e.screenY, e.clientX, e.clientY,
|
318
|
+
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
|
319
|
+
e.button, e.relatedTarget || document.body.parentNode);
|
320
|
+
} else if (document.createEventObject) {
|
321
|
+
evt = document.createEventObject();
|
322
|
+
$.extend(evt, e);
|
323
|
+
evt.button = { 0:1, 1:4, 2:2 }[evt.button] || evt.button;
|
324
|
+
}
|
325
|
+
return evt;
|
326
|
+
},
|
327
|
+
keyboardEvent: function(type, options) {
|
328
|
+
var evt;
|
329
|
+
|
330
|
+
var e = $.extend({ bubbles: true, cancelable: true, view: window,
|
331
|
+
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
|
332
|
+
keyCode: 0, charCode: 0
|
333
|
+
}, options);
|
334
|
+
|
335
|
+
if ($.isFunction(document.createEvent)) {
|
336
|
+
try {
|
337
|
+
evt = document.createEvent("KeyEvents");
|
338
|
+
evt.initKeyEvent(type, e.bubbles, e.cancelable, e.view,
|
339
|
+
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
|
340
|
+
e.keyCode, e.charCode);
|
341
|
+
} catch(err) {
|
342
|
+
evt = document.createEvent("Events");
|
343
|
+
evt.initEvent(type, e.bubbles, e.cancelable);
|
344
|
+
$.extend(evt, { view: e.view,
|
345
|
+
ctrlKey: e.ctrlKey, altKey: e.altKey, shiftKey: e.shiftKey, metaKey: e.metaKey,
|
346
|
+
keyCode: e.keyCode, charCode: e.charCode
|
347
|
+
});
|
348
|
+
}
|
349
|
+
} else if (document.createEventObject) {
|
350
|
+
evt = document.createEventObject();
|
351
|
+
$.extend(evt, e);
|
352
|
+
}
|
353
|
+
if ($.browser.msie || $.browser.opera) {
|
354
|
+
evt.keyCode = (e.charCode > 0) ? e.charCode : e.keyCode;
|
355
|
+
evt.charCode = undefined;
|
356
|
+
}
|
357
|
+
return evt;
|
358
|
+
},
|
359
|
+
dispatchEvent: function(el, type, evt) {
|
360
|
+
if (el.dispatchEvent) {
|
361
|
+
el.dispatchEvent(evt);
|
362
|
+
} else if (el.fireEvent) {
|
363
|
+
el.fireEvent('on' + type, evt);
|
364
|
+
}
|
365
|
+
return evt;
|
366
|
+
},
|
367
|
+
drag: function(el) {
|
368
|
+
var self = this, center = this.findCenter(this.target),
|
369
|
+
options = this.options, x = Math.floor(center.x), y = Math.floor(center.y),
|
370
|
+
dx = options.dx || 0, dy = options.dy || 0, target = this.target;
|
371
|
+
var coord = { clientX: x, clientY: y };
|
372
|
+
this.simulateEvent(target, "mousedown", coord);
|
373
|
+
coord = { clientX: x + 1, clientY: y + 1 };
|
374
|
+
this.simulateEvent(document, "mousemove", coord);
|
375
|
+
coord = { clientX: x + dx, clientY: y + dy };
|
376
|
+
this.simulateEvent(document, "mousemove", coord);
|
377
|
+
this.simulateEvent(document, "mousemove", coord);
|
378
|
+
this.simulateEvent(target, "mouseup", coord);
|
379
|
+
this.simulateEvent(target, "click", coord);
|
380
|
+
},
|
381
|
+
findCenter: function(el) {
|
382
|
+
var el = $(this.target), o = el.offset(), d = $(document);
|
383
|
+
return {
|
384
|
+
x: o.left + el.outerWidth() / 2 - d.scrollLeft(),
|
385
|
+
y: o.top + el.outerHeight() / 2 - d.scrollTop()
|
386
|
+
};
|
387
|
+
}
|
388
|
+
});
|
389
|
+
|
390
|
+
$.extend($.simulate, {
|
391
|
+
defaults: {
|
392
|
+
speed: 'sync'
|
393
|
+
},
|
394
|
+
VK_TAB: 9,
|
395
|
+
VK_ENTER: 13,
|
396
|
+
VK_ESC: 27,
|
397
|
+
VK_PGUP: 33,
|
398
|
+
VK_PGDN: 34,
|
399
|
+
VK_END: 35,
|
400
|
+
VK_HOME: 36,
|
401
|
+
VK_LEFT: 37,
|
402
|
+
VK_UP: 38,
|
403
|
+
VK_RIGHT: 39,
|
404
|
+
VK_DOWN: 40
|
405
|
+
});
|
406
|
+
|
407
|
+
})(jQuery);
|
408
|
+
JAVASCRIPT
|