Permalink
Browse files

BUG Take first non-empty link field for preview

Goes by priority, but allows for fields to be empty.
This is important e.g. for models which are removed just
from live, or just from draft.
Also reacts to a field rename done in CMS module (62783c7).
  • Loading branch information...
1 parent f638935 commit dc08e87bd58ea430d8ac145fe4b610c741aca77f @chillu chillu committed Aug 27, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 admin/javascript/LeftAndMain.Preview.js
@@ -67,7 +67,10 @@
if(this.is('.is-collapsed')) return;
// var url = ui.xmlhttp.getResponseHeader('x-frontend-url');
- var url = $('.cms-edit-form').find(':input[name=PreviewURL],:input[name=StageURLSegment]').val();
+ var url = $('.cms-edit-form')
+ .find(':input[name=PreviewURL],:input[name=StageLink],:input[name=LiveLink]')
+ .filter(function() {return $(this).val() !== '';})
+ .val();
if(url) {
this.loadUrl(url);
this.unblock();
@@ -294,7 +297,11 @@
onclick: function(e) {
e.preventDefault();
- var preview = $('.cms-preview'), url = $('.cms-edit-form').find(':input[name=PreviewURL],:input[name=StageURLSegment]').val();
+ var preview = $('.cms-preview'),
+ url = $('.cms-edit-form')
+ .find(':input[name=PreviewURL],:input[name=StageLink],:input[name=LiveLink]')
+ .filter(function() {return $(this).val() !== '';})
+ .val();
if(url) {
preview.loadUrl(url);
preview.unblock();

0 comments on commit dc08e87

Please sign in to comment.