1
0
Fork 0

Fix new private message recipient input

- Add new private message recipient ACL template
- Remove now redundant theme private message templates
This commit is contained in:
Hypolite Petovan 2020-09-03 10:01:58 -04:00
commit 4a4d0f04cb
8 changed files with 89 additions and 192 deletions

View file

@ -0,0 +1,54 @@
<select name="recipient" class="form-control input-lg" id="recipient">
{{foreach $contacts as $contact}}
<option value="{{$contact.id}}"{{if $contact.id == $selected}} selected{{/if}}>{{$contact.name}}</option>
{{/foreach}}
</select>
<script type="text/javascript">
$(function() {
let $recipient_input = $('[name="recipient"]');
let acl = new Bloodhound({
local: {{$contacts|@json_encode nofilter}},
identify: function(obj) { return obj.id.toString(); },
datumTokenizer: Bloodhound.tokenizers.obj.whitespace(['name', 'addr']),
queryTokenizer: Bloodhound.tokenizers.whitespace,
sorter: function (itemA, itemB) {
if (itemA.name === itemB.name) {
return 0;
} else if (itemA.name > itemB.name) {
return 1;
} else {
return -1;
}
},
});
acl.initialize();
let suggestionTemplate = function (item) {
return '<div><img src="' + item.micro + '" alt="" style="float: left; width: auto; height: 2.8em; margin-right: 0.5em;"><p style="margin-left: 3.3em;"><strong>' + item.name + '</strong><br /><em>' + item.addr + '</em></p></div>';
};
$recipient_input.tagsinput({
confirmKeys: [13, 44],
freeInput: false,
tagClass: 'label label-info',
itemValue: function (item) { return item.id.toString(); },
itemText: 'name',
itemThumb: 'micro',
itemTitle: function(item) {
return item.addr;
},
typeaheadjs: {
name: 'contacts',
displayKey: 'name',
templates: {
suggestion: suggestionTemplate
},
source: acl.ttAdapter()
}
});
// Import existing ACL into the tags input fields.
$recipient_input.tagsinput('add', acl.get({{$selected}})[0]);
});
</script>

View file

@ -1,8 +0,0 @@
<script>
$(document).ready(function() {
$("#recip").name_autocomplete(baseurl + '/search/acl', 'm', false, function(data) {
$("#recip-complete").val(data.id);
});
});
</script>

View file

@ -3228,9 +3228,6 @@ div.jGrowl div.info {
width:100px;
}
#recip {
}
.autocomplete-w1 { background: #ffffff no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete { color:#000; border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }
.autocomplete .selected { background:#F0F0F0; }

View file

@ -1,40 +0,0 @@
<h3>{{$header}}</h3>
<div id="prvmail-wrapper" >
<form id="prvmail-form" action="message" method="post" >
{{$parent nofilter}}
<div id="prvmail-to-label">{{$to}}</div>
{{if $showinputs}}
<input type="text" id="recip" name="messagerecip" value="{{$prefill}}" maxlength="255" size="64" tabindex="10" />
<input type="hidden" id="recip-complete" name="messageto" value="{{$preid}}">
{{else}}
{{$select nofilter}}
{{/if}}
<div id="prvmail-subject-label">{{$subject}}</div>
<input type="text" size="64" maxlength="255" id="prvmail-subject" name="subject" value="{{$subjtxt}}" {{$readonly}} tabindex="11" />
<div id="prvmail-message-label">{{$yourmessage}}</div>
<textarea rows="8" cols="72" class="prvmail-text" id="prvmail-text" name="body" tabindex="12">{{$text}}</textarea>
<div id="prvmail-submit-wrapper" >
<input type="submit" id="prvmail-submit" name="submit" value="{{$submit}}" tabindex="13" />
<div id="prvmail-upload-wrapper" >
<div id="prvmail-upload" class="icon border camera" title="{{$upload}}" ></div>
</div>
<div id="prvmail-link-wrapper" >
<div id="prvmail-link" class="icon border link" title="{{$insert}}" onclick="jotGetLink();" ></div>
</div>
<div id="prvmail-rotator-wrapper" >
<img id="prvmail-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" />
</div>
</div>
<div id="prvmail-end"></div>
</form>
</div>

View file

@ -2,21 +2,12 @@
<div id="prvmail-wrapper">
<form id="prvmail-form" action="message" method="post" >
{{* Disable the header. We will see if we will need it
<h3>{{$header}}</h3>
*}}
{{$parent nofilter}}
{{* The To: form-group which contains the message recipient *}}
<div id="prvmail-to-label" class="form-group">
<label for="recip">{{$to}}</label><br>
{{if $showinputs}}
<input type="text" id="recip" class="form-control" name="messagerecip" value="{{$prefill}}" tabindex="10" {{if $prefill}}disabled{{else}}aria-required="true"{{/if}} />
<input type="hidden" id="recip-complete" name="messageto" value="{{$preid}}">
{{else}}
<label for="recipient">{{$to}}</label><br>
{{$select nofilter}}
{{/if}}
</div>
{{* The subject input field *}}

View file

@ -1,37 +0,0 @@
<h3>{{$header}}</h3>
<div id="prvmail-wrapper" >
<form id="prvmail-form" action="message" method="post" >
{{$parent nofilter}}
<div id="prvmail-to-label">{{$to}}</div>
{{if $showinputs}}
<input type="text" id="recip" name="messagerecip" value="{{$prefill}}" maxlength="255" size="64" tabindex="10" />
<input type="hidden" id="recip-complete" name="messageto" value="{{$preid}}">
{{else}}
{{$select nofilter}}
{{/if}}
<div id="prvmail-subject-label">{{$subject}}</div>
<input type="text" size="64" maxlength="255" id="prvmail-subject" name="subject" value="{{$subjtxt}}" {{$readonly}} tabindex="11" />
<div id="prvmail-message-label">{{$yourmessage}}</div>
<textarea rows="20" cols="72" class="prvmail-text" id="prvmail-text" name="body" tabindex="12">{{$text}}</textarea>
<div id="prvmail-submit-wrapper" >
<input type="submit" id="prvmail-submit" name="submit" value="{{$submit}}" tabindex="13" />
<div id="prvmail-upload-wrapper" >
<div id="prvmail-upload" class="icon border camera" title="{{$upload}}" ></div>
</div>
<div id="prvmail-link-wrapper" >
<div id="prvmail-link" class="icon border link" title="{{$insert}}" onclick="jotGetLink();" ></div>
</div>
<div id="prvmail-rotator-wrapper" >
<img id="prvmail-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" />
</div>
</div>
<div id="prvmail-end"></div>
</form>
</div>