Skip to content

Commit

Permalink
Added options method to update init options at run time
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Bryson committed Mar 23, 2013
1 parent a2e329c commit 9ad0b2c
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ https://github.com/cowgp/xui-touchSwipe
- Added support for events binding with on / off / bind in jQ for all callback names.
- Deprecated the 'click' handler in favour of tap.
- added cancelThreshold property
- added 'option' method to update init options at runtime
* **1.6.1** *2013-02-12*
- Added support for ie8 touch events
* **1.6.0** *2013-01-12*
Expand Down
2 changes: 1 addition & 1 deletion docs/files.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h1 class="classTitle">File Index</h1>
</div>
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
<script type="text/javascript">
<!--
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ <h1 class="classTitle">Class Index</h1>
</div>
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ <h3>Constructor</h3>
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.swipe.defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ <h4>Instance Properties<span class="jsdoc-inherits-caption pull-right">Defined B
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.swipe.directions.html
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ <h4>Instance Properties<span class="jsdoc-inherits-caption pull-right">Defined B
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.swipe.fingers.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ <h4>Instance Properties<span class="jsdoc-inherits-caption pull-right">Defined B
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
69 changes: 68 additions & 1 deletion docs/symbols/$.fn.swipe.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,73 @@ <h4>Instance Methods<span class="jsdoc-inherits-caption pull-right">Defined By</
</div>
</div>

<div class="jsdoc-member accordion-button">
<div class="jsdoc-member-definition">
<div class="jsdoc-member-content">
<b><a id="option" href="../symbols/%24.fn.swipe.html#option">option</a></b>
<span class="signature">( <span class="jsdoc-typedesc">String</span> property, [<span class="jsdoc-typedesc">Object</span> value] )</span>
: <span class="jsdoc-typedesc">Object</span>




<span class="jsdoc-inherits-from pull-right"><a href="../symbols/%24.fn.swipe.html">$.fn.swipe</a></span>
</div>
</div>
<div class="jsdoc-member-description">
<div class="jsdoc-member-content">
<div class="jsdoc-member-summary">
Allows run time updating of the swipe configuration options.
<span class="pull-right"><a href="../symbols/src/jquery.touchSwipe.js.html">code »</a></span>
</div>


<pre class="prettyprint linenums">$("#element").swipe("option", "threshold"); // return the threshold</pre>

<pre class="prettyprint linenums">$("#element").swipe("option", "threshold", 100); // set the threshold after init</pre>






<div class="jsdoc-member-see jsdoc-member-info">
<span class="label label-jsdoc label-jsdoc-see">See</span>

<span class="jsdoc-symbol-enum"><a href="../symbols/%24.fn.swipe.defaults.html">$.fn.swipe.defaults</a></span>

</div>



<div class="jsdoc-member-detail accordion-content">

<b>Parameters</b>
<dl>

<dt>property : <span class="jsdoc-typedesc">String</span> </dt>
<dd>The option property to get or set</dd>

<dt>value : <span class="jsdoc-typedesc">Object</span> </dt>
<dd>The value to set the property to</dd>

</dl>


<b>Returns</b>
<dl>

<dt><span class="jsdoc-typedesc">Object</span></dt>
<dd>If only a property name is passed, then that property value is returned.</dd>

</dl>

</div>

</div>
</div>
</div>

</div>


Expand Down Expand Up @@ -1138,7 +1205,7 @@ <h3>Events<span class="jsdoc-inherits-caption pull-right">Defined By</span></h3>
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.swipe.pageScroll.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ <h4>Instance Properties<span class="jsdoc-inherits-caption pull-right">Defined B
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.fn.swipe.phases.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ <h4>Instance Properties<span class="jsdoc-inherits-caption pull-right">Defined B
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/$.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ <h3>Constructor</h3>
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
2 changes: 1 addition & 1 deletion docs/symbols/_global_.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div></body>
</html>
42 changes: 31 additions & 11 deletions docs/symbols/src/jquery.touchSwipe.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,13 @@
* - added jsDoc comments and added documentation for the plugin
* - code tidy
* - added triggerOnTouchLeave property that will end the event when the user swipes off the element.
&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD
* $Date: 2013-03-23 (Sat, 23 Mar 2013) $
* $version: 1.6.1 - Added support for ie8 touch events
* $version: 1.6.2 - Added support for events binding with on / off / bind in jQ for all callback names.
* - Deprecated the 'click' handler in favour of tap.
=======
* $version: 1.6.1 - Added support for ie8
* $Date: 2013-03-23 (Sat, 23 Mar 2013) $
* $version: 1.6.2 - more IE8 fixes
- added events as well as callbacks, so all callbacks can be used with on/bind etc
- added cancelThreshold property
&gt;&gt;&gt;&gt;&gt;&gt;&gt; master
* - added cancelThreshold property
* - added option method to update init options at runtime
*
*/

