var t, tags; function submitParentForm(e) { jQuery(e).parents('fieldset').find('span.status-error,span.status-ok').fadeTo(200,0); var loading = (jQuery(e).parents('fieldset').find('.loading').size() > 0) ? jQuery(e).parents('fieldset').find('.loading') : $('
'); loading.css('opacity',0); jQuery(e).parents('fieldset').prepend(loading); loading.fadeTo(300,1); jQuery(e).parents('form').get(0).onsubmit(); return false; } function truncate(text, len) { var caps = text.replace(/[^A-Z]+/g, '').length; if (caps > 0 && (caps > len/4)) { return $.string(text).truncate(len/2).str; } else { return $.string(text).truncate(len).str; } } var hideBitBox = function hideBitBox(id, eff) { if (eff == undefined) eff = {}; jQuery('#'+id+' .textboxlist').css('overflow','hidden'); jQuery('#'+id+' .close').hide(); if (eff) jQuery('#'+id+' .textboxlist-bits').css(eff); jQuery('#'+id+' .textboxlist').addClass(id+'-closed'); jQuery('.mail-content-closed').scrollTop(0); return false; } var showBitBox = function showBitBox(id, eff) { jQuery('#'+id+' .textboxlist').removeClass(id+'-closed'); if (eff == undefined) eff = {}; if (jQuery('#'+id+' .textboxlist-bits').height() > 40 || (navigator.userAgent.match('MSIE 6') && jQuery('#'+id+' .textboxlist-bit-box').size() > 0) ) { jQuery('#'+id+' .textboxlist').css('overflow','visible'); jQuery('#'+id+' .close').show(); if (eff) jQuery('#'+id+' .textboxlist-bits').css(eff); jQuery('#'+id+' .textboxlist-bit-editable-input').get(0).focus(); } } var createTextBoxList = function createTextBoxList(selector) { return new $.TextboxList(selector, {bitsOptions:{editable:{addKeys: [188,13,32]}}, inBetweenEditableBits: false, startEditableBit: false}); } var addEmailBit = function addEmailBit(b) { var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; if (b.getValue()[1]=='' || !reg.test(b.getValue()[1])) { if (b.type != 'editable') { b.remove(); } else { b.toElement().find('input').val(''); } _bit_added = false; } else { if (b.type != 'editable') { if (b.getValue()[0] != 'no-open') showBitBox('mail-content', {borderBottom:'5px solid #fff'}); else hideBitBox('mail-content', {borderBottom:'none'}); var text = b.toElement().find('span').html(); b.toElement().find('span').html(truncate(text,34)); } else { var text = b.getValue()[1]; text = truncate(text,34); t.add(text, '', ''); b.toElement().find('input').val(''); b.toElement().find('input').get(0).blur(); hideBitBox('mail-content', {borderBottom:'none'}); } } } var _bit_added = false; var initMail = function initMail() { // initialize plugin for sendmail box t = createTextBoxList('#socialize_mail_email'); t.addEvent('bitBoxAdd', function(b) { if (!_bit_added) addEmailBit(b); else _bit_added = false; }); t.addEvent('bitEditableBlur', function(b) { _bit_added = true; addEmailBit(b); }); t.addEvent('bitEditableFocus', function(b) { showBitBox('mail-content', {borderBottom:'5px solid #fff'}) }); t.addEvent('bitRemove', function() { if (jQuery('.textboxlist-bit-box').size() == 0) jQuery('#mail-content .close').hide(); }); jQuery('#mail-content .textboxlist').click(function() { showBitBox('mail-content', {borderBottom:'5px solid #fff'}) }); jQuery('#mail-content .close').click(function(ev) { ev.stopPropagation(); ev.preventDefault(); hideBitBox('mail-content', {borderBottom:'none'})}); jQuery('#socialize_mail_message').focus(function() { hideBitBox('mail-content', {borderBottom:'none'})}); } var activateScrollPane = function activateScrollPane(el) { el.jScrollPane({scrollbarWidth: 16, showArrows: true}); } var initScrolls = function initScrolls() { // initialize scrolls if (type == 'comment') { activateScrollPane(jQuery('#comment-content .comment-list')); } if (type == 'tag') { activateScrollPane(jQuery('#tag-content .scrolltag')); } } var addTagBit = function addTagBit(b) { var reg = /[^a-zùàòèéìÙÀÒÈÉÌA-Z0-9]+/; if (b.getValue()[1]=='' || reg.test(b.getValue()[1]) || b.getValue()[1].length < 3 || b.getValue()[1].length > 15) { if (b.type != 'editable') { b.remove(); } else { b.toElement().find('input').val(''); } _tagbit_added = false; } else { var reg2 = eval('/-'+b.getValue()[1].toUpperCase()+'-/g'); var val = '--'+jQuery('#socialize_tags_tags').val().toUpperCase().replace(/,/g,'--')+'--'; if (val.match(reg2) && val.match(reg2).length > 1) { if (b.type != 'editable') { b.remove(); } else { b.toElement().find('input').val(''); } _tagbit_added = false; } if (b.type != 'editable') { showBitBox('tag-content'); var text = b.toElement().find('span').html(); b.toElement().find('span').html(truncate(text.toUpperCase(),50)); } else { var text = b.getValue()[1]; text = truncate(text.toUpperCase(),50); tags.add(text, '', ''); b.toElement().find('input').val(''); b.toElement().find('input').get(0).blur(); hideBitBox('tag-content'); } } } var _tagbit_added = false; var initTags = function initTags() { if (jQuery('#socialize_tags_tags').size() > 0) { tags = createTextBoxList('#socialize_tags_tags'); tags.addEvent('bitBoxAdd', function(b) { if (!_tagbit_added) addTagBit(b); else _tagbit_added = false; }); tags.addEvent('bitEditableBlur', function(b) { _tagbit_added = true; addTagBit(b); }); tags.addEvent('bitRemove', function() { if (jQuery('#tag-content .textboxlist-bits').height() < 40) hideBitBox('tag-content'); }); tags.addEvent('bitEditableFocus', function() { showBitBox('tag-content') }); jQuery('#tag-content .close').click(function(ev) { ev.stopPropagation(); ev.preventDefault(); hideBitBox('tag-content')}); jQuery('#tag-content ul li a, #tag-content .scrolltag a').click(function() { var text = (jQuery(this).find('span').size() > 0) ? jQuery(this).find('span:last').html() : jQuery(this).html(); if (!$.string(jQuery('#socialize_tags_tags').val()).include(text)) tags.add(text, '', ''); return false; }); } if (_typeface_js) _typeface_js.renderDocument( function(e) { e.style.visibility = 'visible' }); } var initShare = function initShare() { jQuery('#share-content .arrow-black').live('click', function() { if (jQuery(this).parents('.more').size() > 0) { jQuery('#share-content .main').show(); jQuery('#share-content .more').hide(); } else { jQuery('#share-content .main').hide(); jQuery('#share-content .more').show(); } return false; }); } var initFonts = function initFonts() { if (_typeface_js) _typeface_js.renderDocument( function(e) { e.style.visibility = 'visible' }); jQuery('#tag').bind('click', initFonts); jQuery('#comment').bind('click', initFonts); }