jquery_drapper 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/.jshintrc
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
{
|
2
|
+
// Settings
|
3
|
+
"passfail" : false, // Stop on first error.
|
4
|
+
"maxerr" : 100, // Maximum error before stopping.
|
5
|
+
|
6
|
+
|
7
|
+
// Predefined globals whom JSHint will ignore.
|
8
|
+
"browser" : true, // Standard browser globals e.g. `window`, `document`.
|
9
|
+
|
10
|
+
"node" : false,
|
11
|
+
"rhino" : false,
|
12
|
+
"couch" : false,
|
13
|
+
"wsh" : false, // Windows Scripting Host.
|
14
|
+
|
15
|
+
"jquery" : true,
|
16
|
+
"prototypejs" : false,
|
17
|
+
"mootools" : false,
|
18
|
+
"dojo" : false,
|
19
|
+
|
20
|
+
"predef" : [ // Custom globals.
|
21
|
+
"console"
|
22
|
+
],
|
23
|
+
|
24
|
+
|
25
|
+
// Development.
|
26
|
+
"debug" : false, // Allow debugger statements e.g. browser breakpoints.
|
27
|
+
"devel" : true, // Allow developments statements e.g. `console.log();`.
|
28
|
+
|
29
|
+
|
30
|
+
// ECMAScript 5.
|
31
|
+
"es5" : true, // Allow ECMAScript 5 syntax.
|
32
|
+
"strict" : false, // Require `use strict` pragma in every file.
|
33
|
+
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
|
34
|
+
|
35
|
+
|
36
|
+
// The Good Parts.
|
37
|
+
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
|
38
|
+
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
|
39
|
+
"bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
|
40
|
+
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
|
41
|
+
"curly" : true, // Require {} for every new block or scope.
|
42
|
+
"eqeqeq" : true, // Require triple equals i.e. `===`.
|
43
|
+
"eqnull" : false, // Tolerate use of `== null`.
|
44
|
+
"evil" : false, // Tolerate use of `eval`.
|
45
|
+
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
|
46
|
+
"forin" : true, // Tolerate `for in` loops without `hasOwnPrototype`.
|
47
|
+
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
|
48
|
+
"latedef" : true, // Prohipit variable use before definition.
|
49
|
+
"loopfunc" : true, // Allow functions to be defined within loops.
|
50
|
+
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
|
51
|
+
"regexp" : true, // Prohibit `.` and `[^...]` in regular expressions.
|
52
|
+
"regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
|
53
|
+
"scripturl" : true, // Tolerate script-targeted URLs.
|
54
|
+
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
|
55
|
+
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
|
56
|
+
"undef" : true, // Require all non-global variables be declared before they are used.
|
57
|
+
|
58
|
+
|
59
|
+
// Personal styling preferences.
|
60
|
+
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
|
61
|
+
"noempty" : true, // Prohibit use of empty blocks.
|
62
|
+
"nonew" : true, // Prohibit use of constructors for side-effects.
|
63
|
+
"nomen" : false, // Prohibit use of initial or trailing underbars in names.
|
64
|
+
"onevar" : false, // Allow only one `var` statement per function.
|
65
|
+
"plusplus" : false, // Prohibit use of `++` & `--`.
|
66
|
+
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
|
67
|
+
"trailing" : true, // Prohibit trailing whitespaces.
|
68
|
+
"white" : true, // Check against strict whitespace and indentation rules.
|
69
|
+
"indent" : 2 // Specify indentation spacing
|
70
|
+
}
|
71
|
+
|
@@ -1,43 +1,44 @@
|
|
1
|
-
(function($) {
|
1
|
+
(function ($) {
|
2
2
|
$.drappers = {};
|
3
3
|
|
4
|
-
$.fn.drapper = function(options) {
|
4
|
+
$.fn.drapper = function (options) {
|
5
5
|
options = $.extend({}, options);
|
6
6
|
options.drapperIdentifier = "data-drapper";
|
7
7
|
options.elementSelector = options.elementSelector || '[' + options.drapperIdentifier + ']';
|
8
8
|
|
9
|
-
var drapperMethods = function(decoree){
|
10
|
-
var _hashConfig = (function() {
|
9
|
+
var drapperMethods = function (decoree) {
|
10
|
+
var _hashConfig = (function () {
|
11
11
|
var _rawAttributeData = $(decoree).attr(options.drapperIdentifier);
|
12
12
|
var result = {};
|
13
|
+
var _attributeData;
|
13
14
|
|
14
15
|
try {
|
15
|
-
|
16
|
-
} catch(e) {
|
17
|
-
throw("Drapper attributes are invalid. It should be as 'drapperName: config'. 'config' is a JSON. \n"
|
18
|
-
|
16
|
+
_attributeData = eval("({" + _rawAttributeData + "})"); //TODO: eval is evil
|
17
|
+
} catch (e) {
|
18
|
+
throw ("Drapper attributes are invalid. It should be as 'drapperName: config'. 'config' is a JSON. \n" +
|
19
|
+
"Original error message: \n" + e.message);
|
19
20
|
}
|
20
21
|
|
21
|
-
$.each(_attributeData, function(key, value) {
|
22
|
+
$.each(_attributeData, function (key, value) {
|
22
23
|
result['drapperType'] = key;
|
23
24
|
result['drapperConfig'] = value;
|
24
25
|
});
|
25
26
|
return result;
|
26
|
-
}
|
27
|
+
}());
|
27
28
|
|
28
|
-
var _type = function() { return _hashConfig.drapperType };
|
29
|
-
var config = function() { return _hashConfig.drapperConfig };
|
29
|
+
var _type = function () { return _hashConfig.drapperType; };
|
30
|
+
var config = function () { return _hashConfig.drapperConfig; };
|
30
31
|
|
31
32
|
function wrapper() {
|
32
|
-
var findFakeDiv = function() {
|
33
|
+
var findFakeDiv = function () {
|
33
34
|
var a = $(decoree).next('div[data-drapper-wrapper]');
|
34
|
-
if (a.length
|
35
|
+
if (a.length === 0) {
|
35
36
|
return false;
|
36
37
|
} else {
|
37
38
|
return a;
|
38
39
|
}
|
39
40
|
};
|
40
|
-
var createFakeDiv = function() {
|
41
|
+
var createFakeDiv = function () {
|
41
42
|
var fakeDiv = $(document.createElement('div'));
|
42
43
|
fakeDiv.attr({
|
43
44
|
'data-drapper-wrapper': true,
|
@@ -47,19 +48,19 @@
|
|
47
48
|
return fakeDiv;
|
48
49
|
};
|
49
50
|
return findFakeDiv() || createFakeDiv();
|
50
|
-
}
|
51
|
+
}
|
51
52
|
|
52
53
|
function drapperConverter() {
|
53
54
|
var converterPlugin = $.drappers[_type()];
|
54
55
|
|
55
56
|
if (converterPlugin === undefined) {
|
56
|
-
throw "Undefined drapper
|
57
|
-
|
58
|
-
|
57
|
+
throw "Undefined drapper extension '" + _type() + "'. " +
|
58
|
+
"Please, provide 'jquery.drapper.'" + _type() + "' plugin. " +
|
59
|
+
"See https://github.com/aratak/jquery_drapper/ for details.";
|
59
60
|
}
|
60
61
|
|
61
62
|
return converterPlugin.call(decoree);
|
62
|
-
}
|
63
|
+
}
|
63
64
|
|
64
65
|
function init() {
|
65
66
|
$.extend(decoree, {
|
@@ -69,17 +70,17 @@
|
|
69
70
|
'wrapper': wrapper
|
70
71
|
});
|
71
72
|
return drapperConverter();
|
72
|
-
}
|
73
|
+
}
|
73
74
|
|
74
75
|
return init();
|
75
|
-
}
|
76
|
+
};
|
76
77
|
|
77
|
-
return this.each(function() {
|
78
|
-
$(this).find(options.elementSelector).each(function() {
|
78
|
+
return this.each(function () {
|
79
|
+
$(this).find(options.elementSelector).each(function () {
|
79
80
|
if (!this.isDecoree) {
|
80
81
|
drapperMethods(this);
|
81
82
|
}
|
82
83
|
});
|
83
84
|
});
|
84
|
-
}
|
85
|
-
}
|
85
|
+
};
|
86
|
+
}(jQuery));
|
@@ -1,7 +1,7 @@
|
|
1
1
|
(function($) {
|
2
2
|
if($.fn.drapper === undefined) {
|
3
3
|
throw "$.drapper plugin hasn't been required"
|
4
|
-
+ "This plugin depends
|
4
|
+
+ "This plugin depends on 'jquery.drapper' plugin. "
|
5
5
|
+ "See https://github.com/aratak/jquery.drapper/ for details."
|
6
6
|
}
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
(function($) {
|
2
2
|
if($.fn.drapper === undefined) {
|
3
3
|
throw "$.drapper plugin hasn't been required"
|
4
|
-
+ "This plugin depends
|
4
|
+
+ "This plugin depends on 'jquery.drapper' plugin. "
|
5
5
|
+ "See https://github.com/aratak/jquery_drapper/ for details."
|
6
6
|
}
|
7
7
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexey Osipenko
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-02-28 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -48,6 +48,7 @@ extra_rdoc_files: []
|
|
48
48
|
|
49
49
|
files:
|
50
50
|
- .gitignore
|
51
|
+
- .jshintrc
|
51
52
|
- Gemfile
|
52
53
|
- MIT-LICENSE
|
53
54
|
- README.markdown
|