/**
Expand Down Expand Up @@ -408,7 +404,7 @@
var plugin = $this.data(PLUGIN_NS);

if (!plugin) {
plugin = new touchSwipe(this, options);
plugin = new TouchSwipe(this, options);
$this.data(PLUGIN_NS, plugin);
}
});
Expand All @@ -425,7 +421,7 @@
* @see $.fh.swipe
* @class
*/
function touchSwipe(element, options) {
function TouchSwipe(element, options) {
var useTouchEvents = (SUPPORTS_TOUCH || !options.fallbackToMouseEvents),
START_EV = useTouchEvents ? 'touchstart' : 'mousedown',
MOVE_EV = useTouchEvents ? 'touchmove' : 'mousemove',
Expand Down Expand Up @@ -518,6 +514,30 @@
};


/**
* Allows run time updating of the swipe configuration options.
* @function
* @name $.fn.swipe#option
* @param {String} property The option property to get or set
* @param {Object} [value] The value to set the property to
* @return {Object} If only a property name is passed, then that property value is returned.
* @example $("#element").swipe("option", "threshold"); // return the threshold
* @example $("#element").swipe("option", "threshold", 100); // set the threshold after init
* @see $.fn.swipe.defaults
*
*/
this.option = function (property, value) {
if(options[property]!==undefined) {
if(value===undefined) {
return options[property];
} else {
options[property] = value;
}
} else {
$.error('Option ' + property + ' does not exist on jQuery.swipe.options');
}
}

//
// Private methods
//
Expand Down Expand Up @@ -1779,7 +1799,7 @@
<!-- ============================== footer ================================= -->
<footer class="footer">

<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 17:50:52 GMT-0000 (GMT)</p>
<p>Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Mar 23 2013 19:47:13 GMT-0000 (GMT)</p>
</footer>
</div>
<script type="text/javascript">
Expand Down
31 changes: 28 additions & 3 deletions jquery.touchSwipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
* $version: 1.6.1 - Added support for ie8 touch events
* $version: 1.6.2 - Added support for events binding with on / off / bind in jQ for all callback names.
* - Deprecated the 'click' handler in favour of tap.
* - added cancelThreshold property
* - added cancelThreshold property
* - added option method to update init options at runtime
*
*/

Expand Down Expand Up @@ -332,7 +333,7 @@
var plugin = $this.data(PLUGIN_NS);

if (!plugin) {
plugin = new touchSwipe(this, options);
plugin = new TouchSwipe(this, options);
$this.data(PLUGIN_NS, plugin);
}
});
Expand All @@ -349,7 +350,7 @@
* @see $.fh.swipe
* @class
*/
function touchSwipe(element, options) {
function TouchSwipe(element, options) {
var useTouchEvents = (SUPPORTS_TOUCH || !options.fallbackToMouseEvents),
START_EV = useTouchEvents ? 'touchstart' : 'mousedown',
MOVE_EV = useTouchEvents ? 'touchmove' : 'mousemove',
Expand Down Expand Up @@ -442,6 +443,30 @@
};


/**
* Allows run time updating of the swipe configuration options.
* @function
* @name $.fn.swipe#option
* @param {String} property The option property to get or set
* @param {Object} [value] The value to set the property to
* @return {Object} If only a property name is passed, then that property value is returned.
* @example $("#element").swipe("option", "threshold"); // return the threshold
* @example $("#element").swipe("option", "threshold", 100); // set the threshold after init
* @see $.fn.swipe.defaults
*
*/
this.option = function (property, value) {
if(options[property]!==undefined) {
if(value===undefined) {
return options[property];
} else {
options[property] = value;
}
} else {
$.error('Option ' + property + ' does not exist on jQuery.swipe.options');
}
}

//
// Private methods
//
Expand Down
Loading

0 comments on commit 9ad0b2c

Please sign in to comment.