PageSourceSearch

https://farmersmarketsontario.com/_scripts/_hi5/selectize/microplugin.js

js farmersmarketsontario.com collected 2026-10-01 14:40:39 UTC 3,335 bytes, 135 lines download raw bytes

vendor: 3,335 bytes, lines 1-135
1/**
2 * microplugin.js
3 * Copyright (c) 2013 Brian Reavis & contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
6 * file except in compliance with the License. You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under
10 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11 * ANY KIND, either express or implied. See the License for the specific language
12 * governing permissions and limitations under the License.
13 *
14 * @author Brian Reavis <[email protected]>
15 */
16
17(function(root, factory) {
18	if (typeof define === 'function' && define.amd) {
19		define(factory);
20	} else if (typeof exports === 'object') {
21		module.exports = factory();
22	} else {
23		root.MicroPlugin = factory();
24	}
25}(this, function() {
26	var MicroPlugin = {};
27
28	MicroPlugin.mixin = function(Interface) {
29		Interface.plugins = {};
30
31		/**
32		 * Initializes the listed plugins (with options).
33		 * Acceptable formats:
34		 *
35		 * List (without options):
36		 *   ['a', 'b', 'c']
37		 *
38		 * List (with options):
39		 *   [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
40		 *
41		 * Hash (with options):
42		 *   {'a': { ... }, 'b': { ... }, 'c': { ... }}
43		 *
44		 * @param {mixed} plugins
45		 */
46		Interface.prototype.initializePlugins = function(plugins) {
47			var i, n, key;
48			var self  = this;
49			var queue = [];
50
51			self.plugins = {
52				names     : [],
53				settings  : {},
54				requested : {},
55				loaded    : {}
56			};
57
58			if (utils.isArray(plugins)) {
59				for (i = 0, n = plugins.length; i < n; i++) {
60					if (typeof plugins[i] === 'string') {
61						queue.push(plugins[i]);
62					} else {
63						self.plugins.settings[plugins[i].name] = plugins[i].options;
64						queue.push(plugins[i].name);
65					}
66				}
67			} else if (plugins) {
68				for (key in plugins) {
69					if (plugins.hasOwnProperty(key)) {
70						self.plugins.settings[key] = plugins[key];
71						queue.push(key);
72					}
73				}
74			}
75
76			while (queue.length) {
77				self.require(queue.shift());
78			}
79		};
80
81		Interface.prototype.loadPlugin = function(name) {
82			var self    = this;
83			var plugins = self.plugins;
84			var plugin  = Interface.plugins[name];
85
86			if (!Interface.plugins.hasOwnProperty(name)) {
87				throw new Error('Unable to find "' +  name + '" plugin');
88			}
89
90			plugins.requested[name] = true;
91			plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
92			plugins.names.push(name);
93		};
94
95		/**
96		 * Initializes a plugin.
97		 *
98		 * @param {string} name
99		 */
100		Interface.prototype.require = function(name) {
101			var self = this;
102			var plugins = self.plugins;
103
104			if (!self.plugins.loaded.hasOwnProperty(name)) {
105				if (plugins.requested[name]) {
106					throw new Error('Plugin has circular dependency ("' + name + '")');
107				}
108				self.loadPlugin(name);
109			}
110
111			return plugins.loaded[name];
112		};
113
114		/**
115		 * Registers a plugin.
116		 *
117		 * @param {string} name
118		 * @param {function} fn
119		 */
120		Interface.define = function(name, fn) {
121			Interface.plugins[name] = {
122				'name' : name,
123				'fn'   : fn
124			};
125		};
126	};
127
128	var utils = {
129		isArray: Array.isArray || function(vArg) {
130			return Object.prototype.toString.call(vArg) === '[object Array]';
131		}
132	};
133
134	return MicroPlugin;
135}));

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.