<tfoot id='YaDD7'></tfoot>
  • <legend id='YaDD7'><style id='YaDD7'><dir id='YaDD7'><q id='YaDD7'></q></dir></style></legend>
    • <bdo id='YaDD7'></bdo><ul id='YaDD7'></ul>

      <small id='YaDD7'></small><noframes id='YaDD7'>

      1. <i id='YaDD7'><tr id='YaDD7'><dt id='YaDD7'><q id='YaDD7'><span id='YaDD7'><b id='YaDD7'><form id='YaDD7'><ins id='YaDD7'></ins><ul id='YaDD7'></ul><sub id='YaDD7'></sub></form><legend id='YaDD7'></legend><bdo id='YaDD7'><pre id='YaDD7'><center id='YaDD7'></center></pre></bdo></b><th id='YaDD7'></th></span></q></dt></tr></i><div id='YaDD7'><tfoot id='YaDD7'></tfoot><dl id='YaDD7'><fieldset id='YaDD7'></fieldset></dl></div>

        Trello 如何访问用户的剪贴板?

        How does Trello access the user#39;s clipboard?(Trello 如何访问用户的剪贴板?)

        <small id='a6Xlf'></small><noframes id='a6Xlf'>

        <i id='a6Xlf'><tr id='a6Xlf'><dt id='a6Xlf'><q id='a6Xlf'><span id='a6Xlf'><b id='a6Xlf'><form id='a6Xlf'><ins id='a6Xlf'></ins><ul id='a6Xlf'></ul><sub id='a6Xlf'></sub></form><legend id='a6Xlf'></legend><bdo id='a6Xlf'><pre id='a6Xlf'><center id='a6Xlf'></center></pre></bdo></b><th id='a6Xlf'></th></span></q></dt></tr></i><div id='a6Xlf'><tfoot id='a6Xlf'></tfoot><dl id='a6Xlf'><fieldset id='a6Xlf'></fieldset></dl></div>
        <legend id='a6Xlf'><style id='a6Xlf'><dir id='a6Xlf'><q id='a6Xlf'></q></dir></style></legend>
          <tfoot id='a6Xlf'></tfoot>

                <tbody id='a6Xlf'></tbody>
                  <bdo id='a6Xlf'></bdo><ul id='a6Xlf'></ul>
                  本文介绍了Trello 如何访问用户的剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  When you hover over a card in Trello and press Ctrl+C, the URL of this card is copied to the clipboard. How do they do this?

                  As far as I can tell, there is no Flash movie involved. I've got Flashblock installed, and the Firefox network tab shows no Flash movie loaded. (That's the usual method, for example, by ZeroClipboard.)

                  How do they achieve this magic?

                  (Right at this moment I think I had an epiphany: You cannot select text on the page, so I assume they have an invisible element, where they create a text selection via JavaScript code, and Ctrl+C triggers the browser's default behaviour, copying that invisible node's text value.)

                  解决方案

                  Disclosure: I wrote the code that Trello uses; the code below is the actual source code Trello uses to accomplish the clipboard trick.


                  We don't actually "access the user's clipboard", instead we help the user out a bit by selecting something useful when they press Ctrl+C.

                  Sounds like you've figured it out; we take advantage of the fact that when you want to hit Ctrl+C, you have to hit the Ctrl key first. When the Ctrl key is pressed, we pop in a textarea that contains the text we want to end up on the clipboard, and select all the text in it, so the selection is all set when the C key is hit. (Then we hide the textarea when the Ctrl key comes up.)

                  Specifically, Trello does this:

                  TrelloClipboard = new class
                    constructor: ->
                      @value = ""
                  
                      $(document).keydown (e) =>
                        # Only do this if there's something to be put on the clipboard, and it
                        # looks like they're starting a copy shortcut
                        if !@value || !(e.ctrlKey || e.metaKey)
                          return
                  
                        if $(e.target).is("input:visible,textarea:visible")
                          return
                  
                        # Abort if it looks like they've selected some text (maybe they're trying
                        # to copy out a bit of the description or something)
                        if window.getSelection?()?.toString()
                          return
                  
                        if document.selection?.createRange().text
                          return
                  
                        _.defer =>
                          $clipboardContainer = $("#clipboard-container")
                          $clipboardContainer.empty().show()
                          $("<textarea id='clipboard'></textarea>")
                          .val(@value)
                          .appendTo($clipboardContainer)
                          .focus()
                          .select()
                  
                      $(document).keyup (e) ->
                        if $(e.target).is("#clipboard")
                          $("#clipboard-container").empty().hide()
                  
                    set: (@value) ->
                  

                  In the DOM we've got:

                  <div id="clipboard-container"><textarea id="clipboard"></textarea></div>
                  

                  CSS for the clipboard stuff:

                  #clipboard-container {
                    position: fixed;
                    left: 0px;
                    top: 0px;
                    width: 0px;
                    height: 0px;
                    z-index: 100;
                    display: none;
                    opacity: 0;
                  }
                  #clipboard {
                    width: 1px;
                    height: 1px;
                    padding: 0px;
                  }
                  

                  ... and the CSS makes it so you can't actually see the textarea when it pops in ... but it's "visible" enough to copy from.

                  When you hover over a card, it calls

                  TrelloClipboard.set(cardUrl)
                  

                  ... so then the clipboard helper knows what to select when the Ctrl key is pressed.

                  这篇关于Trello 如何访问用户的剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                    <i id='CXxbt'><tr id='CXxbt'><dt id='CXxbt'><q id='CXxbt'><span id='CXxbt'><b id='CXxbt'><form id='CXxbt'><ins id='CXxbt'></ins><ul id='CXxbt'></ul><sub id='CXxbt'></sub></form><legend id='CXxbt'></legend><bdo id='CXxbt'><pre id='CXxbt'><center id='CXxbt'></center></pre></bdo></b><th id='CXxbt'></th></span></q></dt></tr></i><div id='CXxbt'><tfoot id='CXxbt'></tfoot><dl id='CXxbt'><fieldset id='CXxbt'></fieldset></dl></div>

                      <tbody id='CXxbt'></tbody>
                      • <bdo id='CXxbt'></bdo><ul id='CXxbt'></ul>
                        <legend id='CXxbt'><style id='CXxbt'><dir id='CXxbt'><q id='CXxbt'></q></dir></style></legend>

                            <tfoot id='CXxbt'></tfoot>
                          1. <small id='CXxbt'></small><noframes id='CXxbt'>