-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjQueryDocs.py
More file actions
47 lines (41 loc) · 1.95 KB
/
jQueryDocs.py
File metadata and controls
47 lines (41 loc) · 1.95 KB
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
import sublime, sublime_plugin, webbrowser, re
class JqueryDocsCommand(sublime_plugin.TextCommand):
def run(self, edit):
def clean_up(text, listing):
for value in listing:
text = text.replace(value, '')
return text
# get current user selection and strip all non-letter symbols
regex = re.compile('[^a-zA-Z]')
keyword = regex.sub('', self.view.substr(self.view.sel()[0]))
# define which keyword needs additional "jQuery." param appended
# not included yet: jQuery.fn.extend, jQuery.fx.interval, jQuery.fx.off
jquery_prefix = [
"ajax", "ajaxPrefilter", "ajaxSetup", "ajaxTransport",
"boxModel", "browser",
"Callbacks", "contains", "cssHooks",
"data", "Deferred", "dequeue",
"each", "error", "extend",
"get", "getJSON", "getScript", "globalEval", "grep",
"hasData", "holdReady",
"inArray", "isArray", "isEmptyObject", "isFunction", "isNumeric", "isPlainObject", "isWindow", "isXMLDoc",
"makeArray", "map", "merge",
"noConflict", "noop", "now",
"param", "parseHTML", "parseJSON", "parseXML", "post", "proxy",
"queue",
"removeData",
"sub", "support",
"trim", "type",
"unique",
"when"
]
# iterate over jquery_prefix list and append "jQuery." to the keyword
for value in jquery_prefix:
if keyword == value:
keyword = "jQuery." + keyword
# open jQuery Docs in Browser and print a message to the user
if not keyword:
sublime.status_message("Opening jQuery Docs. Check your Browser :)")
else:
sublime.status_message("Opening jQuery Docs for: \"" + keyword + "\". Check your Browser :)")
webbrowser.open_new("http://api.jquery.com/" + keyword)