2007-07-19 10:40:28 +00:00
|
|
|
Behaviour.register({
|
|
|
|
'input#Form_EditForm_Title': {
|
|
|
|
/**
|
|
|
|
* Get the URL segment to suggest a new field
|
|
|
|
*/
|
|
|
|
onchange: function() {
|
2007-10-26 03:00:21 +00:00
|
|
|
if(this.value.length == 0) return;
|
|
|
|
if(!$('Form_EditForm_URLSegment')) return;
|
2007-07-19 10:40:28 +00:00
|
|
|
|
|
|
|
var urlSegmentField = $('Form_EditForm_URLSegment');
|
|
|
|
var newSuggestion = urlSegmentField.suggestNewValue( this.value.toLowerCase() );
|
2007-12-02 21:29:47 +00:00
|
|
|
var isNew = urlSegmentField.value.indexOf("new") == 0;
|
2008-10-03 00:47:08 +00:00
|
|
|
var confirmMessage = ss.i18n.sprintf(
|
2009-03-10 22:08:52 +00:00
|
|
|
ss.i18n._t('UPDATEURL.CONFIRM', 'Would you like me to change the URL to:\n\n%s/\n\nClick Ok to change the URL, click Cancel to leave it as:\n\n%s'),
|
2008-10-03 00:47:08 +00:00
|
|
|
newSuggestion,
|
|
|
|
urlSegmentField.value
|
|
|
|
);
|
2007-07-19 10:40:28 +00:00
|
|
|
|
2008-10-03 00:47:08 +00:00
|
|
|
if(
|
|
|
|
newSuggestion == urlSegmentField.value
|
|
|
|
|| isNew
|
|
|
|
|| confirm(confirmMessage)
|
|
|
|
) {
|
2007-07-19 10:40:28 +00:00
|
|
|
urlSegmentField.value = newSuggestion;
|
2008-10-03 00:47:08 +00:00
|
|
|
}
|
2007-09-16 02:01:34 +00:00
|
|
|
// If you type in Page name, the Navigation Label and Meta Title should automatically update the first time
|
|
|
|
// @todo: Change file name from UpdateURL to something more geneneric since we now do more than update the URL.
|
2007-10-26 03:00:21 +00:00
|
|
|
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MenuTitle').value.indexOf("New") == 0 ) {
|
2007-09-16 02:01:34 +00:00
|
|
|
$('Form_EditForm_MenuTitle').value = this.value;
|
|
|
|
}
|
|
|
|
// @todo see if updating this is confusing (Q: why isn't my page title changing? A: Check the Meta-Data tab)
|
2007-10-26 03:00:21 +00:00
|
|
|
if($('Form_EditForm_MetaTitle') && $('Form_EditForm_MetaTitle').value.length == 0 ) {
|
2007-09-16 02:01:34 +00:00
|
|
|
$('Form_EditForm_MetaTitle').value = this.value;
|
|
|
|
}
|
2007-07-19 10:40:28 +00:00
|
|
|
}
|
|
|
|
}
|
2007-09-16 02:01:34 +00:00
|
|
|
});
|