/** * File: CMSMain.EditForm.js */ (function($) { $.entwine('ss', function($){ /** * Class: .cms-edit-form :input[name=ClassName] * Alert the user on change of page-type. This might have implications * on the available form fields etc. */ $('.cms-edit-form :input[name=ClassName]').entwine({ // Function: onchange onchange: function() { alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME')); } }); /** * Class: .cms-edit-form input[name=Title] * * Input validation on the Title field */ $('.cms-edit-form input[name=Title]').entwine({ // Constructor: onmatch onmatch : function() { var self = this; var form = self.parents('form'); var url_segment = $('.field.urlsegment', form).find(':text'); var live_url_segment = $('input[name=LiveURLSegment]', form); self._addActions(); this.bind('change', function(e) { var title = self.val(); // Criteria for defining a "new" page if ( (url_segment.val().indexOf("new") == 0) && live_url_segment.val() == "" ) { self.updateRelatedFields(title); self.updateURLSegment(title); } else { $('.update', self.parent()).show(); } self.updatePanelLabels(title); }); this._super(); }, onunmatch: function() { this._super(); }, /** * Function: updateRelatedFields * * Update the related fields * (String) title */ updateRelatedFields: function(title) { var form = this.parents('form'); form.find('input[name=MetaTitle], input[name=MenuTitle]').val(title); }, /** * Function: updateURLSegment * * Update the URLSegment * (String) title */ updateURLSegment: function(title) { var url_segment_field = $('.field.urlsegment', this.parents('form')); var updateURLFromTitle = $('.update', this.parent()); url_segment_field.update(title); if (updateURLFromTitle.is(':visible')) { updateURLFromTitle.hide(); } }, /** * Function: updatePanelLabels * * Update the breadcrumb and tree * (String) title */ updatePanelLabels: function(title) { var pageID = $('.cms-edit-form input[name=ID]').val(); var panelCrumb = $('span.cms-panel-link.crumb'); var treeItem = $('.item', $('.cms-tree').find("[data-id='" + pageID + "']")); if (title && title != "") { panelCrumb.text(title); treeItem.text(title); } }, /** * Function: _addActions * * Utility to add update from title action * */ _addActions: function() { var self = this; var updateURLFromTitle; // update button updateURLFromTitle = $('