flok 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6d0bf2af8dafa5f4e70828c942096912a6515a2
4
- data.tar.gz: 7799b952d8fee6d672dd3adbbeffab4a555443b7
3
+ metadata.gz: 3406b13f8cf50a7c88224afaf47441a6ca0d128f
4
+ data.tar.gz: 8c4d7feb578ab38b1a9f4a60760cfec5fd00a268
5
5
  SHA512:
6
- metadata.gz: a14b3378b0add68d5920b472c20fe1994d93967d9b916065eaddb0dccd87d4fbbcb4a4b00d0110cf7200309780afb6f9281761ec9aa0d96b356f3295f23985e4
7
- data.tar.gz: 8737ab63f4acc6d9c6a7587545560f09f0797e99a4a179f4c77757c6a89759a68a15e2c50b83be610e284c70071ce895ce921767edb53fb24b9e86a0c373cabc
6
+ metadata.gz: 50461e1bb7cbf544067d8746d0163620c25573dfc12dffc941c8f2f380610721f11b866427aa08a7f4c1c3e2fa80ac1e1a982b4e86dca1fdb02ef5fb4dc9b949
7
+ data.tar.gz: 8c43c4cd297e7b7bc5f37c5ee34b2c9e1ed9ae73562e459863aaf69dfe5fd4e7d0e51a73b734f104d2a46940ed8ce9feb1fb499b6cfe2e985f4bc27f8faed892
@@ -64,9 +64,19 @@ var TestController = function() {
64
64
  $(document).ready(function() {
65
65
  regController("__test__", TestController);
66
66
  });
67
-
68
67
  ```
69
68
 
69
+ ### DOM helpers
70
+ ```html
71
+ <!-- This will place the contents of context.foo into the divider -->
72
+ <div data-puts="foo"></div>
73
+
74
+ <!-- You can also use an attribute, just place it before the variable -->
75
+ <img data-puts="src foo" />
76
+
77
+ <!-- You can send events via the emit tag -->
78
+ <button data-emit='button_clicked'>Click me</button>
79
+
70
80
  ### ERB Compliation
71
81
  The final `chrome.js` file is run through an `ERB` compiler that contains the variables:
72
82
  * `@debug` - True if `FLOK_ENV=DEBUG`
@@ -47,7 +47,7 @@ task :spec do
47
47
  f.spec_js_init << "./spec/config/**/*.js"
48
48
  f.spec_js << "./spec/spec/**/*_spec.js"
49
49
  f.app_js << File.join(ENV['BUILD_PATH'], './chrome.js')
50
- f.app_js << File.join(ENV['BUILD_PATH'], '../application.js')
50
+ #f.app_js << File.join(ENV['BUILD_PATH'], '../application.js')
51
51
  end
52
52
 
53
53
  recipe.bake
@@ -62,7 +62,7 @@ task :spec do
62
62
  sh2("boojs #{f.path}") do |stdin, stdout|
63
63
  loop do
64
64
  begin
65
- Timeout::timeout(5) do
65
+ Timeout::timeout(10) do
66
66
  res = stdout.readline
67
67
  $stderr.puts "\t"+res
68
68
  if res =~ /__SUCCESS/
@@ -2,7 +2,7 @@
2
2
 
3
3
  QUnit.test("when if_controller_init is called with a view that has the debug flag on, it uses the DebugController", function(assert) {
4
4
  //Setup prototypes html
5
- $("body").append("<div id='prototypes'></div>")
5
+ $("body").html("<div id='prototypes'></div>")
6
6
  if_init_view("my_test_view", {}, 1, ["main", "content"]);
7
7
 
8
8
  //Create a controller that belongs to a debug view (it has data-debug='1')
@@ -0,0 +1,91 @@
1
+ //Testing the DOM binding like data-puts to make sure they work
2
+
3
+ QUnit.test("When the DOM bind data-puts is used with 'foo' in a controller that has a context containing foo, foo is put inside the HTML with the binding", function(assert) {
4
+ $("body").html(" \
5
+ <div id='prototypes'> \
6
+ <div class='view' data-name='my_test_view2'> \
7
+ <h1 id='check' data-puts='foo'></h1> \
8
+ </div> \
9
+ </div> \
10
+ <div id='root'> \
11
+ </div> \
12
+ ")
13
+
14
+ //Create a view
15
+ if_init_view("my_test_view2", {}, 4, ["main"]);
16
+
17
+ //Bind a controller to that view with a context
18
+ //A DebugController will automatically be bound
19
+ if_controller_init(3, 4, "my_test_controller2", {foo: "hello world"});
20
+
21
+ //Attach that controller
22
+ if_attach_view(4, 0);
23
+
24
+ //Check h1
25
+ var $h1 = $("#root h1");
26
+ var html = $h1.html();
27
+ assert.equal(html, "hello world", "html is equal to hello world, got: " + html);
28
+ });
29
+
30
+ QUnit.test("When the DOM bind data-puts is used with 'src foo' in a controller that has a context containing foo, foo is put inside the src tag with the binding", function(assert) {
31
+ $("body").html(" \
32
+ <div id='prototypes'> \
33
+ <div class='view' data-name='my_test_view2'> \
34
+ <img id='check' data-puts='src foo'></h1> \
35
+ </div> \
36
+ </div> \
37
+ <div id='root'> \
38
+ </div> \
39
+ ")
40
+
41
+ //Create a view
42
+ if_init_view("my_test_view2", {}, 4, ["main"]);
43
+
44
+ //Bind a controller to that view with a context
45
+ //A FlokController will automatically be bound
46
+ var src = "http://upload.wikimedia.org/wikipedia/commons/d/d9/Test.png"
47
+ if_controller_init(3, 4, "my_test_controller2", {foo: src});
48
+
49
+ //Attach that controller
50
+ if_attach_view(4, 0);
51
+
52
+ //Check img
53
+ var $img = $("#root img");
54
+ var _src = $img.attr("src");
55
+ assert.equal(_src, src, "src is supposed to be a URL: " + src + ", but instead got: " + _src);
56
+ });
57
+
58
+ QUnit.test("When a button is clicked with the data-emit tag, it will signal the flok controller", function(assert) {
59
+ $("body").html(" \
60
+ <div id='prototypes'> \
61
+ <div class='view' data-name='my_test_view'> \
62
+ <button id='trigger_button_clicked' data-emit='button_clicked'>Click Me</button> \
63
+ </div> \
64
+ </div> \
65
+ <div id='root'> \
66
+ </div> \
67
+ ")
68
+
69
+ //Create an instance of our prototype view
70
+ if_init_view("my_test_view", {}, 4, ["main"]);
71
+
72
+ //Bind a generic FlokController to our view and set the bp to 3
73
+ //It's generic because __test__ does not exist
74
+ if_controller_init(3, 4, "__test__", {});
75
+
76
+ //Attach that view's controller to the root spot
77
+ if_attach_view(4, 0);
78
+
79
+ //Grab the view's button
80
+ var $button = $("#root #trigger_button_clicked");
81
+
82
+ //Intercept click event
83
+ window.int_dispatch = function(q) {
84
+ assert.equal(JSON.stringify(q), JSON.stringify([3, "int_event", 3, "button_clicked", {}]));
85
+ }
86
+
87
+ //Trigger button
88
+ $button.trigger("click");
89
+
90
+ window.int_dispatch = null;
91
+ });
@@ -1,28 +1,28 @@
1
1
  //Tests various control variables, like context
2
2
 
3
- QUnit.test("Controller does receive context on explicit init", function(assert) {
4
- var done = assert.async();
3
+ QUnit.test("Controller does receive context on explicit init", function(assert) {
4
+ var done = assert.async();
5
5
 
6
- //Create a test controller
7
- var TestController = function() {
8
- this.base = FlokController; this.base(); self = this;
6
+ //Create a test controller
7
+ var TestController = function() {
8
+ this.base = FlokController; this.base(); self = this;
9
9
 
10
- self.init = function() {
11
- assert.equal(this.context.hello, "world", "Matches");
12
- done();
13
- }
10
+ self.init = function() {
11
+ assert.equal(this.context.hello, "world", "Matches");
12
+ done();
14
13
  }
14
+ }
15
15
 
16
- //Insert some HTML
17
- $("body").html(" \
18
- <div id='root'> \
19
- <div id='test'></div> \
20
- </div> \
21
- ");
16
+ //Insert some HTML
17
+ $("body").html(" \
18
+ <div id='root'> \
19
+ <div id='test'></div> \
20
+ </div> \
21
+ ");
22
22
 
23
- //Call the controllers init with a forged selector
24
- $sel = $("#test");
25
- var c = new TestController();
26
- c.__initialize__(0, $sel, {hello: 'world'});
27
- c.init();
28
- });
23
+ //Call the controllers init with a forged selector
24
+ $sel = $("#test");
25
+ var c = new TestController();
26
+ c.__initialize__(0, $sel, {hello: 'world'});
27
+ c.init();
28
+ });
@@ -35,8 +35,16 @@ FlokController = function() {
35
35
 
36
36
  //Set the HTML
37
37
  this.$sel("[data-puts]").each(function() {
38
- var name = $(this).attr("data-puts");
39
- $(this).html(self.context[name]);
38
+ //Retreive the args, seperated by spaces
39
+ var args = $(this).attr("data-puts");
40
+ args = args.split(" ");
41
+
42
+ // 2 args => set the attribute named args[0] to the value of context[args[1]]
43
+ if (args.length == 1) {
44
+ $(this).html(self.context[args[0]]);
45
+ } else if (args.length == 2) {
46
+ $(this).attr(args[0], self.context[args[1]]);
47
+ }
40
48
  });
41
49
  }
42
50
 
data/lib/flok/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Flok
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-22 00:00:00.000000000 Z
11
+ date: 2015-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -245,6 +245,7 @@ files:
245
245
  - app/drivers/chrome/spec/init/qunit.js
246
246
  - app/drivers/chrome/spec/spec/controller_debug_spec.js
247
247
  - app/drivers/chrome/spec/spec/debug_spec.js
248
+ - app/drivers/chrome/spec/spec/dom_helpers_spec.js
248
249
  - app/drivers/chrome/spec/spec/sel_scope_spec.js
249
250
  - app/drivers/chrome/spec/spec/vars_spec.js
250
251
  - app/drivers/chrome/src/bench.js