-
Notifications
You must be signed in to change notification settings - Fork 333
/
CMSMain_right.js
executable file
·135 lines (120 loc) · 3.56 KB
/
CMSMain_right.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function action_publish_right() {
$('Form_EditForm_action_publish').value = ss.i18n._t('CMSMAIN.PUBLISHING');
$('Form_EditForm_action_publish').className = 'action loading';
var publish = true;
$('Form_EditForm').save(false, null, 'save', publish);
}
function action_revert_right() {
$('Form_EditForm_action_revert').value = ss.i18n._t('CMSMAIN.RESTORING');
$('Form_EditForm_action_revert').className = 'action loading';
Ajax.SubmitForm('Form_EditForm', 'action_revert', {
onSuccess : Ajax.Evaluator,
onFailure : function(response) {
errorMessage(ss.i18n._t('CMSMAIN.ERRORREVERTING'), response);
}
});
}
function action_rollback_right() {
var options = {
OK: function() {
var pageID = $('Form_EditForm').elements.ID.value;
Ajax.SubmitForm('Form_EditForm', 'action_rollback', {
onSuccess : function(response) {
$('Form_EditForm').getPageFromServer(pageID);
statusMessage(response.responseText,'good');
},
onFailure : function(response) {
errorMessage('Error rolling back content', response);
}
});
},
Cancel:function() {
}
}
if($('Form_EditForm').elements.Version && $('Form_EditForm').elements.Version.value) {
var message = ss.i18n.sprintf(
ss.i18n._t('CMSMAIN.RollbackConfirmation'),
$('Form_EditForm').elements.Version.value
);
} else {
var message = ss.i18n._t('CMSMAIN.CopyPublishedConfirmation');
}
if(confirm(message)) {
options.OK();
} else {
return false;
}
}
/**
* Email containing the link to the archived version of the page
*/
function action_email_right() {
window.open( 'mailto:?subject=' + $('Form_EditForm_ArchiveEmailSubject').value + '&body=' + $('Form_EditForm_ArchiveEmailMessage').value, 'archiveemail' );
}
function action_print_right() {
var printURL = $('Form_EditForm').action.replace(/\?.*$/,'') + '/printable/' + $('Form_EditForm').elements.ID.value;
if(printURL.substr(0,7) != 'http://') printURL = baseHref() + printURL;
window.open(printURL, 'printable');
}
function suggestStageSiteLink() {
var el = $('viewStageSite');
el.flasher = setInterval(flashColor.bind(el), 300);
setTimeout(stopFlashing.bind(el), 3000);
}
function flashColor() {
if(!this.style.color) this.style.color = '';
this.style.color = (this.style.color == '') ? '#00FF00' : '';
}
function stopFlashing() {
clearInterval(this.flasher);
}
Behaviour.register({
'a.cmsEditlink' : {
onclick : function() {
if(this.href.match(/admin\/show\/([0-9]+)($|#|\?)/)) {
$('Form_EditForm').getPageFromServer(RegExp.$1);
return false;
}
}
}
});
Behaviour.register({
'select#Form_EditForm_ClassName' : {
onchange: function() {
alert(ss.i18n._t('CMSMAIN.PageTypeSaveAlert'));
}
},
'#Form_EditForm' : {
changeDetection_fieldsToIgnore : {
'restricted-chars[Form_EditForm_URLSegment]' : true,
'Sort' : true,
'LiveURLSegment' : true
}
},
// ParentType / ParentID field combination
'#Form_EditForm_ParentType' : {
initialize : function() {
var parentTypeRootEl = $('Form_EditForm_ParentType_root');
var parentTypeSubpageEl = $('Form_EditForm_ParentType_subpage');
if(parentTypeRootEl) {
parentTypeRootEl.onclick = this.rootClick.bind(this);
}
if(parentTypeSubpageEl) {
parentTypeSubpageEl.onclick = this.showHide;
}
this.showHide();
},
rootClick : function() {
$('Form_EditForm_ParentID').setValue(0);
this.showHide();
},
showHide : function() {
var parentTypeRootEl = $('Form_EditForm_ParentType_root');
if(parentTypeRootEl && parentTypeRootEl.checked) {
Element.hide('ParentID');
} else {
Element.show('ParentID');
}
}
}
});