Skip to content
This repository
Browse code

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...
commit dc08e87bd58ea430d8ac145fe4b610c741aca77f 1 parent f638935
Ingo Schommer authored August 27, 2012

Showing 1 changed file with 9 additions and 2 deletions. Show diff stats Hide diff stats

  1. 11  admin/javascript/LeftAndMain.Preview.js
11  admin/javascript/LeftAndMain.Preview.js
@@ -67,7 +67,10 @@
67 67
 				if(this.is('.is-collapsed')) return;
68 68
 
69 69
 				// var url = ui.xmlhttp.getResponseHeader('x-frontend-url');
70  
-				var url = $('.cms-edit-form').find(':input[name=PreviewURL],:input[name=StageURLSegment]').val();
  70
+				var url = $('.cms-edit-form')
  71
+					.find(':input[name=PreviewURL],:input[name=StageLink],:input[name=LiveLink]')
  72
+					.filter(function() {return $(this).val() !== '';})
  73
+					.val();
71 74
 				if(url) {
72 75
 					this.loadUrl(url);
73 76
 					this.unblock();
@@ -294,7 +297,11 @@
294 297
 			onclick: function(e) {
295 298
 				e.preventDefault();
296 299
 				
297  
-				var preview = $('.cms-preview'), url = $('.cms-edit-form').find(':input[name=PreviewURL],:input[name=StageURLSegment]').val();
  300
+				var preview = $('.cms-preview'), 
  301
+					url = $('.cms-edit-form')
  302
+						.find(':input[name=PreviewURL],:input[name=StageLink],:input[name=LiveLink]')
  303
+						.filter(function() {return $(this).val() !== '';})
  304
+						.val();
298 305
 				if(url) {
299 306
 						preview.loadUrl(url);
300 307
 						preview.unblock();

0 notes on commit dc08e87

Please sign in to comment.
Something went wrong with that request. Please try again.