admin_data 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +221 -0
- data/README.textile +21 -0
- data/Rakefile +46 -0
- data/app/controllers/admin_data/base_controller.rb +114 -0
- data/app/controllers/admin_data/diagnostic_controller.rb +28 -0
- data/app/controllers/admin_data/feed_controller.rb +17 -0
- data/app/controllers/admin_data/main_controller.rb +132 -0
- data/app/controllers/admin_data/migration_controller.rb +19 -0
- data/app/controllers/admin_data/search_controller.rb +125 -0
- data/app/controllers/admin_data/validate_model_controller.rb +106 -0
- data/app/views/admin_data/diagnostic/index.html.erb +17 -0
- data/app/views/admin_data/diagnostic/missing_index.html.erb +26 -0
- data/app/views/admin_data/feed/index.rss.builder +24 -0
- data/app/views/admin_data/main/all_models.html.erb +22 -0
- data/app/views/admin_data/main/association/_association_info.html.erb +10 -0
- data/app/views/admin_data/main/association/_belongs_to_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_many_info.html.erb +7 -0
- data/app/views/admin_data/main/association/_has_one_info.html.erb +6 -0
- data/app/views/admin_data/main/edit.html.erb +38 -0
- data/app/views/admin_data/main/misc/_form.html.erb +25 -0
- data/app/views/admin_data/main/misc/_modify_record.html.erb +22 -0
- data/app/views/admin_data/main/new.html.erb +23 -0
- data/app/views/admin_data/main/show.html.erb +41 -0
- data/app/views/admin_data/main/table_structure.html.erb +55 -0
- data/app/views/admin_data/migration/index.html.erb +18 -0
- data/app/views/admin_data/migration/jstest.html.erb +51 -0
- data/app/views/admin_data/search/_search_base.html.erb +34 -0
- data/app/views/admin_data/search/advance_search.html.erb +3 -0
- data/app/views/admin_data/search/quick_search.html.erb +6 -0
- data/app/views/admin_data/search/search/_advance_search_form.html.erb +48 -0
- data/app/views/admin_data/search/search/_errors.html.erb +5 -0
- data/app/views/admin_data/search/search/_listing.html.erb +40 -0
- data/app/views/admin_data/search/search/_search_form.html.erb +28 -0
- data/app/views/admin_data/search/search/_sortby.html.erb +18 -0
- data/app/views/admin_data/search/search/_title.html.erb +34 -0
- data/app/views/admin_data/shared/_breadcrum.html.erb +10 -0
- data/app/views/admin_data/shared/_drop_down_klasses.html.erb +4 -0
- data/app/views/admin_data/shared/_flash_message.html.erb +13 -0
- data/app/views/admin_data/shared/_header.html.erb +23 -0
- data/app/views/admin_data/shared/_powered_by.html.erb +23 -0
- data/app/views/admin_data/shared/_secondary_navigation.html.erb +28 -0
- data/app/views/admin_data/validate_model/_bad.html.erb +1 -0
- data/app/views/admin_data/validate_model/tid.html.erb +2 -0
- data/app/views/admin_data/validate_model/validate.html.erb +67 -0
- data/app/views/layouts/admin_data.html.erb +60 -0
- data/config/routes.rb +34 -0
- data/init.rb +1 -0
- data/lib/admin_data.rb +34 -0
- data/lib/admin_data/chelper.rb +37 -0
- data/lib/admin_data/compatibility.rb +7 -0
- data/lib/admin_data/helpers.rb +222 -0
- data/lib/admin_data/railtie.rb +21 -0
- data/lib/admin_data/search.rb +186 -0
- data/lib/admin_data/settings.rb +72 -0
- data/lib/admin_data/util.rb +237 -0
- data/lib/admin_data/version.rb +3 -0
- data/lib/admin_data_date_validation.rb +79 -0
- data/lib/css/app.css +224 -0
- data/lib/css/base.css +1071 -0
- data/lib/css/header.css +65 -0
- data/lib/css/rounded.css +18 -0
- data/lib/css/themes/drastic-dark/style.css +374 -0
- data/lib/css/umbrella.css +34 -0
- data/lib/css/vendor/images/ui-bg_diagonals-thick_75_f3d8d8_40x40.png +0 -0
- data/lib/css/vendor/images/ui-bg_dots-small_65_a6a6a6_2x2.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_0_333333_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_65_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_glass_55_fbf8ee_1x400.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-hard_100_f6f6f6_1x100.png +0 -0
- data/lib/css/vendor/images/ui-bg_highlight-soft_15_cc0000_1x100.png +0 -0
- data/lib/css/vendor/images/ui-icons_004276_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_cc0000_256x240.png +0 -0
- data/lib/css/vendor/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/css/vendor/jquery-ui-1.7.2.custom.css +406 -0
- data/lib/css/vendor/qunit.css +119 -0
- data/lib/js/advance_search/act_on_result.js +47 -0
- data/lib/js/advance_search/adv_search.js +46 -0
- data/lib/js/advance_search/advance_search.js +60 -0
- data/lib/js/advance_search/advance_search_structure.js +79 -0
- data/lib/js/advance_search/ajaxify_advance_search.js +28 -0
- data/lib/js/advance_search/build_first_row.js +12 -0
- data/lib/js/advance_search/event_bindings.js +87 -0
- data/lib/js/advance_search/global_ajax_setting.js +10 -0
- data/lib/js/advance_search/trigger_submit_on_domready.js +6 -0
- data/lib/js/misc/drop_down_change.js +8 -0
- data/lib/js/misc/js_util.js +42 -0
- data/lib/js/misc/quick_search_input_focus.js +6 -0
- data/lib/js/test/act_on_result.js +120 -0
- data/lib/js/test/advance_search.js +80 -0
- data/lib/js/test/ajaxify_advance_search.js +29 -0
- data/lib/js/test/build_first_row.js +10 -0
- data/lib/js/test/event_bindings.js +100 -0
- data/lib/js/validate_model/ajaxify_form.js +66 -0
- data/lib/js/validate_model/select_all.js +15 -0
- data/lib/js/vendor/jack.js +903 -0
- data/lib/js/vendor/jquery-1.4.1.js +6078 -0
- data/lib/js/vendor/jquery-ui-1.7.2.custom.min.js +298 -0
- data/lib/js/vendor/jquery.ba-isjquery.js +21 -0
- data/lib/js/vendor/jquery.form.js +814 -0
- data/lib/js/vendor/jquery.lint.js +604 -0
- data/lib/js/vendor/log.js +9 -0
- data/lib/js/vendor/qunit.js +1043 -0
- data/lib/tasks/admin_data_tasks.rake +7 -0
- data/lib/tasks/validate_models_bg.rake +23 -0
- data/test/factories/article.rb +9 -0
- data/test/factories/car.rb +4 -0
- data/test/factories/city.rb +4 -0
- data/test/factories/comment.rb +6 -0
- data/test/factories/door.rb +4 -0
- data/test/factories/engine.rb +4 -0
- data/test/functional/base_controller_test.rb +5 -0
- data/test/functional/feed_controller_test.rb +34 -0
- data/test/functional/main_controller_test.rb +421 -0
- data/test/functional/migration_controller_test.rb +30 -0
- data/test/functional/routes_test.rb +61 -0
- data/test/functional/search_controller_test.rb +814 -0
- data/test/helper/view_helper_test.rb +177 -0
- data/test/misc_tests/date_validation_test.rb +32 -0
- data/test/misc_tests/settings_test.rb +29 -0
- data/test/misc_tests/util_test.rb +83 -0
- data/test/rails_root/Gemfile +22 -0
- data/test/rails_root/Gemfile.lock +101 -0
- data/test/rails_root/Rakefile +7 -0
- data/test/rails_root/app/controllers/application_controller.rb +3 -0
- data/test/rails_root/app/helpers/application_helper.rb +2 -0
- data/test/rails_root/app/models/article.rb +25 -0
- data/test/rails_root/app/models/city.rb +15 -0
- data/test/rails_root/app/models/comment.rb +13 -0
- data/test/rails_root/app/models/tech_magazine.rb +2 -0
- data/test/rails_root/app/models/vehicle/car.rb +4 -0
- data/test/rails_root/app/models/vehicle/door.rb +3 -0
- data/test/rails_root/app/models/vehicle/engine.rb +3 -0
- data/test/rails_root/app/views/layouts/application.html.erb +14 -0
- data/test/rails_root/config.ru +4 -0
- data/test/rails_root/config/application.rb +42 -0
- data/test/rails_root/config/boot.rb +13 -0
- data/test/rails_root/config/database.yml +22 -0
- data/test/rails_root/config/environment.rb +5 -0
- data/test/rails_root/config/environments/development.rb +22 -0
- data/test/rails_root/config/environments/production.rb +49 -0
- data/test/rails_root/config/environments/test.rb +35 -0
- data/test/rails_root/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_root/config/initializers/inflections.rb +10 -0
- data/test/rails_root/config/initializers/mime_types.rb +5 -0
- data/test/rails_root/config/initializers/secret_token.rb +7 -0
- data/test/rails_root/config/initializers/session_store.rb +8 -0
- data/test/rails_root/config/locales/en.yml +5 -0
- data/test/rails_root/config/routes.rb +58 -0
- data/test/rails_root/db/migrate/20090809061114_create_tables.rb +70 -0
- data/test/rails_root/db/schema.rb +74 -0
- data/test/rails_root/db/seeds.rb +7 -0
- data/test/rails_root/script/rails +6 -0
- data/test/rails_root/test/performance/browsing_test.rb +0 -0
- data/test/rails_root/test/test_helper.rb +13 -0
- data/test/support/assertions.rb +20 -0
- data/test/test_helper.rb +74 -0
- metadata +321 -0
@@ -0,0 +1,604 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Lint
|
3
|
+
* ---
|
4
|
+
* VERSION 0.2
|
5
|
+
* ---
|
6
|
+
* jQuery lint creates a thin blanket over jQuery that'll
|
7
|
+
* report any potentially erroneous activity the console.
|
8
|
+
* ---
|
9
|
+
* Idea from:
|
10
|
+
* http://markmail.org/message/wzkosk2s5jklpkv4
|
11
|
+
* http://groups.google.com/group/jquery-dev/browse_thread/thread/9a15cca62ceb2444
|
12
|
+
* ---
|
13
|
+
* @author James Padolsey
|
14
|
+
* @contributors ...
|
15
|
+
* ---
|
16
|
+
* Dual licensed under the MIT and GPL licenses.
|
17
|
+
* - http://www.opensource.org/licenses/mit-license.php
|
18
|
+
* - http://www.gnu.org/copyleft/gpl.html
|
19
|
+
*/
|
20
|
+
|
21
|
+
(function(){
|
22
|
+
|
23
|
+
var alias = 'jQuery',
|
24
|
+
|
25
|
+
// Define console if not defined
|
26
|
+
// Feel free to edit this
|
27
|
+
_console = {
|
28
|
+
warn: window.console && console.warn || function(){},
|
29
|
+
group: window.console && console.group || function(){},
|
30
|
+
groupEnd: window.console && console.groupEnd || function(){},
|
31
|
+
groupCollapsed: window.console && console.groupCollapsed || function(){},
|
32
|
+
log: window.console && console.log || function(){}
|
33
|
+
},
|
34
|
+
|
35
|
+
langs = {
|
36
|
+
en: {
|
37
|
+
incorrectCall: '%0(...) called incorrectly',
|
38
|
+
specialCheckFailed: '%0(...) special check failed',
|
39
|
+
moreInfo: 'More info:',
|
40
|
+
youPassed: 'You passed: ',
|
41
|
+
collection: 'Collection:',
|
42
|
+
availableSigsInclude: 'Available signatures include: ',
|
43
|
+
errorThrown: 'When I called %0(...) with your args, an error was thrown!',
|
44
|
+
repeatSelector: 'You\'ve used the same selector more than once.',
|
45
|
+
info: 'Info',
|
46
|
+
selector: 'Selector: ',
|
47
|
+
selectorAdvice: 'You should only use the same selector more than once when you know the returned collection will be different. For example, if you\'ve added more elements to the page that may comply with the selector',
|
48
|
+
noElementsFound: 'No elements were found with the selector: "%0"',
|
49
|
+
combineCalls: 'Why not combine these calls by passing an object? E.g. \n%0(%1)',
|
50
|
+
methodTwice: 'You\'ve called %0(...) more than once on the same jQuery object',
|
51
|
+
triggeredBy: 'Triggered by %0 event',
|
52
|
+
event: 'Event:',
|
53
|
+
handler: 'Handler:',
|
54
|
+
location: 'Location:'
|
55
|
+
}
|
56
|
+
},
|
57
|
+
|
58
|
+
// Add specific checks
|
59
|
+
// This is the best place to bring up bad practices
|
60
|
+
specialChecks = [
|
61
|
+
{/* Level 0 */},
|
62
|
+
{/* Level 1 */},
|
63
|
+
{/* Level 2 */},
|
64
|
+
{/* Level 3 */}
|
65
|
+
],
|
66
|
+
|
67
|
+
// Local scope jQuery
|
68
|
+
_jQuery = window[alias],
|
69
|
+
|
70
|
+
lint = {
|
71
|
+
level: 3,
|
72
|
+
special: specialChecks,
|
73
|
+
lang: 'en',
|
74
|
+
langs: langs,
|
75
|
+
console: _console
|
76
|
+
},
|
77
|
+
|
78
|
+
// Only cover certain fns under the jQ namespace
|
79
|
+
jQNameSpace = /^(ajax|get|post|proxy|each|map|queue|ajax.+|removeData|data|pushStack)$/,
|
80
|
+
|
81
|
+
// API data, only with what we need
|
82
|
+
api = {"jQuery.proxy":[{added:"1.4",arg:[{name:"function",type:"Function"},{name:"scope",type:"Object"}]},{added:"1.4",arg:[{name:"scope",type:"Object"},{name:"name",type:"String"}]}],focusout:[{added:"1.4",arg:[{name:"handler(eventObject)",type:"Function"}]}],focusin:[{added:"1.4",arg:[{name:"handler(eventObject)",type:"Function"}]}],has:[{added:"1.4",arg:[{name:"selector",type:"String"}]},{added:"1.4",arg:[{name:"contained",type:"Element"}]},{added:"1.1.4"}],"jQuery.contains":[{added:"1.4",arg:[{name:"container",type:"Element"},{name:"contained",type:"Element"}]}],"jQuery.noop":[{added:"1.4"}],delay:[{added:"1.4",arg:[{name:"duration",type:"Integer"},{name:"queueName",type:"String",optional:true}]}],parentsUntil:[{added:"1.4",arg:[{name:"selector",type:"Selector",optional:true}]}],prevUntil:[{added:"1.4",arg:[{name:"selector",type:"Selector",optional:true}]}],nextUntil:[{added:"1.4",arg:[{name:"selector",type:"Selector",optional:true}]}],"event.isImmediatePropagationStopped":[{added:"1.3"}],"event.stopImmediatePropagation":[{added:"1.3"}],"event.isPropagationStopped":[{added:"1.3"}],"event.stopPropagation":[{added:"1.0"}],"event.isDefaultPrevented":[{added:"1.3"}],"event.preventDefault":[{added:"1.0"}],"event.timeStamp":[{added:"1.2.6"}],"event.result":[{added:"1.3"}],"event.which":[{added:"1.1.3"}],"event.pageY":[{added:"1.0.4"}],"event.pageX":[{added:"1.0.4"}],"event.currentTarget":[{added:"1.3"}],"event.relatedTarget":[{added:"1.1.4"}],"event.data":[{added:"1.1"}],"event.target":[{added:"1.0"}],"event.type":[{added:"1.0"}],"jQuery.fx.off":[{added:"1.3"}],each:[{added:"1.0",arg:[{name:"function(index, Element)",type:"Function"}]}],"jQuery.pushStack":[{added:"1.0",arg:[{name:"elements",type:"Array"}]},{added:"1.3",arg:[{name:"elements",type:"Array"},{name:"name",type:"String"},{name:"arguments",type:"Array"}]}],"jQuery.globalEval":[{added:"1.0.4",arg:[{name:"code",type:"String"}]}],"jQuery.isXMLDoc":[{added:"1.1.4",arg:[{name:"node",type:"Element"}]}],"jQuery.removeData":[{added:"1.2.3",arg:[{name:"name",type:"String",optional:true}]}],"jQuery.data":[{added:"1.2.3",arg:[{name:"element",type:"Element"},{name:"key",type:"String"},{name:"value",type:"Object"}]},{added:"1.2.3",arg:[{name:"element",type:"Element"},{name:"key",type:"String"}]},{added:"1.4"}],"jQuery.dequeue":[{added:"1.3",arg:[{name:"queueName",type:"String",optional:true}]}],"jQuery.queue":[{added:"1.3",arg:[{name:"queueName",type:"String",optional:true}]},{added:"1.3",arg:[{name:"queueName",type:"String",optional:true},{name:"newQueue",type:"Array"}]},{added:"1.3",arg:[{name:"queueName",type:"String",optional:true},{name:"callback()",type:"Function"}]}],clearQueue:[{added:"1.4",arg:[{name:"queueName",type:"String",optional:true}]}],toArray:[{added:"1.4"}],"jQuery.isEmptyObject":[{added:"1.4",arg:[{name:"object",type:"Object"}]}],"jQuery.isPlainObject":[{added:"1.4",arg:[{name:"object",type:"Object"}]}],keydown:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],index:[{added:"1.4"},{added:"1.4",arg:[{name:"selector",type:"Selector"}]},{added:"1.0",arg:[{name:"element",type:"Element, jQuery"}]}],removeData:[{added:"1.2.3",arg:[{name:"name",type:"String",optional:true}]}],data:[{added:"1.2.3",arg:[{name:"key",type:"String"},{name:"value",type:"Object"}]},{added:"1.4",arg:[{name:"obj",type:"Object"}]},{added:"1.2.3",arg:[{name:"key",type:"String"}]},{added:"1.4"}],get:[{added:"1.0",arg:[{name:"index",type:"Number",optional:true}]}],size:[{added:"1.0"}],"jQuery.noConflict":[{added:"1.0",arg:[{name:"removeAll",type:"Boolean",optional:true}]}],selected:[{added:"1.0"}],checked:[{added:"1.0"}],disabled:[{added:"1.0"}],enabled:[{added:"1.0"}],file:[{added:"1.0"}],button:[{added:"1.0"}],reset:[{added:"1.0"}],image:[{added:"1.0"}],submit:[{added:"1.0"},{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],checkbox:[{added:"1.0"}],radio:[{added:"1.0"}],password:[{added:"1.0"}],text:[{added:"1.0"},{added:"1.0"},{added:"1.0",arg:[{name:"textString",type:"String"}]},{added:"1.4",arg:[{name:"function(index, text)",type:"Function"}]}],input:[{added:"1.0"}],"only-child":[{added:"1.1.4"}],"last-child":[{added:"1.1.4"}],"first-child":[{added:"1.1.4"}],"nth-child":[{added:"1.1.4",arg:[{name:"index",type:"Number/String"}]}],attributeContainsPrefix:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeContainsWord:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeMultiple:[{added:"1.0",arg:[{name:"attributeFilter1",type:"Selector"},{name:"attributeFilter2",type:"Selector"},{name:"attributeFilterN",type:"Selector",optional:true}]}],attributeContains:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeEndsWith:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeStartsWith:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeNotEqual:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeEquals:[{added:"1.0",arg:[{name:"attribute",type:"String"},{name:"value",type:"String"}]}],attributeHas:[{added:"1.0",arg:[{name:"attribute",type:"String"}]}],visible:[{added:"1.0"}],hidden:[{added:"1.0"}],parent:[{added:"1.0"},{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],empty:[{added:"1.0"},{added:"1.0"}],contains:[{added:"1.1.4"}],animated:[{added:"1.2"}],header:[{added:"1.2"}],lt:[{added:"1.0",arg:[{name:"index",type:"Number"}]}],gt:[{added:"1.0"}],eq:[{added:"1.0",arg:[{name:"index",type:"Number"}]},{added:"1.1.2",arg:[{name:"index",type:"Integer"}]}],odd:[{added:"1.0"}],even:[{added:"1.0"}],not:[{added:"1.0",arg:[{name:"selector",type:"Selector"}]},{added:"1.0",arg:[{name:"selector",type:"Selector"}]},{added:"1.0",arg:[{name:"elements",type:"Elements"}]},{added:"1.0",arg:[{name:"function(index)",type:"Function"}]}],last:[{added:"1.0"},{added:"1.2"}],first:[{added:"1.0"},{added:"1.2"}],"next siblings":[{added:"1.0",arg:[{name:"prev",type:"Selector"},{name:"siblings",type:"Selector"}]}],"next adjacent":[{added:"1.0",arg:[{name:"prev",type:"Selector"},{name:"next",type:"Selector"}]}],child:[{added:"1.0",arg:[{name:"parent",type:"Selector"},{name:"child",type:"Selector"}]}],descendant:[{added:"1.0",arg:[{name:"ancestor",type:"Selector"},{name:"descendant",type:"Selector"}]}],multiple:[{added:"1.0",arg:[{name:"selector1",type:"Selector"},{name:"selector2",type:"Selector"},{name:"selectorN",type:"Selector",optional:true}]}],all:[{added:"1.0"}],"class":[{added:"1.0",arg:[{name:"class",type:"String"}]}],element:[{added:"1.0",arg:[{name:"element",type:"String"}]}],id:[{added:"1.0",arg:[{name:"id",type:"String"}]}],scroll:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],resize:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],dequeue:[{added:"1.2",arg:[{name:"queueName",type:"String",optional:true}]}],queue:[{added:"1.2",arg:[{name:"queueName",type:"String",optional:true}]},{added:"1.2",arg:[{name:"queueName",type:"String",optional:true},{name:"newQueue",type:"Array"}]},{added:"1.2",arg:[{name:"queueName",type:"String",optional:true},{name:"callback( next )",type:"Function"}]}],keyup:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],keypress:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],select:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],change:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],blur:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],focus:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mousemove:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],hover:[{added:"1.0",arg:[{name:"handlerIn(eventObject)",type:"Function"},{name:"handlerOut(eventObject)",type:"Function"}]}],mouseleave:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mouseenter:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mouseout:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mouseover:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],dblclick:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],click:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mouseup:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],mousedown:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0"}],error:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]}],unload:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]}],load:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"}]},{added:"1.0",arg:[{name:"url",type:"String"},{name:"data",type:"Map, String",optional:true},{name:"success(responseText, textStatus, XMLHttpRequest)",type:"Function",optional:true}]}],ready:[{added:"1.0",arg:[{name:"handler",type:"Function"}]}],die:[{added:"1.3",arg:[{name:"eventType",type:"String"},{name:"handler",type:"String",optional:true}]}],"jQuery.browser":[{added:"1.0"}],"jQuery.browser.version":[{added:"1.1.3"}],live:[{added:"1.3",arg:[{name:"eventType",type:"String"},{name:"handler",type:"Function"}]},{added:"1.4",arg:[{name:"eventType",type:"String"},{name:"eventData",type:"Object",optional:true},{name:"handler",type:"Function"}]}],triggerHandler:[{added:"1.2",arg:[{name:"eventType",type:"String"},{name:"extraParameters",type:"Array",optional:true}]}],trigger:[{added:"1.0",arg:[{name:"eventType",type:"String"},{name:"extraParameters",type:"Array"}]}],ajaxComplete:[{added:"1.0",arg:[{name:"handler(event, XMLHttpRequest, ajaxOptions)",type:"Function"}]}],one:[{added:"1.1",arg:[{name:"eventType",type:"String"},{name:"eventData",type:"Object",optional:true},{name:"handler(eventObject)",type:"Function"}]}],serializeArray:[{added:"1.2"}],serialize:[{added:"1.0"}],"jQuery.ajaxSetup":[{added:"1.1",arg:[{name:"options",type:"Options"}]}],ajaxSuccess:[{added:"1.0",arg:[{name:"handler(event, XMLHttpRequest, ajaxOptions)",type:"Function"}]}],ajaxStop:[{added:"1.0",arg:[{name:"handler()",type:"Function"}]}],ajaxStart:[{added:"1.0",arg:[{name:"handler()",type:"Function"}]}],ajaxSend:[{added:"1.0",arg:[{name:"handler(event, XMLHttpRequest, ajaxOptions)",type:"Function"}]}],ajaxError:[{added:"1.0",arg:[{name:"handler(event, XMLHttpRequest, ajaxOptions, thrownError)",type:"Function"}]}],unbind:[{added:"1.0",arg:[{name:"eventType",type:"String"},{name:"handler(eventObject)",type:"Function"}]},{added:"1.0",arg:[{name:"event",type:"Object"}]}],bind:[{added:"1.0",arg:[{name:"eventType",type:"String"},{name:"eventData",type:"Object",optional:true},{name:"handler(eventObject)",type:"Function"}]},{added:"1.4",arg:[{name:"events",type:"Object"}]}],slice:[{added:"1.1.4",arg:[{name:"start",type:"Integer"}]},{added:"1.1.4",arg:[{name:"end",type:"Integer",optional:true}]}],jQuery:[{added:"1.0",arg:[{name:"selector",type:"selector"},{name:"context",type:"Element, jQuery",optional:true}]},{added:"1.0",arg:[{name:"element",type:"Element"}]},{added:"1.0",arg:[{name:"elementArray",type:"Array"}]},{added:"1.0",arg:[{name:"jQuery object",type:"Object"}]},{added:"1.4"},{added:"1.0",arg:[{name:"html",type:"String"},{name:"ownerDocument",type:"document",optional:true}]},{added:"1.4",arg:[{name:"html",type:"String"},{name:"props",type:"Object"}]},{added:"1.0",arg:[{name:"callback",type:"Function"}]}],stop:[{added:"1.2",arg:[{name:"clearQueue",type:"Boolean",optional:true},{name:"jumpToEnd",type:"Boolean",optional:true}]}],end:[{added:"1.0"}],andSelf:[{added:"1.2"}],siblings:[{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],animate:[{added:"1.0",arg:[{name:"properties",type:"Options"},{name:"duration",type:"String,Number",optional:true},{name:"easing",type:"String",optional:true},{name:"callback",type:"Callback",optional:true}]},{added:"1.0",arg:[{name:"properties",type:"Options"},{name:"options",type:"Options"}]}],prevAll:[{added:"1.2",arg:[{name:"selector",type:"Selector",optional:true}]}],prev:[{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],fadeTo:[{added:"1.0",arg:[{name:"duration",type:"String,Number"},{name:"opacity",type:"Number"},{name:"callback",type:"Callback",optional:true}]}],fadeOut:[{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]}],parents:[{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],fadeIn:[{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]}],offsetParent:[{added:"1.26"}],slideToggle:[{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]}],"jQuery.post":[{added:"1.0",arg:[{name:"url",type:"String"},{name:"data",type:"Map, String",optional:true},{name:"success(data, textStatus)",type:"Function",optional:true},{name:"dataType",type:"String",optional:true}]}],slideUp:[{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]}],nextAll:[{added:"1.2",arg:[{name:"selector",type:"String",optional:true}]}],next:[{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],slideDown:[{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]}],find:[{added:"1.0",arg:[{name:"selector",type:"Selector"}]}],"jQuery.getScript":[{added:"1.0",arg:[{name:"url",type:"String"},{name:"success(data, textStatus)",type:"Function",optional:true}]}],contents:[{added:"1.2"}],closest:[{added:"1.3",arg:[{name:"selector",type:"Selector"}]},{added:"1.4",arg:[{name:"selector",type:"Selector"},{name:"context",type:"Element",optional:true}]},{added:"1.4",arg:[{name:"selectors",type:"Array"},{name:"context",type:"Element",optional:true}]}],"jQuery.getJSON":[{added:"1.0",arg:[{name:"url",type:"String"},{name:"data",type:"Map",optional:true},{name:"callback(data, textStatus)",type:"Function",optional:true}]}],"jQuery.get":[{added:"1.0",arg:[{name:"url",type:"String"},{name:"data",type:"Map, String",optional:true},{name:"callback(data, textStatus, XMLHttpRequest)",type:"Function",optional:true},{name:"dataType",type:"String",optional:true}]}],"jQuery.ajax":[{added:"1.0",arg:[{name:"settings",type:"Map"}]}],length:[{added:"1.0"}],children:[{added:"1.0",arg:[{name:"selector",type:"Selector",optional:true}]}],selector:[{added:"1.3"}],add:[{added:"1.0",arg:[{name:"selector",type:"Selector"}]},{added:"1.0",arg:[{name:"elements",type:"Elements"}]},{added:"1.0",arg:[{name:"html",type:"HTML"}]},{added:"1.4",arg:[{name:"selector",type:"Selector"},{name:"context",type:"Element"}]}],context:[{added:"1.3"}],outerWidth:[{added:"1.2.6",arg:[{name:"includeMargin",type:"Boolean",optional:true}]}],outerHeight:[{added:"1.2.6",arg:[{name:"includeMargin",type:"Boolean",optional:true}]}],toggle:[{added:"1.0",arg:[{name:"handler(eventObject)",type:"Function"},{name:"handler(eventObject)",type:"Function"},{name:"handler(eventObject)",type:"Function",optional:true}]},{added:"1.0",arg:[{name:"duration",type:"String,Number",optional:true},{name:"callback",type:"Callback",optional:true}]},{added:"1.3",arg:[{name:"showOrHide",type:"Boolean"}]}],innerWidth:[{added:"1.2.6"}],innerHeight:[{added:"1.2.6"}],"jQuery.param":[{added:"1.2",arg:[{name:"obj",type:"Array, Object"}]},{added:"1.4",arg:[{name:"obj",type:"Array, Object"},{name:"traditional",type:"Boolean"}]}],hide:[{added:"1.0"},{added:"1.0",arg:[{name:"duration",type:"String,Number"},{name:"callback",type:"",optional:true}]}],width:[{added:"1.0"},{added:"1.0",arg:[{name:"value",type:"String, Number"}]}],height:[{added:"1.0"},{added:"1.0",arg:[{name:"value",type:"String, Number"}]}],show:[{added:"1.0"},{added:"1.0",arg:[{name:"duration",type:"String,Number"},{name:"callback",type:"Callback",optional:true}]}],scrollLeft:[{added:"1.2.6"},{added:"1.2.6",arg:[{name:"value",type:"Number"}]}],"jQuery.trim":[{added:"1.0"}],"jQuery.isFunction":[{added:"1.2"}],"jQuery.isArray":[{added:"1.3",arg:[{name:"obj",type:"Object"}]}],"jQuery.unique":[{added:"1.1.3",arg:[{name:"array",type:"Array"}]}],"jQuery.merge":[{added:"1.0",arg:[{name:"first",type:"Array"},{name:"second",type:"Array"}]}],"jQuery.inArray":[{added:"1.2",arg:[{name:"value",type:"Any"},{name:"array",type:"Array"}]}],"jQuery.map":[{added:"1.0",arg:[{name:"array",type:"Array"},{name:"callback(elementOfArray, indexInArray)",type:"Function"}]}],"jQuery.makeArray":[{added:"1.2",arg:[{name:"obj",type:"Object"}]}],"jQuery.grep":[{added:"1.0",arg:[{name:"array",type:"Array"},{name:"function(elementOfArray, indexInArray)",type:"Function"},{name:"invert",type:"Boolean",optional:true}]}],"jQuery.extend":[{added:"1.0",arg:[{name:"target",type:"Object"},{name:"object1",type:"Object",optional:true},{name:"objectN",type:"Object",optional:true}]},{added:"1.1.4",arg:[{name:"deep",type:"Boolean",optional:true},{name:"target",type:"Object"},{name:"object1",type:"Object"},{name:"objectN",type:"Object",optional:true}]}],"jQuery.each":[{added:"1.0",arg:[{name:"object",type:"Object"},{name:"callback(indexInArray, valueOfElement)",type:"Function"}]}],"jQuery.boxModel":[{added:"1.0"}],scrollTop:[{added:"1.2.6"},{added:"1.2.6",arg:[{name:"value",type:"Number"}]}],"jQuery.support":[{added:"1.3"}],position:[{added:"1.2"}],offset:[{added:"1.2"},{added:"1.4",arg:[{name:"coordinates",type:"Object"}]},{added:"1.4",arg:[{name:"function(index, coords)",type:"Function"}]}],css:[{added:"1.0",arg:[{name:"propertyName",type:"String"}]},{added:"1.0",arg:[{name:"propertyName",type:"String"},{name:"value",type:"String, Number"}]},{added:"1.4",arg:[{name:"propertyName",type:"String"},{name:"function(index, value)",type:"Function"}]},{added:"1.0",arg:[{name:"map",type:"Map"}]}],unwrap:[{added:"1.4"}],detach:[{added:"1.4",arg:[{name:"selector",type:"Selector",optional:true}]}],clone:[{added:"1.0",arg:[{name:"withDataAndEvents",type:"Boolean",optional:true}]}],remove:[{added:"1.0",arg:[{name:"selector",type:"String",optional:true}]}],replaceAll:[{added:"1.2"}],replaceWith:[{added:"1.2",arg:[{name:"newContent",type:"String, Element, jQuery"}]},{added:"1.4",arg:[{name:"function",type:"Function"}]}],wrapInner:[{added:"1.2",arg:[{name:"wrappingElement",type:"String"}]},{added:"1.4",arg:[{name:"wrappingFunction",type:"Function"}]}],wrapAll:[{added:"1.2",arg:[{name:"wrappingElement",type:"String, Selector, Element, jQuery"}]}],wrap:[{added:"1.0",arg:[{name:"wrappingElement",type:"String, Selector, Element, jQuery"}]},{added:"1.4",arg:[{name:"wrappingFunction",type:"Function"}]}],insertBefore:[{added:"1.0",arg:[{name:"target",type:"Selector, Element, jQuery"}]}],before:[{added:"1.0",arg:[{name:"content",type:"String, Element, jQuery"}]},{added:"1.4",arg:[{name:"function",type:"Function"}]}],insertAfter:[{added:"1.0",arg:[{name:"target",type:"Selector, Element, jQuery"}]}],after:[{added:"1.0",arg:[{name:"content",type:"String, Element, jQuery"}]},{added:"1.4",arg:[{name:"function",type:"Function"}]}],prependTo:[{added:"1.0",arg:[{name:"target",type:"Selector, Element, jQuery"}]}],prepend:[{added:"1.0",arg:[{name:"content",type:"String, Element, jQuery"}]},{added:"1.4",arg:[{name:"function(index, html)",type:"Function"}]}],appendTo:[{added:"1.0",arg:[{name:"target",type:"Selector, Element, jQuery"}]}],append:[{added:"1.0",arg:[{name:"content",type:"String, Element, jQuery"}]},{added:"1.4",arg:[{name:"function(index, html)",type:"Function"}]}],val:[{added:"1.0"},{added:"1.0",arg:[{name:"value",type:"String"}]},{added:"1.4",arg:[{name:"function",type:"Function"}]}],html:[{added:"1.0"},{added:"1.0",arg:[{name:"htmlString",type:"String"}]},{added:"1.4",arg:[{name:"function(index, html)",type:"Function"}]}],map:[{added:"1.2",arg:[{name:"callback(index, domElement)",type:"Function"}]}],is:[{added:"1.0",arg:[{name:"selector",type:"Selector"}]}],filter:[{added:"1.0",arg:[{name:"selector",type:"Selector"}]},{added:"1.0",arg:[{name:"function(index)",type:"Function"}]}],toggleClass:[{added:"1.0",arg:[{name:"className",type:"String"}]},{added:"1.3",arg:[{name:"className",type:"String"},{name:"switch",type:"Boolean"}]},{added:"1.4",arg:[{name:"function(index, class)",type:"Function"},{name:"switch",type:"Boolean",optional:true}]}],removeClass:[{added:"1.0",arg:[{name:"className",type:"String",optional:true}]},{added:"1.4",arg:[{name:"function(index, class)",type:"Function"}]}],hasClass:[{added:"1.2",arg:[{name:"className",type:"String"}]}],removeAttr:[{added:"1.0",arg:[{name:"attributeName",type:"String"}]}],attr:[{added:"1.0",arg:[{name:"attributeName",type:"String"}]},{added:"1.0",arg:[{name:"attributeName",type:"String"},{name:"value",type:"Object"}]},{added:"1.0",arg:[{name:"map",type:"Map"}]},{added:"1.1",arg:[{name:"attributeName",type:"String"},{name:"function(index, attr)",type:"Function"}]}],addClass:[{added:"1.0",arg:[{name:"className",type:"String"}]},{added:"1.4",arg:[{name:"function(index, class)",type:"Function"}]}]};
|
83
|
+
|
84
|
+
if ( !_jQuery ) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
|
88
|
+
lint.api = api;
|
89
|
+
|
90
|
+
// Correct API
|
91
|
+
// Yes, it's ugly, but necessary...
|
92
|
+
api['jQuery.data'][1].arg[1].optional = true; // Making $.data(.,THIS) optional
|
93
|
+
api.each[0].arg[1] = api['jQuery.each'][0].arg[2] = {name:'args', type:'Array', optional:true};
|
94
|
+
api['jQuery.data'][0].arg[2].type = '*';
|
95
|
+
api.attr[1].arg[1].type = '*';
|
96
|
+
api['jQuery.each'][0].arg[0].type += ', Array';
|
97
|
+
// extraParam to trigger & triggerHandler IS optional
|
98
|
+
api.trigger[0].arg[1].optional = true;
|
99
|
+
api.triggerHandler[0].arg[1].optional = true;
|
100
|
+
api.slice[0].arg[1] = {name:'end',type:'Integer',optional:true};
|
101
|
+
// Add elem arg to start of args for jQuery.queue
|
102
|
+
var jQQueue = api['jQuery.queue'];
|
103
|
+
jQQueue[0].arg.unshift({type:'Element', name:'elem'});
|
104
|
+
jQQueue[1].arg.unshift({type:'Element', name:'elem'});
|
105
|
+
jQQueue[2].arg.unshift({type:'Element', name:'elem'});
|
106
|
+
|
107
|
+
|
108
|
+
var version = _jQuery.fn.jquery,
|
109
|
+
map = _jQuery.map,
|
110
|
+
each = _jQuery.each,
|
111
|
+
extend = _jQuery.extend,
|
112
|
+
locale = langs[lint.lang],
|
113
|
+
undefined,
|
114
|
+
slice = function(a,s,e) {
|
115
|
+
return Array.prototype.slice.call(a, s || 0, e || a.length);
|
116
|
+
},
|
117
|
+
compare = function(a,b) {
|
118
|
+
|
119
|
+
// Compare two arrays
|
120
|
+
|
121
|
+
var i = a.length;
|
122
|
+
|
123
|
+
if (a.length !== b.length) {
|
124
|
+
return false;
|
125
|
+
}
|
126
|
+
|
127
|
+
while (i--) {
|
128
|
+
if (a[i] !== b[i]) {
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
return true;
|
134
|
+
|
135
|
+
},
|
136
|
+
isFunction = function(obj) {
|
137
|
+
return toString.call(obj) === "[object Function]";
|
138
|
+
},
|
139
|
+
isArray = function(obj) {
|
140
|
+
return toString.call(obj) === "[object Array]";
|
141
|
+
},
|
142
|
+
toString = Object.prototype.toString,
|
143
|
+
typeToString = function(o) {
|
144
|
+
|
145
|
+
if (typeof o === 'string') {
|
146
|
+
return '"' + o.replace(/"/g,'\\"') + '"';
|
147
|
+
}
|
148
|
+
|
149
|
+
if (isFunction(o)) {
|
150
|
+
return 'function(){...}';
|
151
|
+
}
|
152
|
+
|
153
|
+
return o.toString();
|
154
|
+
},
|
155
|
+
shaveArray = function(arr) {
|
156
|
+
arr = Array.prototype.slice.call(arr);
|
157
|
+
// Shave "undefined" off the end of args
|
158
|
+
for (var i = arr.length; i--;) {
|
159
|
+
if (arr[i] === undefined) {
|
160
|
+
arr.splice(i, 1);
|
161
|
+
} else {
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
return arr;
|
166
|
+
},
|
167
|
+
// type map
|
168
|
+
types = {
|
169
|
+
'*': function() {
|
170
|
+
return true;
|
171
|
+
},
|
172
|
+
selector: function(o) {
|
173
|
+
return this.String(o);
|
174
|
+
},
|
175
|
+
Selector: function(o) {
|
176
|
+
return this.selector(o);
|
177
|
+
},
|
178
|
+
Element: function(o) {
|
179
|
+
return o && (!!o.nodeName || o === window);
|
180
|
+
},
|
181
|
+
Elements: function(o) {
|
182
|
+
return this.jQuery(o) || this.Array(o);
|
183
|
+
},
|
184
|
+
Array: function(o) {
|
185
|
+
// Just check that it's "array-like"
|
186
|
+
return o && o.length !== undefined
|
187
|
+
&& typeof o !== 'string' && !isFunction(o);
|
188
|
+
},
|
189
|
+
jQuery: function(o) {
|
190
|
+
return o instanceof _jQuery;
|
191
|
+
},
|
192
|
+
Object: function(o) {
|
193
|
+
return toString.call(o) === '[object Object]';
|
194
|
+
},
|
195
|
+
Function: function(o) {
|
196
|
+
return isFunction(o);
|
197
|
+
},
|
198
|
+
Callback: function(o) {
|
199
|
+
return isFunction(o);
|
200
|
+
},
|
201
|
+
String: function(o) {
|
202
|
+
return typeof o === 'string';
|
203
|
+
},
|
204
|
+
Number: function(o) {
|
205
|
+
return typeof o === 'number' && !isNaN(o);
|
206
|
+
},
|
207
|
+
Integer: function(o) {
|
208
|
+
return this.Number(o) && ~~o === o;
|
209
|
+
},
|
210
|
+
Map: function(o) {
|
211
|
+
return this.Object(o);
|
212
|
+
},
|
213
|
+
Options: function(o) {
|
214
|
+
return this.Object(o);
|
215
|
+
},
|
216
|
+
'null': function(o) {
|
217
|
+
return o === null;
|
218
|
+
}
|
219
|
+
},
|
220
|
+
typeCheck = function typeCheck(type, arg) {
|
221
|
+
|
222
|
+
// Check that argument is of the right type
|
223
|
+
// The types are specified within the API data
|
224
|
+
|
225
|
+
if ( types[type] ) {
|
226
|
+
return arg !== undefined && types[type](arg);
|
227
|
+
}
|
228
|
+
|
229
|
+
if ( type.indexOf(',') ) {
|
230
|
+
|
231
|
+
var split = type.split(/,\s?/g),
|
232
|
+
i = split.length;
|
233
|
+
|
234
|
+
while (i--) {
|
235
|
+
if (types[split[i]] && types[split[i]](arg)) {
|
236
|
+
return true;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
return false;
|
241
|
+
}
|
242
|
+
|
243
|
+
return false;
|
244
|
+
|
245
|
+
},
|
246
|
+
complies = function complies(args, sig) {
|
247
|
+
|
248
|
+
// Determine if argument list complies with
|
249
|
+
// signature outlined in API.
|
250
|
+
|
251
|
+
var matches = false,
|
252
|
+
sigArg,
|
253
|
+
argLength = args.length;
|
254
|
+
|
255
|
+
if (version < sig.added) {
|
256
|
+
// Too new
|
257
|
+
return false;
|
258
|
+
}
|
259
|
+
|
260
|
+
if (!sig.arg) {
|
261
|
+
return 0 === args.length;
|
262
|
+
}
|
263
|
+
|
264
|
+
if (!sig.arg[0] && (args.length > 1)) {
|
265
|
+
return false;
|
266
|
+
}
|
267
|
+
|
268
|
+
for (
|
269
|
+
var sigIndex = 0,
|
270
|
+
argIndex = 0,
|
271
|
+
fullLength = Math.max(argLength,sig.arg.length||1);
|
272
|
+
sigIndex < fullLength || argIndex < argLength;
|
273
|
+
++sigIndex
|
274
|
+
) {
|
275
|
+
|
276
|
+
sigArg = sigIndex === 0 ? sig.arg[0] || sig.arg : sig.arg[sigIndex];
|
277
|
+
|
278
|
+
if (!sigArg) {
|
279
|
+
// Too many args
|
280
|
+
return false;
|
281
|
+
}
|
282
|
+
|
283
|
+
matches = typeCheck(sigArg.type, args[argIndex]);
|
284
|
+
|
285
|
+
if (!matches) {
|
286
|
+
if (sigArg.optional) {
|
287
|
+
if (args[argIndex] === undefined || args[argIndex] === null) {
|
288
|
+
++argIndex;
|
289
|
+
matches = true;
|
290
|
+
}
|
291
|
+
continue;
|
292
|
+
} else {
|
293
|
+
// Sig isn't optional, return false
|
294
|
+
return false;
|
295
|
+
}
|
296
|
+
}
|
297
|
+
|
298
|
+
++argIndex;
|
299
|
+
|
300
|
+
}
|
301
|
+
|
302
|
+
return matches;
|
303
|
+
|
304
|
+
},
|
305
|
+
logLocation = function() {
|
306
|
+
try {
|
307
|
+
throw new Error();
|
308
|
+
} catch(e) {
|
309
|
+
if (e.stack) {
|
310
|
+
lint.console.groupCollapsed(locale.location);
|
311
|
+
lint.console.log(e.stack.replace(
|
312
|
+
/^.+?\n|.+?(jquery\.lint\.js|http:\/\/ajax\.googleapis\.com\/ajax\/libs).+?(\n|$)|.+?(?=@)/g, ''
|
313
|
+
));
|
314
|
+
lint.console.groupEnd();
|
315
|
+
} else {
|
316
|
+
return null;
|
317
|
+
}
|
318
|
+
}
|
319
|
+
},
|
320
|
+
selectorCache = {},
|
321
|
+
lastTriggeredEvent = {},
|
322
|
+
logEvent = function() {
|
323
|
+
if (lastTriggeredEvent && lastTriggeredEvent.event) {
|
324
|
+
_console.groupCollapsed(locale.triggeredBy.replace(/%0/, lastTriggeredEvent.event.type));
|
325
|
+
_console.log(locale.event, lastTriggeredEvent.event);
|
326
|
+
_console.groupCollapsed(locale.handler);
|
327
|
+
_console.log(lastTriggeredEvent.handler);
|
328
|
+
_console.groupEnd();
|
329
|
+
_console.groupEnd();
|
330
|
+
}
|
331
|
+
},
|
332
|
+
internal = false;
|
333
|
+
|
334
|
+
function coverMethod(name, meth, args) {
|
335
|
+
|
336
|
+
args = shaveArray(args);
|
337
|
+
|
338
|
+
var sigs = api[name],
|
339
|
+
_console = lint.console,
|
340
|
+
i = 0,
|
341
|
+
sig,
|
342
|
+
specialCheckResults = (function(){
|
343
|
+
|
344
|
+
// Perform special checks for current level and
|
345
|
+
// all levels below current level.
|
346
|
+
|
347
|
+
var lvl = lint.level + 1,
|
348
|
+
checks = [];
|
349
|
+
|
350
|
+
while (lvl--) {
|
351
|
+
if (specialChecks[lvl] && specialChecks[lvl][name]) {
|
352
|
+
checks.push(
|
353
|
+
specialChecks[lvl][name].apply(this, args)
|
354
|
+
)
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
return checks;
|
359
|
+
|
360
|
+
})(),
|
361
|
+
signatureMatch = false,
|
362
|
+
self = this,
|
363
|
+
sliced = slice(this, 0, 10),
|
364
|
+
withinEvent = lastTriggeredEvent ? lastTriggeredEvent.type : null;
|
365
|
+
|
366
|
+
if (!sigs || !lint.level || internal) {
|
367
|
+
return meth.apply(this, args);
|
368
|
+
}
|
369
|
+
|
370
|
+
if (this.length > 10) {
|
371
|
+
sliced.push('...');
|
372
|
+
}
|
373
|
+
|
374
|
+
// Check for calls like css().css().css()
|
375
|
+
// May as well use css({...})
|
376
|
+
if (lint.level > 2 && args[1] && !isFunction(args[1]) && /^(css|attr)$/.test(name) || (name === 'bind' && version >= '1.4')) {
|
377
|
+
|
378
|
+
if (this._lastMethodCalled === name) {
|
379
|
+
_console.warn(locale.methodTwice.replace(/%0/, name));
|
380
|
+
_console.groupCollapsed(locale.moreInfo);
|
381
|
+
logEvent();
|
382
|
+
if (this instanceof _jQuery) {
|
383
|
+
_console.log(locale.collection, sliced);
|
384
|
+
}
|
385
|
+
_console.log(
|
386
|
+
locale.combineCalls
|
387
|
+
.replace(/%0/, name)
|
388
|
+
.replace(/%1/, '{\n' +
|
389
|
+
map([args, this._lastMethodArgs], function(a){
|
390
|
+
return ' "' + a[0] + '": ' + typeToString(a[1]);
|
391
|
+
}).join(',\n')
|
392
|
+
+ '\n}')
|
393
|
+
);
|
394
|
+
_console.groupEnd();
|
395
|
+
}
|
396
|
+
|
397
|
+
this._lastMethodCalled = name;
|
398
|
+
this._lastMethodArgs = args;
|
399
|
+
setTimeout(function(){
|
400
|
+
self._lastMethodCalled = null;
|
401
|
+
self._lastMethodArgs = null;
|
402
|
+
});
|
403
|
+
|
404
|
+
}
|
405
|
+
|
406
|
+
// Check all arguments passed to method for compliance
|
407
|
+
// against the corresponding signature.
|
408
|
+
while ((sig = sigs[i++])) {
|
409
|
+
if ( complies(args, sig) ) {
|
410
|
+
signatureMatch = true;
|
411
|
+
break;
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
if (!signatureMatch) {
|
416
|
+
|
417
|
+
try {
|
418
|
+
|
419
|
+
// Args !== signature
|
420
|
+
_console.warn(locale.incorrectCall.replace(/%0/, name));
|
421
|
+
_console.groupCollapsed(locale.moreInfo);
|
422
|
+
logEvent();
|
423
|
+
if (this instanceof _jQuery) {
|
424
|
+
_console.log(locale.collection, sliced);
|
425
|
+
}
|
426
|
+
logLocation();
|
427
|
+
_console.log(locale.youPassed, args);
|
428
|
+
_console.group(locale.availableSigsInclude);
|
429
|
+
each(sigs, function(i, sig){
|
430
|
+
if (version < sig.added) {
|
431
|
+
return;
|
432
|
+
}
|
433
|
+
var sigArgs = sig.arg;
|
434
|
+
_console.log(
|
435
|
+
name + '(' +
|
436
|
+
(sigArgs ?
|
437
|
+
sigArgs[0] ?
|
438
|
+
map(sigArgs, function(sig){
|
439
|
+
return sig ? sig.optional ? '[' + sig.name + ']' : sig.name : [];
|
440
|
+
}).join(', ') :
|
441
|
+
sigArgs.name
|
442
|
+
: '') + ')'
|
443
|
+
);
|
444
|
+
});
|
445
|
+
_console.groupEnd();
|
446
|
+
_console.groupEnd();
|
447
|
+
|
448
|
+
} catch(e) { }
|
449
|
+
|
450
|
+
}
|
451
|
+
|
452
|
+
try {
|
453
|
+
if (specialCheckResults.length) {
|
454
|
+
each(specialCheckResults, function(i, checkResult){
|
455
|
+
if (checkResult && checkResult !== true) {
|
456
|
+
_console.warn(locale.specialCheckFailed.replace(/%0/, name));
|
457
|
+
_console.groupCollapsed(locale.moreInfo);
|
458
|
+
if (this instanceof _jQuery) {
|
459
|
+
_console.log(locale.collection, sliced);
|
460
|
+
}
|
461
|
+
logLocation();
|
462
|
+
_console.log(checkResult);
|
463
|
+
_console.groupEnd();
|
464
|
+
}
|
465
|
+
});
|
466
|
+
}
|
467
|
+
} catch(e) { }
|
468
|
+
|
469
|
+
|
470
|
+
try {
|
471
|
+
return meth.apply(this, args);
|
472
|
+
} catch(e) {
|
473
|
+
try {
|
474
|
+
_console.warn(
|
475
|
+
locale.errorThrown.replace(/%0/, name), e
|
476
|
+
);
|
477
|
+
_console.groupCollapsed(locale.moreInfo);
|
478
|
+
logLocation();
|
479
|
+
_console.log(locale.youPassed, args);
|
480
|
+
_console.groupEnd();
|
481
|
+
} catch(e) { }
|
482
|
+
return this;
|
483
|
+
}
|
484
|
+
|
485
|
+
}
|
486
|
+
|
487
|
+
// "Cover" init constructor
|
488
|
+
// Reports when no elements found, and when selector
|
489
|
+
// used more than once to no effect.
|
490
|
+
_jQuery.fn.init = (function(_init){
|
491
|
+
|
492
|
+
return function(s,c) {
|
493
|
+
|
494
|
+
var ret = coverMethod.call(this, 'jQuery', function(){
|
495
|
+
|
496
|
+
// Set internal flag to avoid incorrect internal method
|
497
|
+
// calls being reported by Lint.
|
498
|
+
|
499
|
+
internal = true;
|
500
|
+
var instance = new _init(s, c);
|
501
|
+
internal = false;
|
502
|
+
|
503
|
+
return instance
|
504
|
+
|
505
|
+
}, arguments),
|
506
|
+
_console = lint.console;
|
507
|
+
|
508
|
+
try{
|
509
|
+
if (typeof s === 'string' && lint.level > 1) {
|
510
|
+
if (!ret[0]) {
|
511
|
+
// No elements returned
|
512
|
+
_console.warn(locale.noElementsFound.replace(/%0/, s));
|
513
|
+
} else {
|
514
|
+
// Check for identical collection already in cache.
|
515
|
+
if ( selectorCache[s] && compare(selectorCache[s], ret) ) {
|
516
|
+
|
517
|
+
_console.warn(locale.repeatSelector);
|
518
|
+
_console.groupCollapsed(locale.info);
|
519
|
+
logEvent();
|
520
|
+
logLocation();
|
521
|
+
_console.log(locale.selector + '"' + s + '"');
|
522
|
+
_console.log(locale.selectorAdvice);
|
523
|
+
_console.groupEnd();
|
524
|
+
|
525
|
+
}
|
526
|
+
}
|
527
|
+
selectorCache[s] = ret;
|
528
|
+
}
|
529
|
+
} catch(e) { }
|
530
|
+
|
531
|
+
return ret;
|
532
|
+
|
533
|
+
};
|
534
|
+
|
535
|
+
})(_jQuery.fn.init);
|
536
|
+
|
537
|
+
// Cover all methods, except init
|
538
|
+
for (var i in _jQuery.fn) {
|
539
|
+
if (i === 'init' || !isFunction(_jQuery.fn[i])) {
|
540
|
+
continue;
|
541
|
+
}
|
542
|
+
_jQuery.fn[i] = (function(meth, name){
|
543
|
+
return function() {
|
544
|
+
return coverMethod.call(this, name, function(){
|
545
|
+
|
546
|
+
// Set internal flag.
|
547
|
+
// Any subsequent method calls before this
|
548
|
+
// returns will be ignored. This is to stop
|
549
|
+
// errors being reported from incorrect usage
|
550
|
+
// of jQuery's API, internally.
|
551
|
+
|
552
|
+
internal = true;
|
553
|
+
var ret = meth.apply(this, arguments);
|
554
|
+
internal = false;
|
555
|
+
|
556
|
+
return ret;
|
557
|
+
|
558
|
+
}, arguments);
|
559
|
+
};
|
560
|
+
})(_jQuery.fn[i], i);
|
561
|
+
}
|
562
|
+
|
563
|
+
// Cover some helper function under jQ namespace
|
564
|
+
for (var i in _jQuery) {
|
565
|
+
|
566
|
+
if ( !jQNameSpace.test(i) || !isFunction(_jQuery[i]) ) {
|
567
|
+
continue;
|
568
|
+
}
|
569
|
+
|
570
|
+
_jQuery[i] = (function(meth, name){
|
571
|
+
return function() {
|
572
|
+
return coverMethod.call(this, 'jQuery.' + name, function(){
|
573
|
+
internal = true;
|
574
|
+
var ret = meth.apply(this, arguments);
|
575
|
+
internal = false;
|
576
|
+
return ret;
|
577
|
+
}, arguments);
|
578
|
+
};
|
579
|
+
})(_jQuery[i], i);
|
580
|
+
}
|
581
|
+
|
582
|
+
_jQuery.LINT = lint;
|
583
|
+
|
584
|
+
_jQuery.event.add = (function(_add){
|
585
|
+
|
586
|
+
// Each triggered event gets assigned to lastTriggeredEvent,
|
587
|
+
// Which is immediately nulled after a zero timeout.
|
588
|
+
|
589
|
+
return function(elem, types, handler, data) {
|
590
|
+
var _handler = handler;
|
591
|
+
handler = function(e) {
|
592
|
+
lastTriggeredEvent = {event: e, handler: _handler.toString()};
|
593
|
+
setTimeout(function(){
|
594
|
+
lastTriggeredEvent = null
|
595
|
+
}, 0);
|
596
|
+
return _handler.apply(this, arguments);
|
597
|
+
};
|
598
|
+
return _add.call(this, elem, types, handler, data);
|
599
|
+
};
|
600
|
+
|
601
|
+
})(_jQuery.event.add);
|
602
|
+
|
603
|
+
|
604
|
+
})();
|