cobweb 0.0.38 → 0.0.39
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -1
- data/lib/cobweb.rb +3 -1
- data/lib/cobweb_crawler.rb +98 -100
- data/lib/crawl_job.rb +3 -4
- data/lib/server.rb +98 -0
- data/lib/stats.rb +141 -64
- data/public/css/accordion.css +45 -0
- data/public/css/custom.css +13 -0
- data/public/css/datatable.css +189 -0
- data/public/css/datepicker.css +171 -0
- data/public/css/form-buttons.css +180 -0
- data/public/css/forms.css +489 -0
- data/public/css/jquery.fancybox-1.3.4.css +282 -0
- data/public/css/jquery.treeview.css +103 -0
- data/public/css/link-buttons.css +187 -0
- data/public/css/login.css +110 -0
- data/public/css/menu.css +156 -0
- data/public/css/messages.css +58 -0
- data/public/css/modalbox.css +63 -0
- data/public/css/statics.css +57 -0
- data/public/css/style.css +497 -0
- data/public/css/style_text.css +128 -0
- data/public/css/tabs.css +58 -0
- data/public/css/wysiwyg-editor.css +18 -0
- data/public/css/wysiwyg.css +149 -0
- data/public/css/wysiwyg.modal.css +69 -0
- data/public/gfx/back-menu.gif +0 -0
- data/public/gfx/back-submenu.gif +0 -0
- data/public/gfx/background.gif +0 -0
- data/public/gfx/box-hide.png +0 -0
- data/public/gfx/box-search.png +0 -0
- data/public/gfx/box-title.gif +0 -0
- data/public/gfx/code.gif +0 -0
- data/public/gfx/datepicker-arrows.gif +0 -0
- data/public/gfx/fancybox/blank.gif +0 -0
- data/public/gfx/fancybox/fancy_close.png +0 -0
- data/public/gfx/fancybox/fancy_loading.png +0 -0
- data/public/gfx/fancybox/fancy_nav_left.png +0 -0
- data/public/gfx/fancybox/fancy_nav_right.png +0 -0
- data/public/gfx/fancybox/fancy_title_left.png +0 -0
- data/public/gfx/fancybox/fancy_title_main.png +0 -0
- data/public/gfx/fancybox/fancy_title_over.png +0 -0
- data/public/gfx/fancybox/fancy_title_right.png +0 -0
- data/public/gfx/fancybox/fancybox-x.png +0 -0
- data/public/gfx/fancybox/fancybox.png +0 -0
- data/public/gfx/forms/date-next.gif +0 -0
- data/public/gfx/forms/date-prev.gif +0 -0
- data/public/gfx/forms/forms-checkbox.gif +0 -0
- data/public/gfx/forms/forms-date.gif +0 -0
- data/public/gfx/forms/forms-file.gif +0 -0
- data/public/gfx/forms/forms-input-big.gif +0 -0
- data/public/gfx/forms/forms-input-medium.gif +0 -0
- data/public/gfx/forms/forms-input-small.gif +0 -0
- data/public/gfx/forms/forms-input-xl.gif +0 -0
- data/public/gfx/forms/forms-radio.gif +0 -0
- data/public/gfx/forms/forms-selectbox-small.gif +0 -0
- data/public/gfx/forms/forms-selectbox.gif +0 -0
- data/public/gfx/forms/forms-textarea-big.gif +0 -0
- data/public/gfx/forms/forms-textarea-medium.gif +0 -0
- data/public/gfx/forms/forms-textarea-small.gif +0 -0
- data/public/gfx/forms/forms-textarea-xl.gif +0 -0
- data/public/gfx/icon-delete.png +0 -0
- data/public/gfx/icon-edit.png +0 -0
- data/public/gfx/icon-home.gif +0 -0
- data/public/gfx/img-delete.png +0 -0
- data/public/gfx/img-hover.png +0 -0
- data/public/gfx/img-zoom.png +0 -0
- data/public/gfx/jquery.wysiwyg.gif +0 -0
- data/public/gfx/label-icons.gif +0 -0
- data/public/gfx/label.gif +0 -0
- data/public/gfx/li-down.gif +0 -0
- data/public/gfx/li.gif +0 -0
- data/public/gfx/link-button-big.gif +0 -0
- data/public/gfx/link-button-medium.gif +0 -0
- data/public/gfx/link-button.gif +0 -0
- data/public/gfx/loading-2.gif +0 -0
- data/public/gfx/loading.gif +0 -0
- data/public/gfx/logo.png +0 -0
- data/public/gfx/modal-title.gif +0 -0
- data/public/gfx/photos/00.jpg +0 -0
- data/public/gfx/photos/01.jpg +0 -0
- data/public/gfx/photos/01xl.jpg +0 -0
- data/public/gfx/photos/02.jpg +0 -0
- data/public/gfx/photos/02xl.jpg +0 -0
- data/public/gfx/photos/03.jpg +0 -0
- data/public/gfx/photos/03xl.jpg +0 -0
- data/public/gfx/photos/04.jpg +0 -0
- data/public/gfx/photos/04xl.jpg +0 -0
- data/public/gfx/photos/05.jpg +0 -0
- data/public/gfx/photos/05xl.jpg +0 -0
- data/public/gfx/photos/06.jpg +0 -0
- data/public/gfx/photos/06xl.jpg +0 -0
- data/public/gfx/photos/07.jpg +0 -0
- data/public/gfx/photos/07xl.jpg +0 -0
- data/public/gfx/photos/08.jpg +0 -0
- data/public/gfx/photos/08xl.jpg +0 -0
- data/public/gfx/photos/09.jpg +0 -0
- data/public/gfx/photos/09xl.jpg +0 -0
- data/public/gfx/photos/10.jpg +0 -0
- data/public/gfx/photos/10xl.jpg +0 -0
- data/public/gfx/photos/11.jpg +0 -0
- data/public/gfx/photos/11xl.jpg +0 -0
- data/public/gfx/photos/12.jpg +0 -0
- data/public/gfx/photos/12xl.jpg +0 -0
- data/public/gfx/photos/13.jpg +0 -0
- data/public/gfx/photos/13xl.jpg +0 -0
- data/public/gfx/photos/14.jpg +0 -0
- data/public/gfx/photos/14xl.jpg +0 -0
- data/public/gfx/photos/15.jpg +0 -0
- data/public/gfx/photos/15xl.jpg +0 -0
- data/public/gfx/search-button.gif +0 -0
- data/public/gfx/search-input.gif +0 -0
- data/public/gfx/slider-button.gif +0 -0
- data/public/gfx/system-messages.gif +0 -0
- data/public/gfx/table-asc-arrow.gif +0 -0
- data/public/gfx/table-desc-arrow.gif +0 -0
- data/public/gfx/table-first.gif +0 -0
- data/public/gfx/table-last.gif +0 -0
- data/public/gfx/table-next.gif +0 -0
- data/public/gfx/table-number.gif +0 -0
- data/public/gfx/table-prev.gif +0 -0
- data/public/gfx/table-rows.gif +0 -0
- data/public/gfx/table-search.gif +0 -0
- data/public/gfx/table-thead.gif +0 -0
- data/public/gfx/tooltip.gif +0 -0
- data/public/gfx/treeview/ajax-loader.gif +0 -0
- data/public/gfx/treeview/file.gif +0 -0
- data/public/gfx/treeview/folder-closed.gif +0 -0
- data/public/gfx/treeview/folder.gif +0 -0
- data/public/gfx/treeview/minus.gif +0 -0
- data/public/gfx/treeview/plus.gif +0 -0
- data/public/gfx/treeview/treeview-default-line.gif +0 -0
- data/public/gfx/treeview/treeview-default.gif +0 -0
- data/public/js/controls/wysiwyg.image.js +284 -0
- data/public/js/controls/wysiwyg.link.js +210 -0
- data/public/js/controls/wysiwyg.table.js +151 -0
- data/public/js/customInput.jquery.js +68 -0
- data/public/js/excanvas.min.js +1 -0
- data/public/js/hoverIntent.js +84 -0
- data/public/js/inline.js +392 -0
- data/public/js/jquery-1.7.1.min.js +4 -0
- data/public/js/jquery-ui-select.js +522 -0
- data/public/js/jquery-ui-timepicker-addon.js +1299 -0
- data/public/js/jquery-ui.js +791 -0
- data/public/js/jquery.dataTables.js +7440 -0
- data/public/js/jquery.fancybox-1.3.4.js +1156 -0
- data/public/js/jquery.filestyle.mini.js +2 -0
- data/public/js/jquery.flot.js +2600 -0
- data/public/js/jquery.flot.resize.min.js +60 -0
- data/public/js/jquery.graphtable-0.2.js +179 -0
- data/public/js/jquery.tipsy.js +104 -0
- data/public/js/jquery.treeview.js +256 -0
- data/public/js/jquery.wysiwyg.js +2454 -0
- data/public/js/plugins/wysiwyg.rmFormat.js +348 -0
- data/public/js/superfish.js +121 -0
- data/public/js/supersubs.js +90 -0
- data/views/home.haml +54 -0
- data/views/layout.haml +89 -0
- data/views/statistics.haml +251 -71
- metadata +175 -22
@@ -0,0 +1,348 @@
|
|
1
|
+
/**
|
2
|
+
* rmFormat plugin
|
3
|
+
*
|
4
|
+
* Depends on jWYSIWYG
|
5
|
+
*/
|
6
|
+
(function ($) {
|
7
|
+
if (undefined === $.wysiwyg) {
|
8
|
+
throw "wysiwyg.rmFormat.js depends on $.wysiwyg";
|
9
|
+
}
|
10
|
+
|
11
|
+
/*
|
12
|
+
* Wysiwyg namespace: public properties and methods
|
13
|
+
*/
|
14
|
+
var rmFormat = {
|
15
|
+
name: "rmFormat",
|
16
|
+
version: "",
|
17
|
+
defaults: {
|
18
|
+
rules: {
|
19
|
+
heading: false,
|
20
|
+
table: false,
|
21
|
+
/*
|
22
|
+
* rmAttr - { "all" | object with names } remove all
|
23
|
+
* attributes or attributes with following names
|
24
|
+
*
|
25
|
+
* rmWhenEmpty - if element contains no text or { \s, \n, <br>, <br/> }
|
26
|
+
* then it will be removed
|
27
|
+
*
|
28
|
+
* rmWhenNoAttr - if element contains no attributes (i.e. <span>Some Text</span>)
|
29
|
+
* then it will be removed
|
30
|
+
*/
|
31
|
+
msWordMarkup: {
|
32
|
+
enabled: false,
|
33
|
+
tags: {
|
34
|
+
"a": {
|
35
|
+
rmWhenEmpty: true
|
36
|
+
},
|
37
|
+
|
38
|
+
"b": {
|
39
|
+
rmWhenEmpty: true
|
40
|
+
},
|
41
|
+
|
42
|
+
"div": {
|
43
|
+
rmWhenEmpty: true,
|
44
|
+
rmWhenNoAttr: true
|
45
|
+
},
|
46
|
+
|
47
|
+
"em": {
|
48
|
+
rmWhenEmpty: true
|
49
|
+
},
|
50
|
+
|
51
|
+
"font": {
|
52
|
+
rmAttr: {
|
53
|
+
"face": "",
|
54
|
+
"size": ""
|
55
|
+
},
|
56
|
+
rmWhenEmpty: true,
|
57
|
+
rmWhenNoAttr: true
|
58
|
+
},
|
59
|
+
|
60
|
+
"h1": {
|
61
|
+
rmAttr: "all",
|
62
|
+
rmWhenEmpty: true
|
63
|
+
},
|
64
|
+
"h2": {
|
65
|
+
rmAttr: "all",
|
66
|
+
rmWhenEmpty: true
|
67
|
+
},
|
68
|
+
"h3": {
|
69
|
+
rmAttr: "all",
|
70
|
+
rmWhenEmpty: true
|
71
|
+
},
|
72
|
+
"h4": {
|
73
|
+
rmAttr: "all",
|
74
|
+
rmWhenEmpty: true
|
75
|
+
},
|
76
|
+
"h5": {
|
77
|
+
rmAttr: "all",
|
78
|
+
rmWhenEmpty: true
|
79
|
+
},
|
80
|
+
"h6": {
|
81
|
+
rmAttr: "all",
|
82
|
+
rmWhenEmpty: true
|
83
|
+
},
|
84
|
+
|
85
|
+
"i": {
|
86
|
+
rmWhenEmpty: true
|
87
|
+
},
|
88
|
+
|
89
|
+
"p": {
|
90
|
+
rmAttr: "all",
|
91
|
+
rmWhenEmpty: true
|
92
|
+
},
|
93
|
+
|
94
|
+
"span": {
|
95
|
+
rmAttr: {
|
96
|
+
lang: ""
|
97
|
+
},
|
98
|
+
rmWhenEmpty: true,
|
99
|
+
rmWhenNoAttr: true
|
100
|
+
},
|
101
|
+
|
102
|
+
"strong": {
|
103
|
+
rmWhenEmpty: true
|
104
|
+
},
|
105
|
+
|
106
|
+
"u": {
|
107
|
+
rmWhenEmpty: true
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
},
|
113
|
+
options: {},
|
114
|
+
enabled: false,
|
115
|
+
debug: false,
|
116
|
+
|
117
|
+
domRemove: function (node) {
|
118
|
+
// replace h1-h6 with p
|
119
|
+
if (this.options.rules.heading) {
|
120
|
+
if (node.nodeName.toLowerCase().match(/^h[1-6]$/)) {
|
121
|
+
// in chromium change this to
|
122
|
+
// $(node).replaceWith($('<p/>').html(node.innerHTML));
|
123
|
+
// to except DOM error: also try in other browsers
|
124
|
+
$(node).replaceWith($('<p/>').html($(node).contents()));
|
125
|
+
|
126
|
+
return true;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
// remove tables not smart enough )
|
131
|
+
if (this.options.rules.table) {
|
132
|
+
if (node.nodeName.toLowerCase().match(/^(table|t[dhr]|t(body|foot|head))$/)) {
|
133
|
+
$(node).replaceWith($(node).contents());
|
134
|
+
|
135
|
+
return true;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
return false;
|
140
|
+
},
|
141
|
+
|
142
|
+
domTraversing: function (el, start, end, canRemove, cnt) {
|
143
|
+
if (null === canRemove) {
|
144
|
+
canRemove = false;
|
145
|
+
}
|
146
|
+
|
147
|
+
var isDomRemoved, p;
|
148
|
+
|
149
|
+
while (el) {
|
150
|
+
if (this.debug) { console.log(cnt, "canRemove=", canRemove); }
|
151
|
+
|
152
|
+
if (el.firstElementChild) {
|
153
|
+
|
154
|
+
if (this.debug) { console.log(cnt, "domTraversing", el.firstElementChild); }
|
155
|
+
|
156
|
+
return this.domTraversing(el.firstElementChild, start, end, canRemove, cnt + 1);
|
157
|
+
} else {
|
158
|
+
|
159
|
+
if (this.debug) { console.log(cnt, "routine", el); }
|
160
|
+
|
161
|
+
isDomRemoved = false;
|
162
|
+
|
163
|
+
if (start === el) {
|
164
|
+
canRemove = true;
|
165
|
+
}
|
166
|
+
|
167
|
+
if (canRemove) {
|
168
|
+
if (el.previousElementSibling) {
|
169
|
+
p = el.previousElementSibling;
|
170
|
+
} else {
|
171
|
+
p = el.parentNode;
|
172
|
+
}
|
173
|
+
|
174
|
+
if (this.debug) { console.log(cnt, el.nodeName, el.previousElementSibling, el.parentNode, p); }
|
175
|
+
|
176
|
+
isDomRemoved = this.domRemove(el);
|
177
|
+
if (this.domRemove(el)) {
|
178
|
+
|
179
|
+
if (this.debug) { console.log("p", p); }
|
180
|
+
|
181
|
+
// step back to parent or previousElement to traverse again then element is removed
|
182
|
+
el = p;
|
183
|
+
}
|
184
|
+
|
185
|
+
if (start !== end && end === el) {
|
186
|
+
return true;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
if (false === isDomRemoved) {
|
191
|
+
el = el.nextElementSibling;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
return false;
|
197
|
+
},
|
198
|
+
|
199
|
+
msWordMarkup: function (text) {
|
200
|
+
var tagName, attrName, rules, reg, regAttr, found, attrs;
|
201
|
+
|
202
|
+
// @link https://github.com/akzhan/jwysiwyg/issues/165
|
203
|
+
text = text.replace(/</g, "<").replace(/>/g, ">");
|
204
|
+
|
205
|
+
text = text.replace(/<meta\s[^>]+>/g, "");
|
206
|
+
text = text.replace(/<link\s[^>]+>/g, "");
|
207
|
+
text = text.replace(/<title>[\s\S]*?<\/title>/g, "");
|
208
|
+
text = text.replace(/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gm, "");
|
209
|
+
text = text.replace(/<w:([^\s>]+)(?:\s[^\/]+)?\/>/g, "");
|
210
|
+
text = text.replace(/<w:([^\s>]+)(?:\s[^>]+)?>[\s\S]*?<\/w:\1>/gm, "");
|
211
|
+
text = text.replace(/<m:([^\s>]+)(?:\s[^\/]+)?\/>/g, "");
|
212
|
+
text = text.replace(/<m:([^\s>]+)(?:\s[^>]+)?>[\s\S]*?<\/m:\1>/gm, "");
|
213
|
+
|
214
|
+
// after running the above.. it still needed these
|
215
|
+
text = text.replace(/<xml>[\s\S]*?<\/xml>/g, "");
|
216
|
+
text = text.replace(/<object(?:\s[^>]*)?>[\s\S]*?<\/object>/g, "");
|
217
|
+
text = text.replace(/<o:([^\s>]+)(?:\s[^\/]+)?\/>/g, "");
|
218
|
+
text = text.replace(/<o:([^\s>]+)(?:\s[^>]+)?>[\s\S]*?<\/o:\1>/gm, "");
|
219
|
+
text = text.replace(/<st1:([^\s>]+)(?:\s[^\/]+)?\/>/g, "");
|
220
|
+
text = text.replace(/<st1:([^\s>]+)(?:\s[^>]+)?>[\s\S]*?<\/st1:\1>/gm, "");
|
221
|
+
// ----
|
222
|
+
text = text.replace(/<!--[^>]+>\s*<[^>]+>/gm, ""); // firefox needed this 1
|
223
|
+
|
224
|
+
|
225
|
+
text = text.replace(/^[\s\n]+/gm, "");
|
226
|
+
|
227
|
+
if (this.options.rules.msWordMarkup.tags) {
|
228
|
+
for (tagName in this.options.rules.msWordMarkup.tags) {
|
229
|
+
rules = this.options.rules.msWordMarkup.tags[tagName];
|
230
|
+
|
231
|
+
if ("string" === typeof (rules)) {
|
232
|
+
if ("" === rules) {
|
233
|
+
reg = new RegExp("<" + tagName + "(?:\\s[^>]+)?/?>", "gmi");
|
234
|
+
text = text.replace(reg, "<" + tagName + ">");
|
235
|
+
}
|
236
|
+
} else if ("object" === typeof (rules)) {
|
237
|
+
reg = new RegExp("<" + tagName + "(\\s[^>]+)?/?>", "gmi");
|
238
|
+
found = reg.exec(text);
|
239
|
+
attrs = "";
|
240
|
+
|
241
|
+
if (found && found[1]) {
|
242
|
+
attrs = found[1];
|
243
|
+
}
|
244
|
+
|
245
|
+
if (rules.rmAttr) {
|
246
|
+
if ("all" === rules.rmAttr) {
|
247
|
+
attrs = "";
|
248
|
+
} else if ("object" === typeof (rules.rmAttr) && attrs) {
|
249
|
+
for (attrName in rules.rmAttr) {
|
250
|
+
regAttr = new RegExp(attrName + '="[^"]*"', "mi");
|
251
|
+
attrs = attrs.replace(regAttr, "");
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
256
|
+
if (attrs) {
|
257
|
+
attrs = attrs.replace(/[\s\n]+/gm, " ");
|
258
|
+
|
259
|
+
if (" " === attrs) {
|
260
|
+
attrs = "";
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
text = text.replace(reg, "<" + tagName + attrs + ">");
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
for (tagName in this.options.rules.msWordMarkup.tags) {
|
269
|
+
rules = this.options.rules.msWordMarkup.tags[tagName];
|
270
|
+
|
271
|
+
if ("string" === typeof (rules)) {
|
272
|
+
//
|
273
|
+
} else if ("object" === typeof (rules)) {
|
274
|
+
if (rules.rmWhenEmpty) {
|
275
|
+
reg = new RegExp("<" + tagName + "(\\s[^>]+)?>(?:[\\s\\n]|<br/?>)*?</" + tagName + ">", "gmi");
|
276
|
+
text = text.replace(reg, "");
|
277
|
+
}
|
278
|
+
|
279
|
+
if (rules.rmWhenNoAttr) {
|
280
|
+
reg = new RegExp("<" + tagName + ">(?!<" + tagName + ">)([\\s\\S]*?)</" + tagName + ">", "mi");
|
281
|
+
found = reg.exec(text);
|
282
|
+
while (found) {
|
283
|
+
text = text.replace(reg, found[1]);
|
284
|
+
|
285
|
+
found = reg.exec(text);
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
return text;
|
293
|
+
},
|
294
|
+
|
295
|
+
run: function (Wysiwyg, options) {
|
296
|
+
options = options || {};
|
297
|
+
this.options = $.extend(true, this.defaults, options);
|
298
|
+
|
299
|
+
if (this.options.rules.heading || this.options.rules.table) {
|
300
|
+
var r = Wysiwyg.getInternalRange(),
|
301
|
+
start,
|
302
|
+
end,
|
303
|
+
node,
|
304
|
+
traversing;
|
305
|
+
|
306
|
+
start = r.startContainer;
|
307
|
+
if (start.nodeType === 3) {
|
308
|
+
start = start.parentNode;
|
309
|
+
}
|
310
|
+
|
311
|
+
end = r.endContainer;
|
312
|
+
if (end.nodeType === 3) {
|
313
|
+
end = end.parentNode;
|
314
|
+
}
|
315
|
+
|
316
|
+
if (this.debug) {
|
317
|
+
console.log("start", start, start.nodeType, start.nodeName, start.parentNode);
|
318
|
+
console.log("end", end, end.nodeType, end.nodeName, end.parentNode);
|
319
|
+
}
|
320
|
+
|
321
|
+
node = r.commonAncestorContainer;
|
322
|
+
if (node.nodeType === 3) {
|
323
|
+
node = node.parentNode;
|
324
|
+
}
|
325
|
+
|
326
|
+
if (this.debug) {
|
327
|
+
console.log("node", node, node.nodeType, node.nodeName.toLowerCase(), node.parentNode, node.firstElementChild);
|
328
|
+
console.log(start === end);
|
329
|
+
}
|
330
|
+
|
331
|
+
traversing = null;
|
332
|
+
if (start === end) {
|
333
|
+
traversing = this.domTraversing(node, start, end, true, 1);
|
334
|
+
} else {
|
335
|
+
traversing = this.domTraversing(node.firstElementChild, start, end, null, 1);
|
336
|
+
}
|
337
|
+
|
338
|
+
if (this.debug) { console.log("DomTraversing=", traversing); }
|
339
|
+
}
|
340
|
+
|
341
|
+
if (this.options.rules.msWordMarkup.enabled) {
|
342
|
+
Wysiwyg.setContent(this.msWordMarkup(Wysiwyg.getContent()));
|
343
|
+
}
|
344
|
+
}
|
345
|
+
};
|
346
|
+
|
347
|
+
$.wysiwyg.plugin.register(rmFormat);
|
348
|
+
})(jQuery);
|
@@ -0,0 +1,121 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* Superfish v1.4.8 - jQuery menu widget
|
4
|
+
* Copyright (c) 2008 Joel Birch
|
5
|
+
*
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl.html
|
9
|
+
*
|
10
|
+
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
|
11
|
+
*/
|
12
|
+
|
13
|
+
;(function($){
|
14
|
+
$.fn.superfish = function(op){
|
15
|
+
|
16
|
+
var sf = $.fn.superfish,
|
17
|
+
c = sf.c,
|
18
|
+
$arrow = $(['<span class="',c.arrowClass,'"> »</span>'].join('')),
|
19
|
+
over = function(){
|
20
|
+
var $$ = $(this), menu = getMenu($$);
|
21
|
+
clearTimeout(menu.sfTimer);
|
22
|
+
$$.showSuperfishUl().siblings().hideSuperfishUl();
|
23
|
+
},
|
24
|
+
out = function(){
|
25
|
+
var $$ = $(this), menu = getMenu($$), o = sf.op;
|
26
|
+
clearTimeout(menu.sfTimer);
|
27
|
+
menu.sfTimer=setTimeout(function(){
|
28
|
+
o.retainPath=($.inArray($$[0],o.$path)>-1);
|
29
|
+
$$.hideSuperfishUl();
|
30
|
+
if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
|
31
|
+
},o.delay);
|
32
|
+
},
|
33
|
+
getMenu = function($menu){
|
34
|
+
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
|
35
|
+
sf.op = sf.o[menu.serial];
|
36
|
+
return menu;
|
37
|
+
},
|
38
|
+
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
|
39
|
+
|
40
|
+
return this.each(function() {
|
41
|
+
var s = this.serial = sf.o.length;
|
42
|
+
var o = $.extend({},sf.defaults,op);
|
43
|
+
o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
|
44
|
+
$(this).addClass([o.hoverClass,c.bcClass].join(' '))
|
45
|
+
.filter('li:has(ul)').removeClass(o.pathClass);
|
46
|
+
});
|
47
|
+
sf.o[s] = sf.op = o;
|
48
|
+
|
49
|
+
$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
|
50
|
+
if (o.autoArrows) addArrow( $('>a:first-child',this) );
|
51
|
+
})
|
52
|
+
.not('.'+c.bcClass)
|
53
|
+
.hideSuperfishUl();
|
54
|
+
|
55
|
+
var $a = $('a',this);
|
56
|
+
$a.each(function(i){
|
57
|
+
var $li = $a.eq(i).parents('li');
|
58
|
+
$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
|
59
|
+
});
|
60
|
+
o.onInit.call(this);
|
61
|
+
|
62
|
+
}).each(function() {
|
63
|
+
var menuClasses = [c.menuClass];
|
64
|
+
if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
|
65
|
+
$(this).addClass(menuClasses.join(' '));
|
66
|
+
});
|
67
|
+
};
|
68
|
+
|
69
|
+
var sf = $.fn.superfish;
|
70
|
+
sf.o = [];
|
71
|
+
sf.op = {};
|
72
|
+
sf.IE7fix = function(){
|
73
|
+
var o = sf.op;
|
74
|
+
if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
|
75
|
+
this.toggleClass(sf.c.shadowClass+'-off');
|
76
|
+
};
|
77
|
+
sf.c = {
|
78
|
+
bcClass : 'sf-breadcrumb',
|
79
|
+
menuClass : 'sf-js-enabled',
|
80
|
+
anchorClass : 'sf-with-ul',
|
81
|
+
arrowClass : 'sf-sub-indicator',
|
82
|
+
shadowClass : 'sf-shadow'
|
83
|
+
};
|
84
|
+
sf.defaults = {
|
85
|
+
hoverClass : 'sfHover',
|
86
|
+
pathClass : 'overideThisToUse',
|
87
|
+
pathLevels : 0,
|
88
|
+
delay : 0,
|
89
|
+
animation : {opacity:'show'},
|
90
|
+
speed : 0,
|
91
|
+
autoArrows : true,
|
92
|
+
dropShadows : true,
|
93
|
+
disableHI : false, // true disables hoverIntent detection
|
94
|
+
onInit : function(){}, // callback functions
|
95
|
+
onBeforeShow: function(){},
|
96
|
+
onShow : function(){},
|
97
|
+
onHide : function(){}
|
98
|
+
};
|
99
|
+
$.fn.extend({
|
100
|
+
hideSuperfishUl : function(){
|
101
|
+
var o = sf.op,
|
102
|
+
not = (o.retainPath===true) ? o.$path : '';
|
103
|
+
o.retainPath = false;
|
104
|
+
var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
|
105
|
+
.find('>ul').hide().css('visibility','hidden');
|
106
|
+
o.onHide.call($ul);
|
107
|
+
return this;
|
108
|
+
},
|
109
|
+
showSuperfishUl : function(){
|
110
|
+
var o = sf.op,
|
111
|
+
sh = sf.c.shadowClass+'-off',
|
112
|
+
$ul = this.addClass(o.hoverClass)
|
113
|
+
.find('>ul:hidden').css('visibility','visible');
|
114
|
+
sf.IE7fix.call($ul);
|
115
|
+
o.onBeforeShow.call($ul);
|
116
|
+
$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
|
117
|
+
return this;
|
118
|
+
}
|
119
|
+
});
|
120
|
+
|
121
|
+
})(jQuery);
|