appetizer-ui 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/appetizer-ui.gemspec +15 -13
  2. data/lib/appetizer/ui/assets.rb +21 -8
  3. data/lib/appetizer/ui/jasmine/js/jquery-jasmine.js +288 -0
  4. data/lib/appetizer/ui/jasmine/js/spec-runner.coffee +0 -1
  5. data/lib/appetizer/ui/jasmine/views/specs.erb +12 -4
  6. data/lib/appetizer/ui/rake.rb +29 -10
  7. data/lib/appetizer/ui/spec.rb +1 -2
  8. metadata +122 -61
  9. data/lib/appetizer/ui/app/js/appetizer.coffee +0 -15
  10. data/lib/appetizer/ui/app/js/appetizer/core.coffee +0 -20
  11. data/lib/appetizer/ui/app/js/appetizer/model.coffee +0 -1
  12. data/lib/appetizer/ui/app/js/appetizer/router.coffee +0 -70
  13. data/lib/appetizer/ui/app/js/appetizer/view.coffee +0 -139
  14. data/lib/appetizer/ui/app/js/appetizer/xdr.coffee +0 -57
  15. data/lib/appetizer/ui/app/views/client/appetizer/missing.jst.eco +0 -3
  16. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/appetizerExtensions.spec.js +0 -54
  17. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/checkboxConventionBindings.spec.js +0 -110
  18. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/configurableBindingAttributes.spec.js +0 -117
  19. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/configureAllBindingAttributes.spec.js +0 -139
  20. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/customConvention.spec.js +0 -53
  21. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindConvention.spec.js +0 -151
  22. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindMultiple.spec.js +0 -36
  23. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindSubstitutions.spec.js +0 -137
  24. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfiguraAllBindingAttributes.spec.js +0 -124
  25. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfigurableBindingAttributes.spec.js +0 -36
  26. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/SpecHelper.js +0 -4
  27. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/sample.backbone.app.js +0 -159
  28. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/html5inputConventionBinding.spec.js +0 -142
  29. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/modelUnbinding.spec.js +0 -73
  30. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/noConflict.spec.js +0 -36
  31. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/radioButtonConventionBinding.spec.js +0 -41
  32. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/selectboxConventionBindings.spec.js +0 -60
  33. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/textareaConventionBinding.spec.js +0 -29
  34. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/textboxConventionBinding.spec.js +0 -66
  35. data/lib/appetizer/ui/vendor/js/backbone.js +0 -1290
  36. data/lib/appetizer/ui/vendor/js/backbone.modelbinding.js +0 -624
  37. data/lib/appetizer/ui/vendor/js/jquery.js +0 -9266
  38. data/lib/appetizer/ui/vendor/js/json2.js +0 -480
  39. data/lib/appetizer/ui/vendor/js/underscore.js +0 -999
  40. data/lib/appetizer/ui/vendor/js/underscore.string.js +0 -480
