/** * File: CMSMain.js */ (function($) { $.entwine('ss', function($){ /** * Class: #contentPanel form * * All forms in the right content panel should have closeable jQuery UI style titles. */ // TODO Change to modal dialog, jQuery UI update somehow messed up the button positioning, // they're no longer clickable // $('#contentPanel form').entwine({ // // Constructor: onmatch // onmatch: function() { // // Style as title bar // this.find(':header:first').titlebar({ // closeButton:true // }); // // The close button should close the east panel of the layout // this.find(':header:first .ui-dialog-titlebar-close').bind('click', function(e) { // $('body.CMSMain').entwine('ss').getMainLayout().close('east'); // return false; // }); // // this._super(); // } // }); /** * Class: #Form_SearchTreeForm * * Control the site tree filter. * Toggles search form fields based on a dropdown selection, * similar to "Smart Search" criteria in iTunes. */ $('#Form_SearchTreeForm').entwine({ /** * Variable: SelectEl * {DOMElement} */ SelectEl: null, /** * Constructor: onmatch */ onmatch: function() { var self = this; // only the first field should be visible by default this.find('.field').not('.show-default').hide(); // generate the field dropdown this.setSelectEl($('') .appendTo(this.find('fieldset:first')) .bind('change', function(e) {self._addField(e);}) ); this._setOptions(); // special case: we can't use CMSSiteTreeFilter together with other options this.find('select[name=FilterClass]').change(function(e) { var others = self.find('.field').not($(this).parents('.field')).find(':input,select'); if(e.target.value == 'CMSSiteTreeFilter_Search') others.removeAttr('disabled'); else others.attr('disabled','disabled'); }); // Reset binding through entwine doesn't work in IE this.bind('reset', function(e) { self._onreset(e); }); this._super(); }, /** * Function: _setOptions */ _setOptions: function() { var self = this; // reset existing elements self.getSelectEl().find('option').remove(); // add default option // TODO i18n jQuery( '' ).appendTo(self.getSelectEl()); // populate dropdown values from existing fields this.find('.field').not(':visible').each(function() { $('