-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixit.js
53 lines (36 loc) · 1.03 KB
/
fixit.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
(function( $ ){
var notEnabledMsg = "Fixit.js has not been given permission to fix this page. Stop being a coward, and allow access.";
var fixedMsg = "This page has been fixed. You're welcome.";
var methods = {
fixit: function(){
if(options.doFix){
$('html').html(fixedMsg);
} else {
if(window.console){
console.warn(notEnabledMsg);
} else {
alert(notEnabledMsg);
}
}
}
}; // end methods
// the plugin function
$.fixit = function( userOptions ) {
/*
Offer only a single option - which the user
must manually set to true so that he is fully
aware that all issues are to be resolved in a timely manner.
*/
options = $.extend({
doFix: false
}, userOptions);
// assigning this to plugin's global scope.
// This just tends to make my life easier
_this = this;
// fix your broken crap
methods.fixit();
// return this for chaining, which is admittedly silly,
// since after everything is "fixed", chaining becomes obsolete
return this
};
})( jQuery );