-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathjquery.indextank.ize.js
56 lines (43 loc) · 1.67 KB
/
jquery.indextank.ize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(function($){
if(!$.Indextank){
$.Indextank = new Object();
};
$.Indextank.Ize = function(el, apiurl, indexName, options){
// To avoid scope issues, use 'base' instead of 'this'
// to reference this class from internal events and functions.
var base = this;
// Access to jQuery and DOM versions of element
base.$el = $(el);
base.el = el;
// some parameter validation
var urlrx = /http(s)?:\/\/[a-z0-9]+\.api\..+/;
if (!urlrx.test(apiurl)) throw("invalid api url ! is it private ? ");
if (indexName == undefined) throw("index name is not defined!");
// Add a reverse reference to the DOM object
base.$el.data("Indextank.Ize", base);
base.init = function(){
base.apiurl = apiurl;
base.indexName = indexName;
base.options = $.extend({},$.Indextank.Ize.defaultOptions, options);
// Put your initialization code here
};
// Sample Function, Uncomment to use
// base.functionName = function(paramaters){
//
// };
// Run initializer
base.init();
};
$.Indextank.Ize.defaultOptions = {
};
$.fn.indextank_Ize = function(apiurl, indexName, options){
return this.each(function(){
(new $.Indextank.Ize(this, apiurl, indexName, options));
});
};
// This function breaks the chain, but returns
// the Indextank.Ize if it has been attached to the object.
$.fn.getIndextank_Ize = function(){
this.data("Indextank.Ize");
};
})(jQuery);