| 1 |
/** |
| 2 |
* Auto prepend `LP` prefix for jQuery fn plugin name. |
| 3 |
* |
| 4 |
* Create : $.fn.LP( 'PLUGIN_NAME', func) <=> $.fn.LP_PLUGIN_NAME |
| 5 |
* Usage: $(selector).LP('PLUGIN_NAME') <=> $(selector).LP_PLUGIN_NAME() |
| 6 |
* |
| 7 |
* @version 3.2.6 |
| 8 |
*/ |
| 9 |
|
| 10 |
const $ = window.jQuery; |
| 11 |
let exp; |
| 12 |
|
| 13 |
( function() { |
| 14 |
if ( $ === undefined ) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
$.fn.LP = exp = function( widget, fn ) { |
| 19 |
if ( typeof fn === 'function' ) { |
| 20 |
$.fn[ 'LP_' + widget ] = fn; |
| 21 |
} else if ( widget ) { |
| 22 |
const args = []; |
| 23 |
if ( arguments.length > 1 ) { |
| 24 |
for ( let i = 1; i < arguments.length; i++ ) { |
| 25 |
args.push( arguments[ i ] ); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
return typeof ( $( this )[ 'LP_' + widget ] ) === 'function' ? $( this )[ 'LP_' + widget ].apply( this, args ) : this; |
| 30 |
} |
| 31 |
return this; |
| 32 |
}; |
| 33 |
}() ); |
| 34 |
|
| 35 |
export default exp; |
| 36 |
|