golf 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/golf/version.rb +1 -1
- data/resources/jquery.golf.js +68 -37
- metadata +58 -6
data/lib/golf/version.rb
CHANGED
data/resources/jquery.golf.js
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
(function($) {
|
2
2
|
|
3
3
|
function toJson(obj) {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
return new String(obj);
|
27
|
-
}
|
4
|
+
switch (typeof obj) {
|
5
|
+
case 'object':
|
6
|
+
if (obj) {
|
7
|
+
var list = [];
|
8
|
+
if (obj instanceof Array) {
|
9
|
+
for (var i=0;i < obj.length;i++)
|
10
|
+
list.push(toJson(obj[i]));
|
11
|
+
return '[' + list.join(',') + ']';
|
12
|
+
} else {
|
13
|
+
for (var prop in obj)
|
14
|
+
list.push('"' + prop + '":' + toJson(obj[prop]));
|
15
|
+
return '{' + list.join(',') + '}';
|
16
|
+
}
|
17
|
+
} else {
|
18
|
+
return 'null';
|
19
|
+
}
|
20
|
+
case 'string':
|
21
|
+
return '"' + obj.replace(/(["'])/g, '\\$1') + '"';
|
22
|
+
case 'number':
|
23
|
+
case 'boolean':
|
24
|
+
return new String(obj);
|
25
|
+
}
|
28
26
|
}
|
29
27
|
|
30
28
|
function Component() {
|
@@ -36,6 +34,9 @@ function Component() {
|
|
36
34
|
this.show = function() {
|
37
35
|
this._dom.show(Array.prototype.slice.call(arguments));
|
38
36
|
};
|
37
|
+
this.toggle = function() {
|
38
|
+
this._dom.toggle(Array.prototype.slice.call(arguments));
|
39
|
+
};
|
39
40
|
}
|
40
41
|
|
41
42
|
function Debug(prefix) {
|
@@ -400,6 +401,25 @@ function componentConstructor(name) {
|
|
400
401
|
obj.require = $fake.require;
|
401
402
|
obj.$ = $fake;
|
402
403
|
checkForReservedClass(obj._dom.children().find("*"));
|
404
|
+
|
405
|
+
// find <component> elements and replace them w/components
|
406
|
+
obj._dom.find("component").each(function(i,v) {
|
407
|
+
var jself = $(v), type, ref, argv, c, i, attrs, attr;
|
408
|
+
for (i=0,attrs=v.attributes,argv={};i<attrs.length;i++) {
|
409
|
+
attr = attrs.item(i);
|
410
|
+
switch (attr.nodeName) {
|
411
|
+
case "new": type = attr.nodeValue; break;
|
412
|
+
case "ref": ref = attr.nodeValue; break;
|
413
|
+
default: argv[attr.nodeName]=attr.nodeValue;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
eval("c = Component."+type);
|
417
|
+
c = new c(argv);
|
418
|
+
jself.replaceWith(c);
|
419
|
+
if (ref)
|
420
|
+
obj[ref] = c;
|
421
|
+
});
|
422
|
+
|
403
423
|
doCall(obj, $fake, $fake, argv, cmp.js, Debug(name));
|
404
424
|
obj._dom.removeData("_golf_constructing");
|
405
425
|
jss.mark(obj._dom.children().eq(0));
|
@@ -444,6 +464,13 @@ window.Component = Component;
|
|
444
464
|
};
|
445
465
|
})($.fn.bind);
|
446
466
|
|
467
|
+
function doOnAppend(cmp) {
|
468
|
+
if (!cmp.didOnAppend) {
|
469
|
+
cmp.didOnAppend = true;
|
470
|
+
cmp.onAppend();
|
471
|
+
}
|
472
|
+
}
|
473
|
+
|
447
474
|
$.each(
|
448
475
|
[
|
449
476
|
"append",
|
@@ -468,10 +495,14 @@ window.Component = Component;
|
|
468
495
|
$("*", e).each(function(index, elem) {
|
469
496
|
var cmp = $(elem).data("_golf_component");
|
470
497
|
if (cmp instanceof Component && cmp.onAppend)
|
471
|
-
cmp
|
498
|
+
doOnAppend(cmp);
|
472
499
|
});
|
473
|
-
if (a instanceof Component
|
474
|
-
|
500
|
+
if (a instanceof Component) {
|
501
|
+
// run onAppend event handler if one is defined
|
502
|
+
if (a.onAppend)
|
503
|
+
doOnAppend(a);
|
504
|
+
}
|
505
|
+
|
475
506
|
return $(this);
|
476
507
|
};
|
477
508
|
}
|
@@ -482,8 +513,12 @@ window.Component = Component;
|
|
482
513
|
var cmps = [];
|
483
514
|
$("*", this).add([this]).each(function(index, elem) {
|
484
515
|
var cmp = $(elem).data("_golf_component");
|
485
|
-
|
516
|
+
// save component<->dom mapping and remove onAppend flag
|
517
|
+
if (cmp) {
|
486
518
|
cmps.push({component: cmp, dom: elem});
|
519
|
+
// this will cause onAppend to run on next insertion into the dom
|
520
|
+
cmp.didOnAppend = false;
|
521
|
+
}
|
487
522
|
if ($(this).attr("golfid"))
|
488
523
|
$.golf.events[$(this).attr("golfid")] = [];
|
489
524
|
});
|
@@ -616,18 +651,14 @@ $.golf = {
|
|
616
651
|
return $.golf.location.hash;
|
617
652
|
},
|
618
653
|
|
619
|
-
|
620
|
-
|
621
|
-
.replace(/</g, "<")
|
622
|
-
.replace(/>/g, ">")
|
623
|
-
.replace(/"/g, """);
|
624
|
-
},
|
625
|
-
|
626
|
-
addComponent: function(cmp) {
|
654
|
+
createComponent: function(cmp) {
|
655
|
+
// create dom elements from html source
|
627
656
|
cmp.html = $("<div/>")._golf_append(
|
628
657
|
$(cmp.html)._golf_addClass("component")
|
629
658
|
._golf_addClass(cmp.name.replace(".", "-"))
|
630
659
|
);
|
660
|
+
|
661
|
+
// strip off the wrapper div and set component dom elements
|
631
662
|
cmp.dom = $(cmp.html.html());
|
632
663
|
|
633
664
|
var m, pkg;
|
@@ -658,7 +689,7 @@ $.golf = {
|
|
658
689
|
|
659
690
|
d("Loading components/ directory...");
|
660
691
|
for (name in $.golf.components)
|
661
|
-
$.golf.
|
692
|
+
$.golf.createComponent($.golf.components[name]);
|
662
693
|
|
663
694
|
if (!window.forcebot) {
|
664
695
|
d("Loading styles/ directory...");
|
metadata
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: golf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
- 7
|
9
|
+
version: 0.5.7
|
6
10
|
platform: ruby
|
7
11
|
authors:
|
8
12
|
- Micha Niskin, Alan Dipert, Julio Capote
|
@@ -10,7 +14,7 @@ autorequire:
|
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
16
|
|
13
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-15 00:00:00 -04:00
|
14
18
|
default_executable:
|
15
19
|
dependencies:
|
16
20
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +25,8 @@ dependencies:
|
|
21
25
|
requirements:
|
22
26
|
- - ">="
|
23
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
24
30
|
version: "0"
|
25
31
|
type: :runtime
|
26
32
|
version_requirements: *id001
|
@@ -32,6 +38,8 @@ dependencies:
|
|
32
38
|
requirements:
|
33
39
|
- - ">="
|
34
40
|
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
35
43
|
version: "0"
|
36
44
|
type: :runtime
|
37
45
|
version_requirements: *id002
|
@@ -43,6 +51,8 @@ dependencies:
|
|
43
51
|
requirements:
|
44
52
|
- - ">="
|
45
53
|
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
46
56
|
version: "0"
|
47
57
|
type: :runtime
|
48
58
|
version_requirements: *id003
|
@@ -54,6 +64,8 @@ dependencies:
|
|
54
64
|
requirements:
|
55
65
|
- - ">="
|
56
66
|
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
57
69
|
version: "0"
|
58
70
|
type: :runtime
|
59
71
|
version_requirements: *id004
|
@@ -216,19 +228,59 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
228
|
requirements:
|
217
229
|
- - ">="
|
218
230
|
- !ruby/object:Gem::Version
|
231
|
+
segments:
|
232
|
+
- 0
|
219
233
|
version: "0"
|
220
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
235
|
none: false
|
222
236
|
requirements:
|
223
237
|
- - ">="
|
224
238
|
- !ruby/object:Gem::Version
|
239
|
+
segments:
|
240
|
+
- 0
|
225
241
|
version: "0"
|
226
242
|
requirements: []
|
227
243
|
|
228
244
|
rubyforge_project: golf
|
229
|
-
rubygems_version: 1.
|
245
|
+
rubygems_version: 1.3.7
|
230
246
|
signing_key:
|
231
247
|
specification_version: 3
|
232
248
|
summary: Component based front end JS Framework
|
233
|
-
test_files:
|
234
|
-
|
249
|
+
test_files:
|
250
|
+
- test/reference_app/golfapp/components.js
|
251
|
+
- test/reference_app/golfapp/components/HelloWorld/HelloWorld.css
|
252
|
+
- test/reference_app/golfapp/components/HelloWorld/HelloWorld.html
|
253
|
+
- test/reference_app/golfapp/components/HelloWorld/HelloWorld.js
|
254
|
+
- test/reference_app/golfapp/components/golf/cart/Admin/Admin.html
|
255
|
+
- test/reference_app/golfapp/components/golf/cart/Cart/Cart.html
|
256
|
+
- test/reference_app/golfapp/components/golf/cart/Product/Product.html
|
257
|
+
- test/reference_app/golfapp/components/golf/cart/ProductListing/ProductListing.html
|
258
|
+
- test/reference_app/golfapp/components/golf/cart/Store/Store.html
|
259
|
+
- test/reference_app/golfapp/controller.js
|
260
|
+
- test/reference_app/golfapp/img/ Timer & Non-Stick.jpeg
|
261
|
+
- test/reference_app/golfapp/img/134lines.jpeg
|
262
|
+
- test/reference_app/golfapp/img/Q33 Sail Plan.jpeg
|
263
|
+
- test/reference_app/golfapp/img/a/asdf
|
264
|
+
- test/reference_app/golfapp/img/a/b/c/zxcv
|
265
|
+
- test/reference_app/golfapp/img/a/b/qwer
|
266
|
+
- test/reference_app/golfapp/img/em> - Brushed Stainless Steel.jpeg
|
267
|
+
- test/reference_app/golfapp/img/em> - White.jpeg
|
268
|
+
- test/reference_app/golfapp/img/em> Broil CTO7100B.jpeg
|
269
|
+
- test/reference_app/golfapp/img/em> Broiler - Stainless.jpeg
|
270
|
+
- test/reference_app/golfapp/img/em> with Countdo.jpeg
|
271
|
+
- test/reference_app/golfapp/img/em> with Element IQ.jpeg
|
272
|
+
- test/reference_app/golfapp/img/em> with OneTouch ...jpeg
|
273
|
+
- test/reference_app/golfapp/img/em> with Pizza.jpeg
|
274
|
+
- test/reference_app/golfapp/img/em>-1.jpeg
|
275
|
+
- test/reference_app/golfapp/img/em>-2.jpeg
|
276
|
+
- test/reference_app/golfapp/img/em>-3.jpeg
|
277
|
+
- test/reference_app/golfapp/img/em>-Black.jpeg
|
278
|
+
- test/reference_app/golfapp/img/em>.jpeg
|
279
|
+
- test/reference_app/golfapp/img/unnamed.jpeg
|
280
|
+
- test/reference_app/golfapp/plugins/mylib.js
|
281
|
+
- test/reference_app/golfapp/scripts/00-myscript.js
|
282
|
+
- test/reference_app/golfapp/scripts/01-jquery.tmpl.js
|
283
|
+
- test/reference_app/golfapp/styles/main.css
|
284
|
+
- test/test_compiler.rb
|
285
|
+
- test/test_helper.rb
|
286
|
+
- test/test_rack.rb
|