PageSourceSearch

https://fdnyheart.com/plugins/system/easyslider/assets/js/lib/utils.js

js fdnyheart.com collected 2026-10-08 08:11:25 UTC 3,715 bytes, 141 lines download raw bytes

1void function( exports, $, _, Backbone ) {
2
3	//exports.log = log.bind( console );
4	exports.log = _.noop;
5
6	_.mixin( {
7
8		prefixCSSRules: function( css, prefix ) {
9			css = css.replace(/\n|\r|\t/g, '');
10			css = css.replace(/\/\*[^*]+\*\//g, '');
11			return _( css.match(/[^{]+{[^}]+}/g) || [] ).map(function ( rule ) {
12				var split = rule.match(/^(.*)({.*})/)
13				return _.map(split[1].split(','), function(name) {
14						return prefix + ' ' + name.trim();
15					}, this).join(",\n") + split[2];
16			}, this).join("\n");
17		},
18
19		loadImage: function( src, callback, context ) {
20			var img = new Image;
21			img.onerror = function ( e ) {
22				console.warn('Could not load image from source: ' + src)
23			}
24			img.onload = function() {
25				_.isFunction(callback) && callback.call(context||this, this)
26			}
27			img.src = src;
28		},
29		isPrototypeOf: function( child, parent ) {
30			if ( !child || !parent )
31				return false;
32			var result = false;
33			var proto = child.prototype;
34			while ( proto ) {
35				if ( proto == parent.prototype ) {
36					result = true;
37					break;
38				}
39				proto = proto.__proto__;
40			}
41			return result;
42		},
43		setPrototypeOf: function( child, prototype ) {
44			if (_.isFunction(Object.setPrototypeOf))
45				Object.setPrototypeOf(child.prototype || child, prototype);
46			else
47				(child.prototype || child).__proto__ = prototype;
48			return child
49		},
50		extendPrototype: function( child, prototype ) {
51			_.extend(child.prototype, prototype)
52			return child
53		},
54
55		joinPath: function() {
56			return _( arguments ).join( '/' ).replace(/([^:])\/+/g,'$1\/');
57		},
58
59		deepExtend: function deepExtend( obj ) {
60			return $.extend.apply( $, _( arguments ).splice( 0, 0, true ) );
61		},
62
63		parseNumberUnit: function( str ) {
64			str += '';
65			var match = str.replace( /\s+/, ' ' ).match( /([-0-9.]+)\s?([^\s]*)?/ );
66			return {
67				value: match && parseFloat( match[ 1 ] ) || 0,
68				unit: match && match[ 2 ] || ''
69			}
70		},
71		stripTags: function( str ) {
72			return str
73				.replace( /</g, '&lt;' )
74				.replace( />/g, '&gt;' );
75		},
76		encodeHtmlEntities: function( str ) {
77			return String( str )
78				.replace( /&/g, '&amp;' )
79				.replace( /</g, '&lt;' )
80				.replace( />/g, '&gt;' )
81				.replace( /"/g, '&quot;' );
82		},
83		decodeHtmlEntities: function( str ) {
84			return String( str )
85				.replace( /&amp;/g, '&' )
86				.replace( /&lt;/g, '<' )
87				.replace( /&gt;/g, '>' )
88				.replace( /&quot;/g, '"' );
89		},
90		parseBackgroundPos: function(str, container) {
91			str = (str == 'cover' || str == 'contain') ? '100%' : str;
92			str = str.replace(/center/g, '50%');
93			//str:50% 50%
94			var list = str.split(' ');
95			var newValue = [];
96
97			_.each(list, function( val, i ) {
98				//console.log(val)
99				if ( val.indexOf('%') >= 0 ){
100					newValue.push(parseInt(val.replace(/%/, '')));
101					/*val = parseFloat(val.replace(/%/g, ''));
102					if ( i == 0 ) {
103						newValue.push( val * container.width() / 100);
104					}
105					else if ( i == 1 ) {
106						newValue.push( val * container.height() / 100);
107					}*/
108				}
109				else if ( val.indexOf('px') >= 0 ){
110					//newValue.push(parseFloat(val.replace(/px/, '')));
111
112					val = parseInt(val.replace(/px/g, ''));
113					if ( i == 0 ) {
114						newValue.push( parseInt(val / container.width() * 100) );
115					}
116					else if ( i == 1 ) {
117						newValue.push( parseInt(val / container.height() * 100) );
118					}
119
120				}
121			})
122			return newValue;
123		}
124	} );
125
126	function deepExtend(obj) {
127		_(arguments).chain().slice(1).each(function(props) {
128			_(props).each(function( value, key ) {
129				if (_.isObject(value)) {
130					if (!_.isObject(obj[key]))
131						obj[key] = {};
132					return deepExtend(obj[key], value)
133				}
134				obj[key] = value;
135			})
136		})
137		return obj;
138	}
139
140
141}( this, jQuery, _, Backbone );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.