{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
{/if}
- <dl>
- <dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
- <dd>
- <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
- </dd>
- </dl>
- {if $availableLanguages|count > 1}
- {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
- {/if}
+ {if $media->isImage}
+ <dl>
+ <dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
+ <dd>
+ <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
+ </dd>
+ </dl>
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
- <dl>
- <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
- <dd>
- <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
- </dd>
- </dl>
- {if $availableLanguages|count > 1}
- {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ <dl>
+ <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
+ <dd>
+ <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
+ </dd>
+ </dl>
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
{/if}
{event name='dataFields'}
{include file='multipleLanguageInputJavascript' elementIdentifier='title'|concat:'_':$media->mediaID forceSelection=true}
{/if}
- <dl>
- <dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
- <dd>
- <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
- </dd>
- </dl>
- {if $availableLanguages|count > 1}
- {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
- {/if}
-
- <dl>
- <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
- <dd>
- <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
- </dd>
- </dl>
- {if $availableLanguages|count > 1}
- {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {if $media->isImage}
+ <dl>
+ <dt><label for="caption_{@$media->mediaID}">{lang}wcf.media.caption{/lang}</label></dt>
+ <dd>
+ <textarea id="caption_{@$media->mediaID}" name="caption" cols="40" rows="3"></textarea>
+ </dd>
+ </dl>
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='caption'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
+
+ <dl>
+ <dt><label for="altText_{@$media->mediaID}">{lang}wcf.media.altText{/lang}</label></dt>
+ <dd>
+ <input type="text" id="altText_{@$media->mediaID}" name="altText" class="long">
+ </dd>
+ </dl>
+ {if $availableLanguages|count > 1}
+ {include file='multipleLanguageInputJavascript' elementIdentifier='altText'|concat:'_':$media->mediaID forceSelection=true}
+ {/if}
{/if}
{event name='dataFields'}
var title = elBySel('input[name=title]', content);
var hasError = false;
- var altTextError = DomTraverse.childByClass(altText.parentNode.parentNode, 'innerError');
- var captionError = DomTraverse.childByClass(caption.parentNode.parentNode, 'innerError');
+ var altTextError = (altText ? DomTraverse.childByClass(altText.parentNode.parentNode, 'innerError') : false);
+ var captionError = (caption ? DomTraverse.childByClass(caption.parentNode.parentNode, 'innerError') : false);
var titleError = DomTraverse.childByClass(title.parentNode.parentNode, 'innerError');
if (this._availableLanguageCount > 1) {
this._media.caption = {};
this._media.title = {};
if (this._availableLanguageCount > 1 && this._media.isMultilingual) {
- if (!LanguageInput.validate('altText_' + this._media.mediaID, true)) {
+ if (elById('altText_' + this._media.mediaID) && !LanguageInput.validate('altText_' + this._media.mediaID, true)) {
hasError = true;
if (!altTextError) {
var error = elCreate('small');
altText.parentNode.parentNode.appendChild(error);
}
}
- if (!LanguageInput.validate('caption_' + this._media.mediaID, true)) {
+ if (elById('caption_' + this._media.mediaID) && !LanguageInput.validate('caption_' + this._media.mediaID, true)) {
hasError = true;
if (!captionError) {
var error = elCreate('small');
}
}
- this._media.altText = LanguageInput.getValues('altText_' + this._media.mediaID).toObject();
- this._media.caption = LanguageInput.getValues('caption_' + this._media.mediaID).toObject();
+ this._media.altText = (elById('altText_' + this._media.mediaID) ? LanguageInput.getValues('altText_' + this._media.mediaID).toObject() : '');
+ this._media.caption = (elById('caption_' + this._media.mediaID) ? LanguageInput.getValues('caption_' + this._media.mediaID).toObject() : '');
this._media.title = LanguageInput.getValues('title_' + this._media.mediaID).toObject();
}
else {
- this._media.altText[this._media.languageID] = altText.value;
- this._media.caption[this._media.languageID] = caption.value;
+ this._media.altText[this._media.languageID] = (altText ? altText.value : '');
+ this._media.caption[this._media.languageID] = (caption ? caption.value : '');
this._media.title[this._media.languageID] = title.value;
}
if (element.checked) {
LanguageInput.enable('title_' + this._media.mediaID);
- LanguageInput.enable('caption_' + this._media.mediaID);
- LanguageInput.enable('altText_' + this._media.mediaID);
+ if (elById('caption_' + this._media.mediaID)) LanguageInput.enable('caption_' + this._media.mediaID);
+ if (elById('altText_' + this._media.mediaID)) LanguageInput.enable('altText_' + this._media.mediaID);
elHide(languageChooserContainer);
}
else {
LanguageInput.disable('title_' + this._media.mediaID);
- LanguageInput.disable('caption_' + this._media.mediaID);
- LanguageInput.disable('altText_' + this._media.mediaID);
+ if (elById('caption_' + this._media.mediaID)) LanguageInput.disable('caption_' + this._media.mediaID);
+ if (elById('altText_' + this._media.mediaID)) LanguageInput.disable('altText_' + this._media.mediaID);
elShow(languageChooserContainer);
}
var title = elBySel('input[name=title]', content);
var altText = elBySel('input[name=altText]', content);
+ var caption = elBySel('textarea[name=caption]', content);
if (this._availableLanguageCount > 1 && this._media.isMultilingual) {
- LanguageInput.setValues('altText_' + this._media.mediaID, Dictionary.fromObject(this._media.altText || { }));
- LanguageInput.setValues('caption_' + this._media.mediaID, Dictionary.fromObject(this._media.caption || { }));
+ if (elById('altText_' + this._media.mediaID)) LanguageInput.setValues('altText_' + this._media.mediaID, Dictionary.fromObject(this._media.altText || { }));
+ if (elById('caption_' + this._media.mediaID)) LanguageInput.setValues('caption_' + this._media.mediaID, Dictionary.fromObject(this._media.caption || { }));
LanguageInput.setValues('title_' + this._media.mediaID, Dictionary.fromObject(this._media.title || { }));
}
else {
title.value = this._media.title ? this._media.title[LANGUAGE_ID] : '';
- altText.value = this._media.altText ? this._media.altText[LANGUAGE_ID] : '';
- elBySel('textarea[name=caption]', content).value = this._media.caption ? this._media.caption[LANGUAGE_ID] : '';
+ if (altText) altText.value = this._media.altText ? this._media.altText[LANGUAGE_ID] : '';
+ if (caption) caption.value = this._media.caption ? this._media.caption[LANGUAGE_ID] : '';
}
if (this._availableLanguageCount > 1) {
}
var keyPress = this._keyPress.bind(this);
- altText.addEventListener('keypress', keyPress);
+ if (altText) altText.addEventListener('keypress', keyPress);
title.addEventListener('keypress', keyPress);
elBySel('button[data-type=submit]', content).addEventListener(WCF_CLICK_EVENT, this._saveData.bind(this));