@@ -1,36 +0,0 @@
1
- describe("globalConfigurableBindingAttributes", function(){
2
- beforeEach(function(){
3
- Backbone.ModelBinding.Configuration.store();
4
- Backbone.ModelBinding.Configuration.configureBindingAttributes({text: "modelAttr"});
5
-
6
- this.model = new AModel({ weakness: "liver & onions" });
7
- this.view = new AView({model: this.model});
8
- this.view.render();
9
- });
10
-
11
- afterEach(function(){
12
- Backbone.ModelBinding.Configuration.restore();
13
- });
14
-
15
- describe("text element binding with global configuration of convention attribute", function(){
16
- it("bind view changes to the model's field, by configurable convention", function(){
17
- var el = this.view.$("#super_hero_weakness");
18
- el.val("spinach");
19
- el.trigger('change');
20
-
21
- expect(this.model.get('weakness')).toEqual("spinach");
22
- });
23
-
24
- it("bind model field changes to the form input, by convention of id", function(){
25
- this.model.set({weakness: "broccoli"});
26
- var el = this.view.$("#super_hero_weakness");
27
- expect(el.val()).toEqual("broccoli");
28
- });
29
-
30
- it("binds the model's value to the form field on render", function(){
31
- var el = this.view.$("#super_hero_weakness");
32
- expect(el.val()).toEqual("liver & onions");
33
- });
34
- });
35
-
36
- });
@@ -1,4 +0,0 @@
1
- beforeEach(function() {
2
- this.addMatchers({
3
- })
4
- });
@@ -1,159 +0,0 @@
1
- AModel = Backbone.Model.extend({urlRoot: "/foo"});
2
-
3
- AppetizerView = Backbone.View.extend({
4
- render: function(){
5
- var html = $("\
6
- <div id='villain' data-bind='text villain' />\
7
- <div id='mrNice' data-bind='text niceDude' />\
8
- <div id='pet' data-bind='text pet.smelly' />\
9
- <div id='country' data-bind='text country.withFood.hasWine' />\
10
- <input type='text' id='usa' modelAttr='country.withFood.hasBurgers'>\
11
- <input type='text' id='cat' modelAttr='pet.fluffy'>\
12
- ");
13
- $(this.el).append(html).appendTo(sandbox());
14
- Backbone.ModelBinding.bind(this, { text: "modelAttr" });
15
- }
16
- });
17
-
18
- AView = Backbone.View.extend({
19
- render: function(){
20
- var html = $("\
21
- <div id='eventDiv' data-bind='text event:foo' />\
22
- <img id='avatar' data-bind='src urlSrc; class name'>\
23
- <input id='noType'>\
24
- <div id='showHideThing' data-bind='displayed isValid' />\
25
- <div id='showHideAnotherThing' data-bind='hidden isValid' />\
26
- <button id='unclicker' data-bind='disabled isValid'>Click Me!</button>\
27
- <button id='clicker' data-bind='enabled isValid'>Click Me!</button>\
28
- <div id='villain' data-bind='html villain'><p>test</p></div>\
29
- <div id='doctor_no_elem' data-bind='doctor'>Seuss</div>\
30
- <div id='doctor_data_bind_bb' data-bind-bb='doctor'>Seuss</div>\
31
- <div id='doctor' data-bind='text doctor'>Seuss</div>\
32
- <div id='pet' data-bind='someAttr pet' someAttr='Cat'></div>\
33
- <input type='text' id='super_hero_weakness' modelAttr='weakness'>\
34
- <input type='text' id='something'> \
35
- <div id='showIt'></div>\
36
- <input type='text' id='prefilled_name' value='a name'>\
37
- <input type='text' id='name'>\
38
- <select id='operating_system'> \
39
- <option value='osx'>osx</option> \
40
- <option value='windows'>windows</option> \
41
- <option value='linux'>linux</option> \
42
- </select> \
43
- <select id='education'> \
44
- <option value='none'>none</option> \
45
- <option value='grade_school'>i dun learned at grade skool</option> \
46
- <option value='high school'>high school</option> \
47
- <option value='college'>college</option> \
48
- <option value='graduate'>graduate</option> \
49
- </select> \
50
- <select id='age_level'> \
51
- <option value=''>-- select --</option> \
52
- <option value='0'>under 20</option> \
53
- <option value='21'>21 - 40</option> \
54
- <option value='41'>over 41</option> \
55
- </select> \
56
- <select id='another_select'> \
57
- <option value='pre_selected' selected='selected'>pre selected</option> \
58
- <option value='not_selected'>not selected</option> \
59
- </select> \
60
- <input type='radio' id='graduated_yes' name='graduated' value='yes'>\
61
- <input type='radio' id='graduated_no' name='graduated' value='no'>\
62
- <input type='radio' id='graduated_maybe' name='graduated' value='maybe'>\
63
- <input type='radio' id='us_citizen_true' name='us_citizen' value='true'>\
64
- <input type='radio' id='us_citizen_false' name='us_citizen' value='false'>\
65
- <input type='radio' id='another_radio_true' name='another_radio' value='true' checked='checked'>\
66
- <input type='radio' id='another_radio_false' name='another_radio' value='false'>\
67
- <input type='checkbox' id='drivers_license' value='yes'>\
68
- <input type='checkbox' id='motorcycle_license' value='yes' checked='checked'>\
69
- <input type='checkbox' id='binary_checkbox' value='yes'>\
70
- <textarea id='bio'></textarea>\
71
- <p id='aParagraph'></p>\
72
- <input type='password' id='password'>\
73
- <input type='number' id='number'>\
74
- <input type='range' id='range' min='0' max='98765'>\
75
- <input type='email' id='email'>\
76
- <input type='url' id='urlSrc'>\
77
- <input type='tel' id='tel'>\
78
- <input type='search' id='search'>\
79
- ");
80
- $(this.el).append(html).appendTo(sandbox());
81
- Backbone.ModelBinding.bind(this);
82
- }
83
- });
84
-
85
- AllBindingAttributesView = Backbone.View.extend({
86
- render: function(){
87
- var html = $("\
88
- <input type='text' id='v_name' class='name'> \
89
- <select id='v_education' class='education'> \
90
- <option value='none'>none</option> \
91
- <option value='grade_school'>i dun learned at grade skool</option> \
92
- <option value='high school'>high school</option> \
93
- <option value='college'>college</option> \
94
- <option value='graduate'>graduate</option> \
95
- </select> \
96
- <input type='radio' id='graduated_yes' name='graduated' class='graduated' value='yes'>\
97
- <input type='radio' id='graduated_no' name='graduated' class='graduated' value='no'>\
98
- <input type='radio' id='graduated_maybe' name='graduated' class='graduated' value='maybe'>\
99
- <input type='checkbox' id='v_drivers_license' class='drivers_license' value='yes'>\
100
- <textarea id='v_bio' class='bio'></textarea>\
101
- ");
102
- $(this.el).append(html).appendTo(sandbox());
103
-
104
- Backbone.ModelBinding.bind(this, {all: "class"});
105
- }
106
- });
107
-
108
- GlobalAllBindingAttributesView = Backbone.View.extend({
109
- render: function(){
110
- var html = $("\
111
- <input type='text' id='v_name' class='name'> \
112
- <select id='v_education' class='education'> \
113
- <option value='none'>none</option> \
114
- <option value='grade_school'>i dun learned at grade skool</option> \
115
- <option value='high school'>high school</option> \
116
- <option value='college'>college</option> \
117
- <option value='graduate'>graduate</option> \
118
- </select> \
119
- <input type='radio' id='graduated_yes' name='graduated' class='graduated' value='yes'>\
120
- <input type='radio' id='graduated_no' name='graduated' class='graduated' value='no'>\
121
- <input type='radio' id='graduated_maybe' name='graduated' class='graduated' value='maybe'>\
122
- <input type='checkbox' id='v_drivers_license' class='drivers_license' value='yes'>\
123
- <textarea id='v_bio' class='bio'></textarea>\
124
- ");
125
- $(this.el).append(html).appendTo(sandbox());
126
-
127
- Backbone.ModelBinding.bind(this);
128
- }
129
- });
130
-
131
- AnotherView = Backbone.View.extend({
132
- render: function(){
133
- var html = $("\
134
- <input type='text' class='super_power' modelAttr='weakness'>\
135
- <select class='education'> \
136
- <option value='none'>none</option> \
137
- <option value='grade_school'>i dun learned at grade skool</option> \
138
- <option value='high school'>high school</option> \
139
- <option value='college'>college</option> \
140
- <option value='graduate'>graduate</option> \
141
- </select> \
142
- <input type='radio' id='graduated_yes' class='graduated' value='yes'>\
143
- <input type='radio' id='graduated_no' class='graduated' value='no'>\
144
- <input type='radio' id='graduated_maybe' class='graduated' value='maybe'>\
145
- <input type='checkbox' class='drivers_license' value='yes'>\
146
- ");
147
-
148
- $(this.el).append(html).appendTo(sandbox());
149
-
150
- Backbone.ModelBinding.bind(this, {
151
- text: 'class',
152
- textarea: 'class',
153
- password: 'class',
154
- radio: 'class',
155
- select: 'class',
156
- checkbox: 'class',
157
- });
158
- }
159
- });
@@ -1,142 +0,0 @@
1
- describe("HTML5 input convention bindings", function(){
2
- beforeEach(function(){
3
- this.model = new AModel({
4
- number: "1234",
5
- range: "65",
6
- tel: "321-123-1222",
7
- search: "search text",
8
- urlSrc: "http:\\\\url.com",
9
- email: "email@domain.com"
10
- });
11
- this.view = new AView({model: this.model});
12
- this.view.render();
13
- });
14
-
15
- describe("number element binding", function(){
16
- it("bind view changes to the model's field, by convention of id", function(){
17
- var el = this.view.$("#number");
18
- el.val("09876");
19
- el.trigger('change');
20
-
21
- expect(this.model.get('number')).toEqual("09876");
22
- });
23
-
24
- it("bind model field changes to the form input, by convention of id", function(){
25
- this.model.set({number: "45678"});
26
- var el = this.view.$("#number");
27
- expect(el.val()).toEqual("45678");
28
- });
29
-
30
- it("binds the model's value to the form field on render", function(){
31
- var el = this.view.$("#number");
32
- expect(el.val()).toEqual("1234");
33
- });
34
- });
35
-
36
- describe("range element binding", function(){
37
- it("bind view changes to the model's field, by convention of id", function(){
38
- var el = this.view.$("#range");
39
- el.val("9876");
40
- el.trigger('change');
41
-
42
- expect(this.model.get('range')).toEqual("9876");
43
- });
44
-
45
- it("bind model field changes to the form input, by convention of id", function(){
46
- this.model.set({range: "45678"});
47
- var el = this.view.$("#range");
48
- expect(el.val()).toEqual("45678");
49
- });
50
-
51
- it("binds the model's value to the form field on render", function(){
52
- var el = this.view.$("#range");
53
- expect(el.val()).toEqual("65");
54
- });
55
- });
56
-
57
- describe("tel element binding", function(){
58
- it("bind view changes to the model's field, by convention of id", function(){
59
- var el = this.view.$("#tel");
60
- el.val("321-345-5555");
61
- el.trigger('change');
62
-
63
- expect(this.model.get('tel')).toEqual("321-345-5555");
64
- });
65
-
66
- it("bind model field changes to the form input, by convention of id", function(){
67
- this.model.set({tel: "456-345-5555"});
68
- var el = this.view.$("#tel");
69
- expect(el.val()).toEqual("456-345-5555");
70
- });
71
-
72
- it("binds the model's value to the form field on render", function(){
73
- var el = this.view.$("#tel");
74
- expect(el.val()).toEqual("321-123-1222");
75
- });
76
- });
77
-
78
- describe("search element binding", function(){
79
- it("bind view changes to the model's field, by convention of id", function(){
80
- var el = this.view.$("#search");
81
- el.val("more text");
82
- el.trigger('change');
83
-
84
- expect(this.model.get('search')).toEqual("more text");
85
- });
86
-
87
- it("bind model field changes to the form input, by convention of id", function(){
88
- this.model.set({search: "new text"});
89
- var el = this.view.$("#search");
90
- expect(el.val()).toEqual("new text");
91
- });
92
-
93
- it("binds the model's value to the form field on render", function(){
94
- var el = this.view.$("#search");
95
- expect(el.val()).toEqual("search text");
96
- });
97
- });
98
-
99
- describe("url element binding", function(){
100
- it("bind view changes to the model's field, by convention of id", function(){
101
- var el = this.view.$("#urlSrc");
102
- el.val("some url");
103
- el.trigger('change');
104
-
105
- expect(this.model.get('urlSrc')).toEqual("some url");
106
- });
107
-
108
- it("bind model field changes to the form input, by convention of id", function(){
109
- this.model.set({urlSrc: "new url"});
110
- var el = this.view.$("#urlSrc");
111
- expect(el.val()).toEqual("new url");
112
- });
113
-
114
- it("binds the model's value to the form field on render", function(){
115
- var el = this.view.$("#urlSrc");
116
- expect(el.val()).toEqual("http:\\\\url.com");
117
- });
118
- });
119
-
120
- describe("email element binding", function(){
121
- it("bind view changes to the model's field, by convention of id", function(){
122
- var el = this.view.$("#email");
123
- el.val("new@email.com");
124
- el.trigger('change');
125
-
126
- expect(this.model.get('email')).toEqual("new@email.com");
127
- });
128
-
129
- it("bind model field changes to the form input, by convention of id", function(){
130
- this.model.set({email: "more@email.gov"});
131
- var el = this.view.$("#email");
132
- expect(el.val()).toEqual("more@email.gov");
133
- });
134
-
135
- it("binds the model's value to the form field on render", function(){
136
- var el = this.view.$("#email");
137
- expect(el.val()).toEqual("email@domain.com");
138
- });
139
- });
140
-
141
-
142
- });
@@ -1,73 +0,0 @@
1
- describe("model unbinding", function(){
2
- beforeEach(function(){
3
- this.model = new AModel({
4
- name: "a name",
5
- bio: "a bio",
6
- password: "it's a secret",
7
- education: "college",
8
- graduated: "no",
9
- drivers_license: true,
10
- isValid: true
11
- });
12
- this.view = new AView({model: this.model});
13
- this.view.render();
14
- });
15
-
16
- describe("when unbinding a view should", function(){
17
- beforeEach(function(){
18
- Backbone.ModelBinding.unbind(this.view);
19
- });
20
-
21
- it("should unbind the text box", function(){
22
- this.model.set({name: "some name change"});
23
- var el = this.view.$("#name");
24
- expect(el.val()).toEqual("a name");
25
- });
26
-
27
- it("should unbind the textarea", function(){
28
- this.model.set({bio: "some change to my bio"});
29
- var el = this.view.$("#bio");
30
- expect(el.val()).toEqual("a bio");
31
- });
32
-
33
- it("should unbind the password", function(){
34
- this.model.set({password: "this isn't it"});
35
- var el = this.view.$("#password");
36
- expect(el.val()).toEqual("it's a secret");
37
- });
38
-
39
- it("should unbind the select box", function(){
40
- this.model.set({education: "none"});
41
- var el = this.view.$("#education");
42
- expect(el.val()).toEqual("college");
43
- });
44
-
45
- it("should unbind the radio group", function(){
46
- this.model.set({graduated: "yes"});
47
-
48
- var elYes = this.view.$("#graduated_yes");
49
- var selected = elYes.attr("checked");
50
- expect(selected).toBeFalsy();
51
-
52
- var elNo = this.view.$("#graduated_no");
53
- var selected = elNo.attr("checked");
54
- expect(selected).toBeTruthy();
55
- });
56
-
57
- it("should unbind the checkbox", function(){
58
- this.model.set({drivers_license: false});
59
- var el = this.view.$("#drivers_license");
60
- var selected = el.attr("checked");
61
- expect(selected).toBeTruthy();
62
- });
63
-
64
- it("should unbind the data-bind", function(){
65
- this.model.set({isValid: false});
66
- var el = this.view.$("#clicker");
67
- var disabled = el.attr("disabled");
68
- expect(disabled).toBeFalsy();
69
- });
70
- });
71
-
72
- });
73
-
@@ -1,36 +0,0 @@
1
- describe("Backbone.noConflict", function(){
2
- beforeEach(function(){
3
- var that = this;
4
- this.localBackbone = Backbone.noConflict();
5
- this.localUnderscore = _.noConflict();
6
-
7
- var Model = this.localBackbone.Model.extend({});
8
- var View = this.localBackbone.View.extend({
9
- render: function(){
10
- var html = $("\
11
- <input id='input'>\
12
- <select id='select'> \
13
- <option value='none'>none</option> \
14
- </select> \
15
- <input type='radio' id='radio' name='radio' value='yes'>\
16
- <input type='checkbox' id='check' value='yes'>\
17
- <button id='data' data-bind='disabled isValid'>Click Me!</button>\
18
- ");
19
- this.$(this.el).append(html);
20
- }
21
- });
22
-
23
- this.model = new Model();
24
- this.view = new View({model: this.model});
25
- this.view.render();
26
- });
27
-
28
- afterEach(function(){
29
- Backbone = this.localBackbone;
30
- _ = this.localUnderscore;
31
- });
32
-
33
- it("should use local copy of backbone when binding", function(){
34
- this.localBackbone.ModelBinding.bind(this.view);
35
- });
36
- });