Merge pull request #431 from opf/fix/modal_links

Fix/modal links
pull/457/merge
Martin Czuchra 11 years ago
commit 0978bf0c28
  1. 14
      app/assets/javascripts/application.js
  2. 16
      app/assets/javascripts/modal.js
  3. 2
      app/assets/javascripts/timelines.js
  4. 3
      doc/CHANGELOG.md
  5. 29
      features/step_definitions/web_steps.rb
  6. 19
      features/timelines/timeline_modal_views.feature

@ -71,6 +71,20 @@ if (typeof []._reverse == 'undefined') {
}
jQuery(document).ready(function ($) {
//remove modal layout=false if we ctrl-click!
$(document.body).on("click", "a", function (e) {
if (top != self && e.ctrlKey) {
if (e.target && e.target.href) {
var url = e.target.href;
if (url.match(/(&)?layout=false/)) {
url = url.replace(/(&)?layout=false/g, "").replace(/\?$/, "");
window.open(url);
e.preventDefault();
}
}
}
});
if (typeof CS !== "undefined") {
var regions = $.datepicker.regional;
var regional = regions[CS.lang] || regions[""];

@ -58,7 +58,6 @@ var ModalHelper = (function() {
/** replace all data-modal links and all inside modal links */
body.on("click", "[data-modal]", modalFunction);
modalDiv.on("click", "a", modalFunction);
// close when body is clicked
body.on("click", ".ui-widget-overlay", jQuery.proxy(modalHelper.close, modalHelper));
@ -99,8 +98,18 @@ var ModalHelper = (function() {
modalDiv.data('changed', false);
var document_host = document.location.href.split("/")[2];
body.on("click", "a", function (e) {
var url = jQuery(e.target).attr("href");
var data = this.href.split("/");
var link_host = data[2];
if (link_host && link_host != document_host) {
window.open(this.href);
return false;
}
if (url) {
jQuery(e.target).attr("href", modalHelper.tweakLink(url));
}
@ -195,6 +204,11 @@ var ModalHelper = (function() {
* @param callback called when done. called with modal div.
*/
ModalHelper.prototype.createModal = function(url, callback) {
if (top != self) {
window.open(url.replace(/(&)?layout=false/g, ""));
return;
}
var modalHelper = this, modalDiv = this.modalDiv, counter = 0;
url = this.tweakLink(url);

@ -4280,7 +4280,7 @@ Timeline = {
text = timeline.escape(data.name);
if (data.getUrl instanceof Function) {
text = jQuery('<a href="' + data.getUrl() + '" class="tl-discreet-link" target="_blank" data-modal/>').append(text).attr("title", text);
text = jQuery('<a href="' + data.getUrl() + '" class="tl-discreet-link" data-modal/>').append(text).attr("title", text);
}
if (data.is(Timeline.Project)) {

@ -29,6 +29,9 @@ See doc/COPYRIGHT.rdoc for more details.
# Changelog
* `#1946` Modal shown within in Modal
* `#1949` External links within modals do not work
## 3.0.0pre19
* `#2203` Use server-side responsible filter

@ -63,6 +63,28 @@ When /^(.*) within (.*[^:])$/ do |step_name, parent|
with_scope(parent) { step step_name }
end
When(/^I ctrl\-click on "([^\"]+)"$/) do |text|
builder = page.driver.browser.action
#Hold control key down
builder.key_down(:control)
#Click all elements that you want, in this case we click all lis
#Note that you can retrieve the elements using capybara's
# standard methods. When passing them to the builder
# make sure to do .native
elements = page.all('a', :text => text)
elements.each do |e|
builder.click(e.native)
end
#Release control key
builder.key_up(:control)
#Do the action setup
builder.perform
end
# Single-line step scoper
When /^(.*) within_hidden (.*[^:])$/ do |step_name, parent|
with_scope(parent, visible: false) { step step_name }
@ -388,6 +410,13 @@ Given /^I (accept|dismiss) the alert dialog$/ do |method|
end
end
Then(/^(.*) in the new window$/) do |step|
new_window=page.driver.browser.window_handles.last
page.within_window new_window do
step(step)
end
end
Then /^(.*) in the iframe "([^\"]+)"$/ do |step, iframe_name|
browser = page.driver.browser
browser.switch_to.frame(iframe_name)

@ -47,13 +47,13 @@ Feature: Timeline View Tests
And I am already logged in as "manager"
And there are the following planning elements:
| Start date | Due date | description | planning_element_status | responsible | Subject |
| 2012-01-01 | 2012-01-31 | Avocado Hall | closed | manager | January |
| 2012-02-01 | 2012-02-24 | Avocado Rincon | closed | manager | February |
| 2012-03-01 | 2012-03-30 | Hass | closed | manager | March |
| 2012-04-01 | 2012-04-30 | Avocado Choquette | closed | manager | April |
| 2012-04-01 | 2012-04-30 | Relish | closed | manager | Loremipsumdolorsitamet,consecteturadipisicingelit,seddoeiusmodtemporincididuntutlaboreetdoloremagnaaliqua.Utenimadminimveniam |
And there are the following work packages:
| Start date | Due date | description | responsible | Subject |
| 2012-01-01 | 2012-01-31 | #2 http://google.de | manager | January |
| 2012-02-01 | 2012-02-24 | Avocado Rincon | manager | February |
| 2012-03-01 | 2012-03-30 | Hass | manager | March |
| 2012-04-01 | 2012-04-30 | Avocado Choquette | manager | April |
| 2012-04-01 | 2012-04-30 | Relish | manager | Test2 |
@javascript
Scenario: planning element click should show modal window
@ -63,8 +63,11 @@ Feature: Timeline View Tests
And I click on the Planning Element with name "January"
Then I should see a modal window
And I should see "#1: January" in the modal
And I should see "Avocado Hall" in the modal
And I should see "http://google.de" in the modal
And I should see "01/01/2012" in the modal
And I should see "01/31/2012" in the modal
And I should see "New timeline report"
And I should be on the page of the timeline "Testline" of the project called "ecookbook"
When I ctrl-click on "#2" in the modal
Then I should see "February" in the new window
Then I should see "Avocado Rincon" in the new window
Loading…
Cancel
Save