2010-05-08 09:35:35 +02:00
|
|
|
/**
|
|
|
|
* File: CMSMain.EditForm.js
|
|
|
|
*/
|
2009-11-21 04:16:03 +01:00
|
|
|
(function($) {
|
2010-04-13 07:55:56 +02:00
|
|
|
$.entwine('ss', function($){
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form :input[name=ClassName]
|
2010-05-08 04:45:05 +02:00
|
|
|
* Alert the user on change of page-type. This might have implications
|
2009-11-21 04:19:59 +01:00
|
|
|
* on the available form fields etc.
|
|
|
|
*/
|
2011-03-31 10:51:59 +02:00
|
|
|
$('.cms-edit-form :input[name=ClassName]').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
// Function: onchange
|
2009-11-21 04:17:54 +01:00
|
|
|
onchange: function() {
|
|
|
|
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
|
2009-11-21 04:16:03 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:16:03 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form input[name=Title]
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Input validation on the Title field
|
2009-11-21 04:19:59 +01:00
|
|
|
*/
|
2011-03-31 10:51:59 +02:00
|
|
|
$('.cms-edit-form input[name=Title]').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
// Constructor: onmatch
|
2009-11-21 04:16:03 +01:00
|
|
|
onmatch : function() {
|
|
|
|
var self = this;
|
2012-06-22 03:02:35 +02:00
|
|
|
|
|
|
|
self.data('OrigVal', self.val());
|
2012-05-10 02:01:57 +02:00
|
|
|
|
2013-02-04 20:47:23 +01:00
|
|
|
var form = self.closest('form');
|
|
|
|
var urlSegmentInput = $('input:text[name=URLSegment]', form);
|
|
|
|
var liveLinkInput = $('input[name=LiveLink]', form);
|
2012-05-22 04:04:20 +02:00
|
|
|
|
2013-02-04 20:47:23 +01:00
|
|
|
if (urlSegmentInput.length > 0) {
|
|
|
|
self._addActions();
|
2012-05-22 04:04:20 +02:00
|
|
|
this.bind('change', function(e) {
|
2012-06-22 03:02:35 +02:00
|
|
|
var origTitle = self.data('OrigVal');
|
2012-05-22 04:04:20 +02:00
|
|
|
var title = self.val();
|
2012-06-22 03:02:35 +02:00
|
|
|
self.data('OrigVal', title);
|
|
|
|
|
2012-05-22 04:04:20 +02:00
|
|
|
// Criteria for defining a "new" page
|
2015-02-20 23:33:59 +01:00
|
|
|
if (
|
|
|
|
urlSegmentInput.val().indexOf(urlSegmentInput.data('defaultUrl')) === 0
|
|
|
|
&& liveLinkInput.val() == ''
|
|
|
|
) {
|
2012-05-22 04:04:20 +02:00
|
|
|
self.updateURLSegment(title);
|
|
|
|
} else {
|
|
|
|
$('.update', self.parent()).show();
|
|
|
|
}
|
2012-06-22 03:02:35 +02:00
|
|
|
|
|
|
|
self.updateRelatedFields(title, origTitle);
|
2012-06-18 07:34:35 +02:00
|
|
|
self.updateBreadcrumbLabel(title);
|
2012-05-22 04:04:20 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
this._super();
|
2009-11-21 04:16:03 +01:00
|
|
|
},
|
2012-05-14 01:43:55 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2011-12-17 05:58:58 +01:00
|
|
|
|
|
|
|
/**
|
2012-05-13 06:55:26 +02:00
|
|
|
* Function: updateRelatedFields
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-06-22 03:02:35 +02:00
|
|
|
* Update the related fields if appropriate
|
|
|
|
* (String) title The new title
|
|
|
|
* (Stirng) origTitle The original title
|
2012-05-13 06:55:26 +02:00
|
|
|
*/
|
2012-06-22 03:02:35 +02:00
|
|
|
updateRelatedFields: function(title, origTitle) {
|
|
|
|
// Update these fields only if their value was originally the same as the title
|
|
|
|
this.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').each(function() {
|
|
|
|
var $this = $(this);
|
|
|
|
if($this.val() == origTitle) {
|
|
|
|
$this.val(title);
|
|
|
|
// Onchange bubbling didn't work in IE8, so .trigger('change') couldn't be used
|
|
|
|
if($this.updatedRelatedFields) $this.updatedRelatedFields();
|
|
|
|
}
|
|
|
|
});
|
2012-05-13 06:55:26 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: updateURLSegment
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-05-13 06:55:26 +02:00
|
|
|
* Update the URLSegment
|
|
|
|
* (String) title
|
|
|
|
*/
|
|
|
|
updateURLSegment: function(title) {
|
2013-02-04 20:47:23 +01:00
|
|
|
var urlSegmentInput = $('input:text[name=URLSegment]', this.closest('form'));
|
|
|
|
var urlSegmentField = urlSegmentInput.closest('.field.urlsegment');
|
2012-05-13 06:55:26 +02:00
|
|
|
var updateURLFromTitle = $('.update', this.parent());
|
2013-02-04 20:47:23 +01:00
|
|
|
urlSegmentField.update(title);
|
2012-05-13 06:55:26 +02:00
|
|
|
if (updateURLFromTitle.is(':visible')) {
|
|
|
|
updateURLFromTitle.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-06-18 07:34:35 +02:00
|
|
|
* Function: updateBreadcrumbLabel
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-06-18 07:34:35 +02:00
|
|
|
* Update the breadcrumb
|
2012-05-13 06:55:26 +02:00
|
|
|
* (String) title
|
2011-12-17 05:58:58 +01:00
|
|
|
*/
|
2012-06-18 07:34:35 +02:00
|
|
|
updateBreadcrumbLabel: function(title) {
|
2012-05-13 06:55:26 +02:00
|
|
|
var pageID = $('.cms-edit-form input[name=ID]').val();
|
|
|
|
var panelCrumb = $('span.cms-panel-link.crumb');
|
|
|
|
if (title && title != "") {
|
|
|
|
panelCrumb.text(title);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: _addActions
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-05-13 06:55:26 +02:00
|
|
|
* Utility to add update from title action
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-05-13 06:55:26 +02:00
|
|
|
*/
|
|
|
|
_addActions: function() {
|
|
|
|
var self = this;
|
|
|
|
var updateURLFromTitle;
|
|
|
|
|
|
|
|
// update button
|
|
|
|
updateURLFromTitle = $('<button />', {
|
|
|
|
'class': 'update ss-ui-button-small',
|
2015-01-13 11:36:09 +01:00
|
|
|
'text': ss.i18n._t('URLSEGMENT.UpdateURL'),
|
2015-10-05 17:22:36 +02:00
|
|
|
'type': 'button',
|
2012-05-13 06:55:26 +02:00
|
|
|
'click': function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
self.updateURLSegment(self.val());
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// insert elements
|
|
|
|
updateURLFromTitle.insertAfter(self);
|
|
|
|
updateURLFromTitle.hide();
|
2009-11-21 04:16:03 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:16:03 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form .parentTypeSelector
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* ParentID field combination - mostly toggling between
|
2009-11-21 04:19:59 +01:00
|
|
|
* the two radiobuttons and setting the hidden "ParentID" field
|
|
|
|
*/
|
2011-03-31 10:51:59 +02:00
|
|
|
$('.cms-edit-form .parentTypeSelector').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
// Constructor: onmatch
|
2009-11-21 04:16:03 +01:00
|
|
|
onmatch : function() {
|
|
|
|
var self = this;
|
|
|
|
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
|
2012-02-11 00:49:51 +01:00
|
|
|
this.find('.TreeDropdownField').bind('change', function(e) {self._changeParentId(e);});
|
|
|
|
|
|
|
|
this._changeParentId();
|
2009-11-21 04:16:03 +01:00
|
|
|
this._toggleSelection();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
|
|
|
this._super();
|
2009-11-21 04:16:03 +01:00
|
|
|
},
|
2012-05-14 01:43:55 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: _toggleSelection
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2009-11-21 04:16:03 +01:00
|
|
|
_toggleSelection: function(e) {
|
|
|
|
var selected = this.find(':input[name=ParentType]:checked').val();
|
|
|
|
// reset parent id if 'root' radiobutton is selected
|
|
|
|
if(selected == 'root') this.find(':input[name=ParentID]').val(0);
|
2012-02-11 00:49:51 +01:00
|
|
|
// otherwise use the old value
|
|
|
|
else this.find(':input[name=ParentID]').val(this.find('#Form_EditForm_ParentType_subpage').data('parentIdValue'));
|
2009-11-21 04:16:03 +01:00
|
|
|
// toggle tree dropdown based on selection
|
2015-09-23 15:53:07 +02:00
|
|
|
this.find('#Form_EditForm_ParentID_Holder').toggle(selected != 'root');
|
2012-02-11 00:49:51 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: _changeParentId
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2012-02-11 00:49:51 +01:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
|
|
|
_changeParentId: function(e) {
|
|
|
|
var value = this.find(':input[name=ParentID]').val();
|
|
|
|
// set a data attribute so we know what to use in _toggleSelection
|
|
|
|
this.find('#Form_EditForm_ParentType_subpage').data('parentIdValue', value);
|
2009-11-21 04:16:03 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:16:03 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form #CanViewType, .cms-edit-form #CanEditType
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Toggle display of group dropdown in "access" tab,
|
2009-11-21 04:19:59 +01:00
|
|
|
* based on selection of radiobuttons.
|
|
|
|
*/
|
2011-04-30 08:34:52 +02:00
|
|
|
$('.cms-edit-form #CanViewType, .cms-edit-form #CanEditType, .cms-edit-form #CanCreateTopLevelType').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
// Constructor: onmatch
|
2009-11-21 04:16:03 +01:00
|
|
|
onmatch: function() {
|
|
|
|
// TODO Decouple
|
|
|
|
var dropdown;
|
2015-09-23 15:53:07 +02:00
|
|
|
if(this.attr('id') == 'CanViewType') dropdown = $('#Form_EditForm_ViewerGroups_Holder');
|
|
|
|
else if(this.attr('id') == 'CanEditType') dropdown = $('#Form_EditForm_EditorGroups_Holder');
|
|
|
|
else if(this.attr('id') == 'CanCreateTopLevelType') dropdown = $('#Form_EditForm_CreateTopLevelGroups_Holder');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:16:03 +01:00
|
|
|
this.find('.optionset :input').bind('change', function(e) {
|
2012-03-09 01:14:17 +01:00
|
|
|
var wrapper = $(this).closest('.middleColumn').parent('div');
|
|
|
|
if(e.target.value == 'OnlyTheseUsers') {
|
|
|
|
wrapper.addClass('remove-splitter');
|
|
|
|
dropdown['show']();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
wrapper.removeClass('remove-splitter');
|
|
|
|
dropdown['hide']();
|
|
|
|
}
|
2009-11-21 04:16:03 +01:00
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:16:03 +01:00
|
|
|
// initial state
|
|
|
|
var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val();
|
2011-04-30 08:34:52 +02:00
|
|
|
dropdown[currentVal == 'OnlyTheseUsers' ? 'show' : 'hide']();
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2012-05-14 01:43:55 +02:00
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
onunmatch: function() {
|
2009-11-21 04:19:59 +01:00
|
|
|
this._super();
|
2009-11-21 04:16:03 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:16:03 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_print
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Open a printable representation of the form in a new window.
|
2009-11-21 04:19:59 +01:00
|
|
|
* Used for readonly older versions of a specific page.
|
|
|
|
*/
|
2011-03-31 10:51:59 +02:00
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_print').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2009-11-21 04:16:03 +01:00
|
|
|
onclick: function(e) {
|
2016-01-06 00:42:07 +01:00
|
|
|
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
|
|
|
|
+ '/printable/'
|
2009-11-21 04:16:03 +01:00
|
|
|
+ $(':input[name=ID]',this[0].form).val();
|
|
|
|
if(printURL.substr(0,7) != 'http://') printURL = $('base').attr('href') + printURL;
|
|
|
|
|
|
|
|
window.open(printURL, 'printable');
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 04:16:03 +01:00
|
|
|
return false;
|
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 04:16:03 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
2011-03-31 10:51:59 +02:00
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_rollback
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* A "rollback" to a specific version needs user confirmation.
|
2009-11-21 04:19:59 +01:00
|
|
|
*/
|
2017-10-19 23:01:56 +02:00
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_doRollback').entwine({
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2010-05-08 04:45:05 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2009-11-21 04:16:03 +01:00
|
|
|
onclick: function(e) {
|
2010-04-13 06:26:34 +02:00
|
|
|
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
|
|
|
|
if(version) {
|
2012-04-10 14:02:05 +02:00
|
|
|
message = ss.i18n.sprintf(
|
2016-01-06 00:42:07 +01:00
|
|
|
ss.i18n._t('CMSMain.RollbackToVersion'),
|
2012-04-10 14:02:05 +02:00
|
|
|
version
|
|
|
|
);
|
2010-04-13 06:26:34 +02:00
|
|
|
} else {
|
2012-04-10 14:02:05 +02:00
|
|
|
message = ss.i18n._t('CMSMain.ConfirmRestoreFromLive');
|
|
|
|
}
|
|
|
|
if(confirm(message)) {
|
|
|
|
return this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
2010-04-13 06:26:34 +02:00
|
|
|
}
|
2009-11-21 04:16:03 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2011-09-28 00:48:36 +02:00
|
|
|
|
2015-05-15 01:51:23 +02:00
|
|
|
/**
|
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_archive
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Informing the user about the archive action while requiring confirmation
|
|
|
|
*/
|
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_archive').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
|
|
|
onclick: function(e) {
|
|
|
|
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
|
|
|
|
message = ss.i18n.sprintf(
|
2016-01-06 00:42:07 +01:00
|
|
|
ss.i18n._t('CMSMain.Archive'),
|
2015-05-15 01:51:23 +02:00
|
|
|
version
|
|
|
|
);
|
|
|
|
if(confirm(message)) {
|
|
|
|
return this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_restore
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Informing the user about the archive action while requiring confirmation
|
|
|
|
*/
|
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_restore').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
|
|
|
onclick: function(e) {
|
|
|
|
var form = this.parents('form:first'),
|
|
|
|
version = form.find(':input[name=Version]').val(),
|
|
|
|
message = '',
|
|
|
|
toRoot = this.data('toRoot');
|
|
|
|
message = ss.i18n.sprintf(
|
2016-01-06 00:42:07 +01:00
|
|
|
ss.i18n._t(toRoot ? 'CMSMain.RestoreToRoot' : 'CMSMain.Restore'),
|
2015-05-15 01:51:23 +02:00
|
|
|
version
|
|
|
|
);
|
|
|
|
if(confirm(message)) {
|
|
|
|
return this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_delete
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Informing the user about the delete from draft action while requiring confirmation
|
|
|
|
*/
|
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_delete').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
|
|
|
onclick: function(e) {
|
|
|
|
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
|
|
|
|
message = ss.i18n.sprintf(
|
2016-01-06 00:42:07 +01:00
|
|
|
ss.i18n._t('CMSMain.DeleteFromDraft'),
|
2015-05-15 01:51:23 +02:00
|
|
|
version
|
|
|
|
);
|
|
|
|
if(confirm(message)) {
|
|
|
|
return this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class: .cms-edit-form .Actions #Form_EditForm_action_unpublish
|
|
|
|
* Informing the user about the unpublish action while requiring confirmation
|
|
|
|
*/
|
|
|
|
$('.cms-edit-form .Actions #Form_EditForm_action_unpublish').entwine({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function: onclick
|
2016-01-06 00:42:07 +01:00
|
|
|
*
|
2015-05-15 01:51:23 +02:00
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
|
|
|
onclick: function(e) {
|
|
|
|
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
|
|
|
|
message = ss.i18n.sprintf(
|
2016-01-06 00:42:07 +01:00
|
|
|
ss.i18n._t('CMSMain.Unpublish'),
|
2015-05-15 01:51:23 +02:00
|
|
|
version
|
|
|
|
);
|
|
|
|
if(confirm(message)) {
|
|
|
|
return this._super(e);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-11-21 21:46:45 +01:00
|
|
|
/**
|
|
|
|
* Enable save buttons upon detecting changes to content.
|
|
|
|
* "changed" class is added by jQuery.changetracker.
|
|
|
|
*/
|
2012-12-17 23:02:32 +01:00
|
|
|
$('.cms-edit-form.changed').entwine({
|
2012-11-21 21:46:45 +01:00
|
|
|
onmatch: function(e) {
|
2012-12-17 23:02:32 +01:00
|
|
|
this.find('button[name=action_save]').button('option', 'showingAlternate', true);
|
|
|
|
this.find('button[name=action_publish]').button('option', 'showingAlternate', true);
|
2012-11-21 21:46:45 +01:00
|
|
|
this._super(e);
|
|
|
|
},
|
|
|
|
onunmatch: function(e) {
|
2013-01-21 00:56:02 +01:00
|
|
|
var saveButton = this.find('button[name=action_save]');
|
2014-02-17 02:34:12 +01:00
|
|
|
if(saveButton.data('button')) saveButton.button('option', 'showingAlternate', false);
|
2013-01-21 00:56:02 +01:00
|
|
|
var publishButton = this.find('button[name=action_publish]');
|
2014-02-17 02:34:12 +01:00
|
|
|
if(publishButton.data('button')) publishButton.button('option', 'showingAlternate', false);
|
2012-11-21 21:46:45 +01:00
|
|
|
this._super(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cms-edit-form .Actions button[name=action_publish]').entwine({
|
|
|
|
/**
|
|
|
|
* Bind to ssui.button event to trigger stylistic changes.
|
|
|
|
*/
|
|
|
|
onbuttonafterrefreshalternate: function() {
|
|
|
|
if (this.button('option', 'showingAlternate')) {
|
|
|
|
this.addClass('ss-ui-action-constructive');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.removeClass('ss-ui-action-constructive');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cms-edit-form .Actions button[name=action_save]').entwine({
|
|
|
|
/**
|
|
|
|
* Bind to ssui.button event to trigger stylistic changes.
|
|
|
|
*/
|
|
|
|
onbuttonafterrefreshalternate: function() {
|
|
|
|
if (this.button('option', 'showingAlternate')) {
|
|
|
|
this.addClass('ss-ui-action-constructive');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.removeClass('ss-ui-action-constructive');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-09-28 00:48:36 +02:00
|
|
|
/**
|
|
|
|
* Class: .cms-edit-form.CMSPageSettingsController input[name="ParentType"]:checked
|
|
|
|
*
|
|
|
|
* Showing the "Page location" "Parent page" chooser only when the "Sub-page underneath a parent page"
|
|
|
|
* radio button is selected
|
|
|
|
*/
|
|
|
|
$('.cms-edit-form.CMSPageSettingsController input[name="ParentType"]:checked').entwine({
|
2012-04-23 11:02:29 +02:00
|
|
|
onmatch: function() {
|
2012-04-23 11:21:31 +02:00
|
|
|
this.redraw();
|
2012-04-23 11:02:29 +02:00
|
|
|
this._super();
|
|
|
|
},
|
2012-05-14 01:43:55 +02:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
2012-04-23 11:21:31 +02:00
|
|
|
redraw: function() {
|
2015-09-23 15:53:07 +02:00
|
|
|
var treeField = $('.cms-edit-form.CMSPageSettingsController #Form_EditForm_ParentID_Holder');
|
2012-04-23 11:21:31 +02:00
|
|
|
if ($(this).attr('id') == 'Form_EditForm_ParentType_root') treeField.slideUp();
|
|
|
|
else treeField.slideDown();
|
|
|
|
},
|
|
|
|
onclick: function() {
|
|
|
|
this.redraw();
|
2011-09-28 00:48:36 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//trigger an initial change event to do the initial hiding of the element, if necessary
|
|
|
|
if ($('.cms-edit-form.CMSPageSettingsController input[name="ParentType"]:checked').attr('id') == 'Form_EditForm_ParentType_root') {
|
2015-09-23 15:53:07 +02:00
|
|
|
$('.cms-edit-form.CMSPageSettingsController #Form_EditForm_ParentID_Holder').hide(); //quick hide on first run
|
2011-09-28 00:48:36 +02:00
|
|
|
}
|
2009-11-21 04:16:03 +01:00
|
|
|
});
|
2012-04-21 01:22:55 +02:00
|
|
|
}(jQuery));
|