Excluded_children.html 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
  5. <meta http-equiv="x-ua-compatible" content="IE=9">
  6. <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
  7. <link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" />
  8. <link href="css/main.css" type="text/css" rel="stylesheet" />
  9. <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  10. <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
  11. <script type="text/javascript" src="../jquery.touchSwipe.js"></script>
  12. <script type="text/javascript" src="js/main.js"></script>
  13. <title>touchSwipe</title>
  14. </head>
  15. <body>
  16. <a href="https://github.com/mattbryson"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub"></a>
  17. <div class="container">
  18. <script id='code_1'>
  19. $(function() {
  20. var swipeCount1=0;
  21. var swipeCount2=0;
  22. $("#test").swipe( {
  23. swipe:function() {
  24. swipeCount1++;
  25. $("#textText1").html("You swiped " + swipeCount1 + " times");
  26. }
  27. //By default any element with a class .noSwipe is not swipeable
  28. });
  29. //Enable swiping...
  30. $("#test2").swipe( {
  31. swipe:function() {
  32. swipeCount2++;
  33. $("#textText2").html("You swiped " + swipeCount2 + " times");
  34. },
  35. //By default the value of $.fn.swipe.defaults.excludedElements is ".noSwipe"
  36. //To replace or clear the list, re set the excludedElements array.
  37. //To append to it, do the following (dont forget the proceeding comma) ...
  38. excludedElements:$.fn.swipe.defaults.excludedElements+", #some_other_div"
  39. });
  40. });
  41. </script>
  42. <span class='title'></span>
  43. <h4>property: <span class='properties'><code>excludedElements</code></span></h4>
  44. <p>If you want to exclude certain child elements from triggering swipes, you can simply add a <code>.noSwipe</code> class to the element. Then the element and any of its children will no longer trigger the swipe.
  45. <p>Also, a jQuery selector is used to exclude input elements as well as the <code>.noSwipe</code> elements.
  46. So either add a <code>.noSwipe</code> class the element, or set your own selector in the excludedElements property. Setting your own selector will remove the .noSwipe selector.
  47. </p>
  48. <button class='btn btn-small btn-info example_btn'>Jump to Example</button>
  49. <pre class="prettyprint lang-js" data-src='code_1'></pre>
  50. <span class='navigation'></span>
  51. <div id="test" class="box">
  52. <div id="textText1">Swipe me, the child elements will not trigger swipes by default</div><br/>
  53. <small></smal><a href="http://www.google.com" target="new" >I open a new tab if clicked, but im swipeable</a></small>
  54. <form>
  55. <input type="text" value="I am clickable and swipeable" />
  56. <input type="button" value="I am clickable and swipeable" />
  57. <textarea>I am clickable and swipeable</textarea>
  58. </form>
  59. <div id="another_div" class="box noSwipe" style="width:400px;height:100px;background:#000"><h3>Im am NOT swipeable because my class is .noSwipe</h3></div>
  60. </div>
  61. <div id="test2" class="box">
  62. <div id="textText2">Swipe me, the child elements will not trigger swipes as they have been explicitly excluded</div><br/>
  63. <div id="some_other_div" class="box" style="width:400px;height:100px;background:#000"><h3>Im am NOT swipeable because my im added to the excludedElements array</h3></div>
  64. </div>
  65. <span class='navigation'></span>
  66. </div>
  67. </body>
  68. </html>