Produced by Araxis Merge on 2023-03-13 03:01:04 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v4.0.4/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/js | jquery.bridget.js | 2016-01-16 14:55:36 +0000 |
| 2 | Porto v4.0.5/Porto Theme/app/code/Smartwave/Porto/view/frontend/web/js | jquery.bridget.js | 2016-01-16 14:55:36 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 1 | 282 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | /** | 1 | /** | |||
| 2 | * Bridget makes jQuery widgets | 2 | * Bridget makes jQuery widgets | |||
| 3 | * v1.0.1 | 3 | * v1.0.1 | |||
| 4 | */ | 4 | */ | |||
| 5 | 5 | |||||
| 6 | ( function( window ) { | 6 | ( function( window ) { | |||
| 7 | 7 | |||||
| 8 | 'use strict'; | 8 | 'use strict'; | |||
| 9 | 9 | |||||
| 10 | // -------------------------- utils -------------------------- // | 10 | // -------------------------- utils -------------------------- // | |||
| 11 | 11 | |||||
| 12 | var slice = Array.prototype.slice; | 12 | var slice = Array.prototype.slice; | |||
| 13 | 13 | |||||
| 14 | function noop() {} | 14 | function noop() {} | |||
| 15 | 15 | |||||
| 16 | // -------------------------- definition -------------------------- // | 16 | // -------------------------- definition -------------------------- // | |||
| 17 | 17 | |||||
| 18 | function defineBridget( $ ) { | 18 | function defineBridget( $ ) { | |||
| 19 | 19 | |||||
| 20 | // bail if no jQuery | 20 | // bail if no jQuery | |||
| 21 | if ( !$ ) { | 21 | if ( !$ ) { | |||
| 22 | return; | 22 | return; | |||
| 23 | } | 23 | } | |||
| 24 | 24 | |||||
| 25 | // -------------------------- addOptionMethod -------------------------- // | 25 | // -------------------------- addOptionMethod -------------------------- // | |||
| 26 | 26 | |||||
| 27 | /** | 27 | /** | |||
| 28 | * adds option method -> $().plugin('option', {...}) | 28 | * adds option method -> $().plugin('option', {...}) | |||
| 29 | * @param {Function} PluginClass - constructor class | 29 | * @param {Function} PluginClass - constructor class | |||
| 30 | */ | 30 | */ | |||
| 31 | function addOptionMethod( PluginClass ) { | 31 | function addOptionMethod( PluginClass ) { | |||
| 32 | // don't overwrite original option method | 32 | // don't overwrite original option method | |||
| 33 | if(typeof PluginClass === "function"){ | 33 | if(typeof PluginClass === "function"){ | |||
| 34 | if ( PluginClass.prototype.option ) { | 34 | if ( PluginClass.prototype.option ) { | |||
| 35 | return; | 35 | return; | |||
| 36 | } | 36 | } | |||
| 37 | 37 | |||||
| 38 | // option setter | 38 | // option setter | |||
| 39 | PluginClass.prototype.option = function( opts ) { | 39 | PluginClass.prototype.option = function( opts ) { | |||
| 40 | // bail out if not an object | 40 | // bail out if not an object | |||
| 41 | if ( !$.isPlainObject( opts ) ){ | 41 | if ( !$.isPlainObject( opts ) ){ | |||
| 42 | return; | 42 | return; | |||
| 43 | } | 43 | } | |||
| 44 | this.options = $.extend( true, this.options, opts ); | 44 | this.options = $.extend( true, this.options, opts ); | |||
| 45 | }; | 45 | }; | |||
| 46 | } else { | 46 | } else { | |||
| 47 | return; | 47 | return; | |||
| 48 | } | 48 | } | |||
| 49 | } | 49 | } | |||
| 50 | 50 | |||||
| 51 | 51 | |||||
| 52 | // -------------------------- plugin bridge -------------------------- // | 52 | // -------------------------- plugin bridge -------------------------- // | |||
| 53 | 53 | |||||
| 54 | // helper function for logging errors | 54 | // helper function for logging errors | |||
| 55 | // $.error breaks jQuery chaining | 55 | // $.error breaks jQuery chaining | |||
| 56 | var logError = typeof console === 'undefined' ? noop : | 56 | var logError = typeof console === 'undefined' ? noop : | |||
| 57 | function( message ) { | 57 | function( message ) { | |||
| 58 | console.error( message ); | 58 | console.error( message ); | |||
| 59 | }; | 59 | }; | |||
| 60 | 60 | |||||
| 61 | /** | 61 | /** | |||
| 62 | * jQuery plugin bridge, access methods like $elem.plugin('method') | 62 | * jQuery plugin bridge, access methods like $elem.plugin('method') | |||
| 63 | * @param {String} namespace - plugin name | 63 | * @param {String} namespace - plugin name | |||
| 64 | * @param {Function} PluginClass - constructor class | 64 | * @param {Function} PluginClass - constructor class | |||
| 65 | */ | 65 | */ | |||
| 66 | function bridge( namespace, PluginClass ) { | 66 | function bridge( namespace, PluginClass ) { | |||
| 67 | // add to jQuery fn namespace | 67 | // add to jQuery fn namespace | |||
| 68 | $.fn[ namespace ] = function( options ) { | 68 | $.fn[ namespace ] = function( options ) { | |||
| 69 | if ( typeof options === 'string' ) { | 69 | if ( typeof options === 'string' ) { | |||
| 70 | // call plugin method when first argument is a string | 70 | // call plugin method when first argument is a string | |||
| 71 | // get arguments for method | 71 | // get arguments for method | |||
| 72 | var args = slice.call( arguments, 1 ); | 72 | var args = slice.call( arguments, 1 ); | |||
| 73 | 73 | |||||
| 74 | for ( var i=0, len = this.length; i < len; i++ ) { | 74 | for ( var i=0, len = this.length; i < len; i++ ) { | |||
| 75 | var elem = this[i]; | 75 | var elem = this[i]; | |||
| 76 | var instance = $.data( elem, namespace ); | 76 | var instance = $.data( elem, namespace ); | |||
| 77 | if ( !instance ) { | 77 | if ( !instance ) { | |||
| 78 | logError( "cannot call methods on " + namespace + " prior to initialization; " + | 78 | logError( "cannot call methods on " + namespace + " prior to initialization; " + | |||
| 79 | "attempted to call '" + options + "'" ); | 79 | "attempted to call '" + options + "'" ); | |||
| 80 | continue; | 80 | continue; | |||
| 81 | } | 81 | } | |||
| 82 | if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) { | 82 | if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) { | |||
| 83 | logError( "no such method '" + options + "' for " + namespace + " instance" ); | 83 | logError( "no such method '" + options + "' for " + namespace + " instance" ); | |||
| 84 | continue; | 84 | continue; | |||
| 85 | } | 85 | } | |||
| 86 | 86 | |||||
| 87 | // trigger method with arguments | 87 | // trigger method with arguments | |||
| 88 | var returnValue = instance[ options ].apply( instance, args ); | 88 | var returnValue = instance[ options ].apply( instance, args ); | |||
| 89 | 89 | |||||
| 90 | // break look and return first value if provided | 90 | // break look and return first value if provided | |||
| 91 | if ( returnValue !== undefined ) { | 91 | if ( returnValue !== undefined ) { | |||
| 92 | return returnValue; | 92 | return returnValue; | |||
| 93 | } | 93 | } | |||
| 94 | } | 94 | } | |||
| 95 | // return this if no return value | 95 | // return this if no return value | |||
| 96 | return this; | 96 | return this; | |||
| 97 | } else { | 97 | } else { | |||
| 98 | return this.each( function() { | 98 | return this.each( function() { | |||
| 99 | var instance = $.data( this, namespace ); | 99 | var instance = $.data( this, namespace ); | |||
| 100 | if ( instance ) { | 100 | if ( instance ) { | |||
| 101 | // apply options & init | 101 | // apply options & init | |||
| 102 | instance.option( options ); | 102 | instance.option( options ); | |||
| 103 | instance._init(); | 103 | instance._init(); | |||
| 104 | } else { | 104 | } else { | |||
| 105 | // initialize new instance | 105 | // initialize new instance | |||
| 106 | instance = new PluginClass( this, options ); | 106 | instance = new PluginClass( this, options ); | |||
| 107 | $.data( this, namespace, instance ); | 107 | $.data( this, namespace, instance ); | |||
| 108 | } | 108 | } | |||
| 109 | }); | 109 | }); | |||
| 110 | } | 110 | } | |||
| 111 | }; | 111 | }; | |||
| 112 | 112 | |||||
| 113 | } | 113 | } | |||
| 114 | 114 | |||||
| 115 | // -------------------------- bridget -------------------------- // | 115 | // -------------------------- bridget -------------------------- // | |||
| 116 | 116 | |||||
| 117 | /** | 117 | /** | |||
| 118 | * converts a Prototypical class into a proper jQuery plugin | 118 | * converts a Prototypical class into a proper jQuery plugin | |||
| 119 | * the class must have a ._init method | 119 | * the class must have a ._init method | |||
| 120 | * @param {String} namespace - plugin name, used in $().pluginName | 120 | * @param {String} namespace - plugin name, used in $().pluginName | |||
| 121 | * @param {Function} PluginClass - constructor class | 121 | * @param {Function} PluginClass - constructor class | |||
| 122 | */ | 122 | */ | |||
| 123 | $.bridget = function( namespace, PluginClass ) { | 123 | $.bridget = function( namespace, PluginClass ) { | |||
| 124 | addOptionMethod( PluginClass ); | 124 | addOptionMethod( PluginClass ); | |||
| 125 | bridge( namespace, PluginClass ); | 125 | bridge( namespace, PluginClass ); | |||
| 126 | }; | 126 | }; | |||
| 127 | 127 | |||||
| 128 | return $.bridget; | 128 | return $.bridget; | |||
| 129 | 129 | |||||
| 130 | } | 130 | } | |||
| 131 | 131 | |||||
| 132 | // transport | 132 | // transport | |||
| 133 | if ( typeof define === 'function' && define.amd ) { | 133 | if ( typeof define === 'function' && define.amd ) { | |||
| 134 | // AMD | 134 | // AMD | |||
| 135 | define( [ 'jquery' ], defineBridget ); | 135 | define( [ 'jquery' ], defineBridget ); | |||
| 136 | } else { | 136 | } else { | |||
| 137 | // get jquery from browser global | 137 | // get jquery from browser global | |||
| 138 | defineBridget( window.jQuery ); | 138 | defineBridget( window.jQuery ); | |||
| 139 | } | 139 | } | |||
| 140 | 140 | |||||
| 141 | })( window ); | 141 | })( window ); |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.