| @@ -543,8 +543,48 @@ | ||
| 543 | 543 | textRange.select(); |
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | + function copyQuestionIdOnClick(el) { | |
| 548 | + var $this = jQuery(el); | |
| 549 | + | |
| 550 | + // Find ID text | |
| 551 | + var text = $this.find('.ays-survey-shortcode-box').text().trim(); | |
| 552 | + | |
| 553 | + // Copy | |
| 554 | + var textField = document.createElement('textarea'); | |
| 555 | + textField.value = text; | |
| 556 | + | |
| 557 | + document.body.appendChild(textField); | |
| 558 | + | |
| 559 | + textField.select(); | |
| 560 | + textField.setSelectionRange(0, 99999); | |
| 561 | + | |
| 562 | + document.execCommand('copy'); | |
| 563 | + | |
| 564 | + document.body.removeChild(textField); | |
| 565 | + | |
| 566 | + // Tooltip | |
| 567 | + $this.attr("data-original-title", SurveyMakerAdmin.copied); | |
| 568 | + $this.attr("title", SurveyMakerAdmin.copied); | |
| 569 | + | |
| 570 | + $this.tooltip("show"); | |
| 571 | + | |
| 572 | + setTimeout(function () { | |
| 573 | + $this.tooltip("hide"); | |
| 574 | + | |
| 575 | + $this.attr( | |
| 576 | + "data-original-title", | |
| 577 | + SurveyMakerAdmin.clickForCopy | |
| 578 | + ); | |
| 579 | + | |
| 580 | + $this.attr( | |
| 581 | + "title", | |
| 582 | + SurveyMakerAdmin.clickForCopy | |
| 583 | + ); | |
| 584 | + }, 1500); | |
| 585 | + } | |
| 586 | + | |
| 547 | 587 | function selectElementContentsCopy(element) { |
| 548 | 588 | var _this = element; |
| 549 | 589 | var text = _this.attr("data-clipboard-text"); |
| 550 | 590 | var newElement = jQuery('<textarea>').appendTo('body').val(text).select(); |