MINOR Generic .cms-help-toggle implementation to replace MemberDatetimeOptionsetField.js (which also didn't work when loaded via Ajax, and needed a rewrite to jQuery.entwine anyway)

This commit is contained in:
Ingo Schommer 2012-03-05 17:18:30 +01:00
parent 851099d82d
commit 8da89c6f7c
3 changed files with 23 additions and 12 deletions

View File

@ -428,6 +428,23 @@ jQuery.noConflict();
}
});
/**
* Simple toggle link, which points to a DOm element by its ID selector
* in the href attribute (which doubles as an anchor link to that element).
*/
$('.cms .cms-help-toggle').entwine({
onmatch: function() {
this._super();
$(this.attr('href')).hide();
},
onclick: function(e) {
$(this.attr('href')).toggle();
e.preventDefault();
}
});
}(jQuery));
var statusMessage = function(text, type) {

View File

@ -6,9 +6,6 @@
class MemberDatetimeOptionsetField extends OptionsetField {
function Field() {
Requirements::javascript(THIRDPARTY_DIR . '/thirdparty/jquery/jquery.js');
Requirements::javascript(SAPPHIRE_DIR . '/javascript/MemberDatetimeOptionsetField.js');
$options = '';
$odd = 0;
$source = $this->getSource();
@ -45,8 +42,12 @@ class MemberDatetimeOptionsetField extends OptionsetField {
_t('MemberDatetimeOptionsetField.Preview', 'Preview'),
Zend_Date::now()->toString($value)
) : '';
$options .= "<a class=\"formattingHelpToggle\" href=\"#\">" . _t('MemberDatetimeOptionsetField.TOGGLEHELP', 'Toggle formatting help') . "</a>";
$options .= "<div class=\"formattingHelpText\">";
$options .= sprintf(
'<a class="cms-help-toggle" href="#%s">%s</a>',
$this->id() . '_Help',
_t('MemberDatetimeOptionsetField.TOGGLEHELP', 'Toggle formatting help')
);
$options .= "<div id=\"" . $this->id() . "_Help\">";
$options .= $this->getFormattingHelpText();
$options .= "</div>";
$options .= "</li>\n";

View File

@ -1,7 +0,0 @@
(function($) {
$('.formattingHelpText').hide();
$('.formattingHelpToggle').click(function() {
$(this).parent().find('.formattingHelpText').toggle();
return false;
})
})(jQuery);