Implement simple button code copying

This commit is contained in:
Fedor A. Fetisov 2021-08-28 03:40:34 +03:00
parent 06078cc8e7
commit 01261f8c92
4 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,26 @@
/*!
* This file is a part of Mibew Messenger.
*
* Copyright 2005-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(Mibew, $) {
$(document).ready(function(){
$('#copy-button-code').click(function(e){
$("#button-code").select();
document.execCommand('copy');
});
});
})(Mibew, jQuery);

View File

@ -48,6 +48,8 @@ class ButtonCodeController extends AbstractController
'errors' => array(),
);
$this->getAssetManager()->attachJs('js/compiled/button_code.js');
$image_locales_map = $this->getImageLocalesMap(MIBEW_FS_ROOT . '/locales');
$image = $request->query->get('i', 'mibew');
if (!isset($image_locales_map[$image])) {

View File

@ -145,6 +145,7 @@
<textarea id="button-code" cols="44" rows="15">{{buttonCode}}</textarea>
</div>
<label for="button-code" class="field-description">{{l10n "<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!"}}</label>
<button id="copy-button-code">{{l10n "Copy button code"}}</button>
<br clear="all"/>
</div>

View File

@ -145,6 +145,7 @@
<textarea id="button-code" cols="44" rows="15">{{buttonCode}}</textarea>
</div>
<label for="button-code" class="field-description">{{l10n "<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> it will work!"}}</label>
<button id="copy-button-code">{{l10n "Copy button code"}}</button>
<br clear="all"/>
</div>