Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG ShowUnpublished checkbox with initial state not working

If ShowUnpublished checkbox initial state is checked, the history
doesn't show the unpublished versions up front. The user would need to
uncheck the box then check again, as only the change event would handle
the toggling of showing unpublished versions.

Moved the ShowUnpublished handler into a separate entwine class, and
run the same toggle code onmatch, as well as onchange.
  • Loading branch information...
commit 4f88dcbbfc0026a6807c79a49ece1dcc183b62d6 1 parent f0e7990
@halkyon halkyon authored
Showing with 36 additions and 18 deletions.
  1. +36 −18 javascript/CMSPageHistoryController.js
View
54 javascript/CMSPageHistoryController.js
@@ -8,6 +8,7 @@
*/
$.entwine('ss', function($){
+
/**
* Class: #Form_VersionsForm
*
@@ -19,24 +20,6 @@
* Constructor
*/
onmatch: function() {
- var self = this;
-
- /**
- * Event: :input[name=ShowUnpublished] change
- *
- * Changing the show unpublished checkbox toggles whether to show
- * or hide the unpublished versions. Because those rows may be being
- * compared this also ensures those rows are unselected.
- */
- this.find(':input[name=ShowUnpublished]').bind('change', function(e) {
- if($(this).attr("checked")) {
- self.find("tr[data-published=false]").show();
- }
- else {
- self.find("tr[data-published=false]").hide()._unselect();
- }
- });
-
this._super();
},
onunmatch: function() {
@@ -84,6 +67,41 @@
});
/**
+ * Class: :input[name=ShowUnpublished]
+ *
+ * Used for toggling whether to show or hide unpublished versions.
+ */
+ $('#Form_VersionsForm input[name=ShowUnpublished]').entwine({
+ onmatch: function() {
+ this.toggle();
+ this._super();
+ },
+ onunmatch: function() {
+ this._super();
+ },
+ /**
+ * Event: :input[name=ShowUnpublished] change
+ *
+ * Changing the show unpublished checkbox toggles whether to show
+ * or hide the unpublished versions. Because those rows may be being
+ * compared this also ensures those rows are unselected.
+ */
+ onchange: function() {
+ this.toggle();
+ },
+ toggle: function() {
+ var self = $(this);
+ var form = self.parents('form');
+
+ if(self.attr('checked')) {
+ form.find('tr[data-published=false]').show();
+ } else {
+ form.find("tr[data-published=false]").hide()._unselect();
+ }
+ }
+ });
+
+ /**
* Class: #Form_VersionsForm tr
*
* An individual row in the versions form. Selecting the row updates
Please sign in to comment.
Something went wrong with that request. Please try again.