Skip to content
This repository
Browse code

BUGFIX: #7036 refresh CMS panel when adding a new file

  • Loading branch information...
commit 39742f53e54e9af99b64239b3021f0948c554da5 1 parent 5061c8c
Will Rossiter authored
2  admin/css/screen.css
@@ -191,6 +191,8 @@ form.small .field input.text, form.small .field textarea, form.small .field sele
191 191
 .cms .ss-ui-button.ss-ui-action-minor { background: none; border: 0; color: #393939; text-decoration: underline; -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; }
192 192
 .cms .ss-ui-button.ss-ui-action-minor:hover { text-decoration: none; color: #1f1f1f; }
193 193
 .cms .ss-ui-button.ss-ui-action-minor:focus, .cms .ss-ui-button.ss-ui-action-minor:active { text-decoration: none; color: #525252; }
  194
+.cms .ss-ui-button.ss-ui-button-loading { opacity: 0.8; }
  195
+.cms .ss-ui-loading-icon { background: url(../../images/network-save.gif) no-repeat; display: block; width: 16px; height: 16px; }
194 196
 
195 197
 /** ---------------------------------------------------- Grouped form fields ---------------------------------------------------- */
196 198
 .fieldgroup .fieldgroup-field { float: left; display: block; width: 184px; padding-right: 8px; }
48  admin/javascript/LeftAndMain.js
@@ -124,6 +124,8 @@ jQuery.noConflict();
124 124
 			 */
125 125
 			loadPanel: function(url, title, data) {
126 126
 				if(!data) data = {};
  127
+				if(!title) title = "";
  128
+				
127 129
 				var selector = data.selector || '.cms-content', contentEl = $(selector);
128 130
 				
129 131
 				// Check change tracking (can't use events as we need a way to cancel the current state change)
@@ -138,7 +140,7 @@ jQuery.noConflict();
138 140
 					
139 141
 					if(abort) return;
140 142
 				}
141  
-
  143
+				
142 144
 				if(window.History.enabled) {
143 145
 					// Active menu item is set based on X-Controller ajax header,
144 146
 					// which matches one class on the menu
@@ -186,7 +188,6 @@ jQuery.noConflict();
186 188
 				});
187 189
 
188 190
 				contentEl.addClass('loading');
189  
-				
190 191
 				var xhr = $.ajax({
191 192
 					url: state.url,
192 193
 					success: function(data, status, xhr) {
@@ -247,9 +248,21 @@ jQuery.noConflict();
247 248
 				});
248 249
 				
249 250
 				this.setCurrentXHR(xhr);
  251
+			},
  252
+			/**
  253
+			 * Function: refresh
  254
+			 * 
  255
+			 * Updates the container based on the current url
  256
+			 *
  257
+			 * Returns: void
  258
+			 */
  259
+			refresh: function() {
  260
+				$(window).trigger('statechange');
  261
+				
  262
+				$(this).redraw();
250 263
 			}
251 264
 		});
252  
-
  265
+		
253 266
 		$('.cms-content-fields').entwine({
254 267
 			redraw: function() {
255 268
 				this.layout();
@@ -299,8 +312,21 @@ jQuery.noConflict();
299 312
 		 * Little helper to avoid repetition, and make it easy to trigger actions via a link,
300 313
 		 * without reloading the page, changing the URL, or loading in any new panel content.
301 314
 		 */
302  
-		$('.cms .cms-link-ajax').entwine({
  315
+		$('.cms .ss-ui-button-ajax').entwine({
303 316
 			onclick: function(e) {
  317
+				$(this).removeClass('ui-button-text-only');
  318
+				$(this).addClass('ss-ui-button-loading ui-button-text-icons');
  319
+				
  320
+				var loading = $(this).find(".ss-ui-loading-icon");
  321
+				
  322
+				if(loading.length < 1) {
  323
+					loading = $("<span></span>").addClass('ss-ui-loading-icon ui-button-icon-primary ui-icon');
  324
+					
  325
+					$(this).prepend(loading);
  326
+				}
  327
+				
  328
+				loading.show();
  329
+				
304 330
 				var href = this.attr('href'), url = href ? href : this.data('href');
305 331
 
306 332
 				jQuery.ajax({
@@ -308,7 +334,19 @@ jQuery.noConflict();
308 334
 					// Ensure that form view is loaded (rather than whole "Content" template)
309 335
 					complete: function(xmlhttp, status) {
310 336
 						var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText;
311  
-						if (typeof msg != "undefined" && msg != null) eval(msg);
  337
+						console.log(msg);
  338
+						
  339
+						try {
  340
+							if (typeof msg != "undefined" && msg != null) eval(msg);
  341
+						}
  342
+						catch(e) {}
  343
+						
  344
+						loading.hide();
  345
+						
  346
+						$(".cms-container").refresh();
  347
+						
  348
+						$(this).removeClass('ss-ui-button-loading ui-button-text-icons');
  349
+						$(this).addClass('ui-button-text-only');
312 350
 					},
313 351
 					dataType: 'html'
314 352
 				});
13  admin/scss/_forms.scss
@@ -319,7 +319,7 @@ form.small .field, .field.small {
319 319
 			);
320 320
 			@include box-shadow(0 0 5px darken($color-button-generic, 20%) inset);
321 321
 		}
322  
-
  322
+		
323 323
 		/* constructive */
324 324
 		&.ss-ui-action-constructive {
325 325
 			font-weight: bold;
@@ -384,6 +384,17 @@ form.small .field, .field.small {
384 384
 				color: lighten($color-text-dark, 20%);
385 385
 			}
386 386
 		}
  387
+		
  388
+		&.ss-ui-button-loading {
  389
+			opacity: 0.8;
  390
+		}
  391
+	}
  392
+	
  393
+	.ss-ui-loading-icon {
  394
+		background: url(../../images/network-save.gif) no-repeat;
  395
+		display: block;
  396
+		width: 16px;
  397
+		height: 16px;
387 398
 	}
388 399
 }
389 400
 

0 notes on commit 39742f5

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