Skip to content

Commit

Permalink
Side-by-side preview initialisation and navigation fixes.
Browse files Browse the repository at this point in the history
Disables changetracking on preview options.
  • Loading branch information
mateusz authored and chillu committed Dec 10, 2012
1 parent 4fa2b0f commit fa3ef8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion admin/javascript/LeftAndMain.EditForm.js
Expand Up @@ -44,7 +44,7 @@
* (Object)
*/
ChangeTrackerOptions: {
ignoreFieldSelector: '.no-change-track, .ss-upload :input'
ignoreFieldSelector: '.no-change-track, .ss-upload :input, .cms-navigator :input'
},

/**
Expand Down
19 changes: 7 additions & 12 deletions admin/javascript/LeftAndMain.Preview.js
Expand Up @@ -96,7 +96,6 @@

// Update preview state selector.
var currentStateName = this.getCurrentStateName();

if (currentStateName) {
this.find('.cms-preview-states').changeVisibleState(currentStateName);
}
Expand Down Expand Up @@ -133,9 +132,10 @@
* Enable the area and start updating to reflect the content editing.
*/
enablePreview: function() {
this.setIsPreviewEnabled(true);
this.changeMode('split');
this._loadCurrentState();
if (!this.getIsPreviewEnabled()) {
this.setIsPreviewEnabled(true);
this.changeMode('split');
}
return this;
},

Expand Down Expand Up @@ -190,6 +190,8 @@
} else {
this.enablePreview();
this._moveNavigator();
this._loadCurrentState();
this.redraw();
}
return this;
},
Expand Down Expand Up @@ -285,7 +287,6 @@
if (navigatorEl.length && previewEl.length) {
// Navigator is available - install the navigator.
previewEl.html($('.cms-edit-form .cms-navigator').detach());
$('.cms-preview')._loadCurrentState();
} else {
// Navigator not available.
this._block();
Expand Down Expand Up @@ -375,19 +376,13 @@
* Change the appearance of the state selector.
*/
changeVisibleState: function(state) {
// Arbitrary mapping from checkbox state to the preview state.
if (state==='LiveLink') {
this.find('.cms-preview-checkbox').prop('checked', false);
} else {
this.find('.cms-preview-checkbox').prop('checked', true);
}
this.find('input[data-name="'+state+'"]').prop('checked', true);
}
});

$('.cms-preview-states .state-name').entwine({
/**
* Reacts to the user changing the state of the preview.
* TODO Rewrite this function to ensure we can handle 1,2,3+ states.
*/
onclick: function(e) {
var targetStateName = $(this).attr('data-name');
Expand Down

0 comments on commit fa3ef8c

Please sign in to comment.