Added maxlength attribute to post source

This commit is contained in:
Marcin Kurczewski 2014-06-20 18:44:08 +02:00
parent fe451af7be
commit 6cacb90eef
4 changed files with 15 additions and 2 deletions

View file

@ -199,7 +199,12 @@ $(function()
{
postDom.data('url', url);
postDom.data('file', '');
postDom.find('[name=source]').val(url);
var sourceInput = postDom.find('[name=source]');
sourceInput.val(url);
if (sourceInput.attr('maxlength'))
sourceInput.val(sourceInput.val().substring(0, sourceInput.attr('maxlength')));
if (matches = url.match(/watch.*?=([a-zA-Z0-9_-]+)/))
{
postDom.find('.file-name strong').text(url);

View file

@ -8,6 +8,7 @@ $placeholder = isset($this->context->placeholder) ? $this->context->placeholder
$additionalInfo = isset($this->context->additionalInfo) ? $this->context->additionalInfo : '';
$inputClass = isset($this->context->inputClass) ? $this->context->inputClass : '';
$noAutocomplete = isset($this->context->noAutocomplete) ? true : false;
$maxLength = isset($this->context->maxLength) ? intval($this->context->maxLength) : null;
?>
<div class="form-row">
@ -16,6 +17,9 @@ $noAutocomplete = isset($this->context->noAutocomplete) ? true : false;
</label>
<div class="input-wrapper">
<input
<?php if ($maxLength): ?>
maxlength="<?= $maxLength ?>"
<?php endif ?>
<?php if ($noAutocomplete): ?>
autocomplete="off"
<?php endif ?>

View file

@ -56,6 +56,7 @@ $post = $this->context->transport->post;
$context = new StdClass;
$context->label = 'Source';
$context->name = 'source';
$context->maxLength = Core::getConfig()->posts->maxSourceLength;
$context->value = htmlspecialchars($post->getSource());
$this->renderExternal('input-text', $context);
}

View file

@ -115,7 +115,10 @@ $this->assets->addScript('../lib/tagit/jquery.tagit.js');
<div class="form-row source">
<label>Source:</label>
<div class="input-wrapper">
<input type="text" name="source" placeholder="where did you get this from? (optional)"/>
<input type="text"
maxlength="<?= Core::getConfig()->posts->maxSourceLength ?>"
name="source"
placeholder="where did you get this from? (optional)"/>
</div>
</div>
</form>