*
* @param {String} tag
*/
- switchInputFormTab: function (tag) {
+ switchInputFormTab: function (tag, setFocus) {
+ if (typeof setFocus === 'undefined') { setFocus = true; }
// The one that's current isn't current anymore
$('.input_form_nav_tab.current').removeClass('current');
if (tag != null) {
return false;
}
- $('#input_form_' + tag)
+ var noticeForm = $('#input_form_' + tag)
.addClass('current')
.find('.ajax-notice').each(function () {
var form = $(this);
SN.Init.NoticeFormSetup(form);
- })
- .find('.notice_data-text').focus();
+ });
+ if (setFocus) {
+ noticeForm.find('.notice_data-text').focus();
+ }
return false;
},
// SN.Init.NoticeFormSetup() will get run
// when forms get displayed for the first time...
- // Initially show Status tab
- SN.U.switchInputFormTab("status");
+ // Initialize the input form field
+ $('#input_form_nav .input_form_nav_tab.current').each(function () {
+ current_tab_id = $(this).attr('id').substring('input_form_nav_'.length);
+ SN.U.switchInputFormTab(current_tab_id, false);
+ });
// Make inline reply forms self-close when clicking out.
$('body').on('click', function (e) {
- var currentForm = $('#content .input_forms div.current');
- if (currentForm.length > 0) {
- if ($('#content .input_forms').has(e.target).length == 0) {
- // If all fields are empty, switch back to the placeholder.
- var fields = currentForm.find('textarea, input[type=text], input[type=""]');
- var anything = false;
- fields.each(function () {
- anything = anything || $(this).val();
- });
- if (!anything) {
- SN.U.switchInputFormTab(null);
- }
- }
- }
-
var openReplies = $('li.notice-reply');
if (openReplies.length > 0) {
var target = $(e.target);