appetizer-ui 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
data/appetizer-ui.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.test_files = `git ls-files -- test/*`.split("\n")
|
11
11
|
gem.name = "appetizer-ui"
|
12
12
|
gem.require_paths = ["lib"]
|
13
|
-
gem.version = "0.
|
13
|
+
gem.version = "0.4.0"
|
14
14
|
|
15
15
|
gem.required_ruby_version = ">= 1.9.2"
|
16
16
|
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_dependency "sass", "~> 3.1"
|
23
23
|
gem.add_dependency "sinatra", "~> 1.3"
|
24
24
|
gem.add_dependency "sprockets", "~> 2.1"
|
25
|
+
gem.add_dependency "sprockets-sass", "~> 0.6"
|
25
26
|
gem.add_dependency "uglifier", "~> 1.0"
|
26
27
|
gem.add_dependency "yajl-ruby", "~> 1.0"
|
27
28
|
gem.add_dependency "yui-compressor", "~> 0.9"
|
data/lib/appetizer/ui/assets.rb
CHANGED
@@ -0,0 +1,562 @@
|
|
1
|
+
// Backbone.ModelBinding v0.4.3
|
2
|
+
// [jbarnette] Added getAttributeValue, allowing values to come from functions.
|
3
|
+
//
|
4
|
+
// Copyright (C)2011 Derick Bailey, Muted Solutions, LLC
|
5
|
+
// Distributed Under MIT Liscene
|
6
|
+
//
|
7
|
+
// Documentation and Full Licence Availabe at:
|
8
|
+
// http://github.com/derickbailey/backbone.modelbinding
|
9
|
+
|
10
|
+
// ----------------------------
|
11
|
+
// Backbone.ModelBinding
|
12
|
+
// ----------------------------
|
13
|
+
|
14
|
+
;(function(root){
|
15
|
+
|
16
|
+
var modelbinding = (function(Backbone, _, $) {
|
17
|
+
var modelBinding = {
|
18
|
+
version: "0.4.3",
|
19
|
+
|
20
|
+
bind: function(view, options){
|
21
|
+
view.modelBinder = new ModelBinder(view, options);
|
22
|
+
view.modelBinder.bind();
|
23
|
+
},
|
24
|
+
|
25
|
+
unbind: function(view){
|
26
|
+
if (view.modelBinder){
|
27
|
+
view.modelBinder.unbind()
|
28
|
+
}
|
29
|
+
}
|
30
|
+
};
|
31
|
+
|
32
|
+
var getAttributeValue = function(model, name) {
|
33
|
+
var value = model[name];
|
34
|
+
|
35
|
+
if (value && _.isFunction(value)) {
|
36
|
+
value = value.apply(model)
|
37
|
+
} else {
|
38
|
+
value = model.get(name);
|
39
|
+
}
|
40
|
+
|
41
|
+
return value;
|
42
|
+
};
|
43
|
+
|
44
|
+
var ModelBinder = function(view, options){
|
45
|
+
this.config = new modelBinding.Configuration(options);
|
46
|
+
this.modelBindings = [];
|
47
|
+
this.elementBindings = [];
|
48
|
+
|
49
|
+
this.bind = function(){
|
50
|
+
var conventions = modelBinding.Conventions;
|
51
|
+
for (var conventionName in conventions){
|
52
|
+
if (conventions.hasOwnProperty(conventionName)){
|
53
|
+
var conventionElement = conventions[conventionName];
|
54
|
+
var handler = conventionElement.handler;
|
55
|
+
var conventionSelector = conventionElement.selector;
|
56
|
+
handler.bind.call(this, conventionSelector, view, view.model, this.config);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
this.unbind = function(){
|
62
|
+
// unbind the html element bindings
|
63
|
+
_.each(this.elementBindings, function(binding){
|
64
|
+
binding.element.unbind(binding.eventName, binding.callback);
|
65
|
+
});
|
66
|
+
|
67
|
+
// unbind the model bindings
|
68
|
+
_.each(this.modelBindings, function(binding){
|
69
|
+
binding.model.unbind(binding.eventName, binding.callback);
|
70
|
+
});
|
71
|
+
};
|
72
|
+
|
73
|
+
this.registerModelBinding = function(model, attrName, callback){
|
74
|
+
// bind the model changes to the form elements
|
75
|
+
var eventName = "change:" + attrName;
|
76
|
+
model.bind(eventName, callback);
|
77
|
+
this.modelBindings.push({model: model, eventName: eventName, callback: callback});
|
78
|
+
};
|
79
|
+
|
80
|
+
this.registerDataBinding = function(model, eventName, callback){
|
81
|
+
// bind the model changes to the elements
|
82
|
+
|
83
|
+
model.bind(eventName, callback);
|
84
|
+
this.modelBindings.push({model: model, eventName: eventName, callback: callback});
|
85
|
+
};
|
86
|
+
|
87
|
+
this.registerElementBinding = function(element, callback){
|
88
|
+
// bind the form changes to the model
|
89
|
+
element.bind("change", callback);
|
90
|
+
this.elementBindings.push({element: element, eventName: "change", callback: callback});
|
91
|
+
};
|
92
|
+
};
|
93
|
+
|
94
|
+
// ----------------------------
|
95
|
+
// Model Binding Configuration
|
96
|
+
// ----------------------------
|
97
|
+
modelBinding.Configuration = function(options){
|
98
|
+
this.bindingAttrConfig = {};
|
99
|
+
|
100
|
+
_.extend(this.bindingAttrConfig,
|
101
|
+
modelBinding.Configuration.bindindAttrConfig,
|
102
|
+
options
|
103
|
+
);
|
104
|
+
|
105
|
+
if (this.bindingAttrConfig.all){
|
106
|
+
var attr = this.bindingAttrConfig.all;
|
107
|
+
delete this.bindingAttrConfig.all;
|
108
|
+
for (var inputType in this.bindingAttrConfig){
|
109
|
+
if (this.bindingAttrConfig.hasOwnProperty(inputType)){
|
110
|
+
this.bindingAttrConfig[inputType] = attr;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
this.getBindingAttr = function(type){
|
116
|
+
return this.bindingAttrConfig[type];
|
117
|
+
};
|
118
|
+
|
119
|
+
this.getBindingValue = function(element, type){
|
120
|
+
var bindingAttr = this.getBindingAttr(type);
|
121
|
+
return element.attr(bindingAttr);
|
122
|
+
};
|
123
|
+
|
124
|
+
};
|
125
|
+
|
126
|
+
modelBinding.Configuration.bindindAttrConfig = {
|
127
|
+
text: "id",
|
128
|
+
textarea: "id",
|
129
|
+
password: "id",
|
130
|
+
radio: "name",
|
131
|
+
checkbox: "id",
|
132
|
+
select: "id",
|
133
|
+
number: "id",
|
134
|
+
range: "id",
|
135
|
+
tel: "id",
|
136
|
+
search: "id",
|
137
|
+
url: "id",
|
138
|
+
email: "id"
|
139
|
+
};
|
140
|
+
|
141
|
+
modelBinding.Configuration.store = function(){
|
142
|
+
modelBinding.Configuration.originalConfig = _.clone(modelBinding.Configuration.bindindAttrConfig);
|
143
|
+
};
|
144
|
+
|
145
|
+
modelBinding.Configuration.restore = function(){
|
146
|
+
modelBinding.Configuration.bindindAttrConfig = modelBinding.Configuration.originalConfig;
|
147
|
+
};
|
148
|
+
|
149
|
+
modelBinding.Configuration.configureBindingAttributes = function(options){
|
150
|
+
if (options.all){
|
151
|
+
this.configureAllBindingAttributes(options.all);
|
152
|
+
delete options.all;
|
153
|
+
}
|
154
|
+
_.extend(modelBinding.Configuration.bindindAttrConfig, options);
|
155
|
+
};
|
156
|
+
|
157
|
+
modelBinding.Configuration.configureAllBindingAttributes = function(attribute){
|
158
|
+
var config = modelBinding.Configuration.bindindAttrConfig;
|
159
|
+
config.text = attribute;
|
160
|
+
config.textarea = attribute;
|
161
|
+
config.password = attribute;
|
162
|
+
config.radio = attribute;
|
163
|
+
config.checkbox = attribute;
|
164
|
+
config.select = attribute;
|
165
|
+
config.number = attribute;
|
166
|
+
config.range = attribute;
|
167
|
+
config.tel = attribute;
|
168
|
+
config.search = attribute;
|
169
|
+
config.url = attribute;
|
170
|
+
config.email = attribute;
|
171
|
+
};
|
172
|
+
|
173
|
+
// ----------------------------
|
174
|
+
// Text, Textarea, and Password Bi-Directional Binding Methods
|
175
|
+
// ----------------------------
|
176
|
+
var StandardBinding = (function(Backbone){
|
177
|
+
var methods = {};
|
178
|
+
|
179
|
+
var _getElementType = function(element) {
|
180
|
+
var type = element[0].tagName.toLowerCase();
|
181
|
+
if (type == "input"){
|
182
|
+
type = element.attr("type");
|
183
|
+
if (type == undefined || type == ''){
|
184
|
+
type = 'text';
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return type;
|
188
|
+
};
|
189
|
+
|
190
|
+
methods.bind = function(selector, view, model, config){
|
191
|
+
var modelBinder = this;
|
192
|
+
|
193
|
+
view.$(selector).each(function(index){
|
194
|
+
var element = view.$(this);
|
195
|
+
var elementType = _getElementType(element);
|
196
|
+
var attribute_name = config.getBindingValue(element, elementType);
|
197
|
+
|
198
|
+
var modelChange = function(changed_model, val){ element.val(val); };
|
199
|
+
|
200
|
+
var setModelValue = function(attr_name, value){
|
201
|
+
var data = {};
|
202
|
+
data[attr_name] = value;
|
203
|
+
model.set(data);
|
204
|
+
};
|
205
|
+
|
206
|
+
var elementChange = function(ev){
|
207
|
+
setModelValue(attribute_name, view.$(ev.target).val());
|
208
|
+
};
|
209
|
+
|
210
|
+
modelBinder.registerModelBinding(model, attribute_name, modelChange);
|
211
|
+
modelBinder.registerElementBinding(element, elementChange);
|
212
|
+
|
213
|
+
// set the default value on the form, from the model
|
214
|
+
var attr_value = getAttributeValue(model, attribute_name);
|
215
|
+
if (typeof attr_value !== "undefined" && attr_value !== null) {
|
216
|
+
element.val(attr_value);
|
217
|
+
} else {
|
218
|
+
var elVal = element.val();
|
219
|
+
if (elVal){
|
220
|
+
setModelValue(attribute_name, elVal);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
});
|
224
|
+
};
|
225
|
+
|
226
|
+
return methods;
|
227
|
+
})(Backbone);
|
228
|
+
|
229
|
+
// ----------------------------
|
230
|
+
// Select Box Bi-Directional Binding Methods
|
231
|
+
// ----------------------------
|
232
|
+
var SelectBoxBinding = (function(Backbone){
|
233
|
+
var methods = {};
|
234
|
+
|
235
|
+
methods.bind = function(selector, view, model, config){
|
236
|
+
var modelBinder = this;
|
237
|
+
|
238
|
+
view.$(selector).each(function(index){
|
239
|
+
var element = view.$(this);
|
240
|
+
var attribute_name = config.getBindingValue(element, 'select');
|
241
|
+
|
242
|
+
var modelChange = function(changed_model, val){ element.val(val); };
|
243
|
+
|
244
|
+
var setModelValue = function(attr, val, text){
|
245
|
+
var data = {};
|
246
|
+
data[attr] = val;
|
247
|
+
data[attr + "_text"] = text;
|
248
|
+
model.set(data);
|
249
|
+
};
|
250
|
+
|
251
|
+
var elementChange = function(ev){
|
252
|
+
var targetEl = view.$(ev.target);
|
253
|
+
var value = targetEl.val();
|
254
|
+
var text = targetEl.find(":selected").text();
|
255
|
+
setModelValue(attribute_name, value, text);
|
256
|
+
};
|
257
|
+
|
258
|
+
modelBinder.registerModelBinding(model, attribute_name, modelChange);
|
259
|
+
modelBinder.registerElementBinding(element, elementChange);
|
260
|
+
|
261
|
+
// set the default value on the form, from the model
|
262
|
+
var attr_value = getAttributeValue(model, attribute_name);
|
263
|
+
if (typeof attr_value !== "undefined" && attr_value !== null) {
|
264
|
+
element.val(attr_value);
|
265
|
+
}
|
266
|
+
|
267
|
+
// set the model to the form's value if there is no model value
|
268
|
+
if (element.val() != attr_value) {
|
269
|
+
var value = element.val();
|
270
|
+
var text = element.find(":selected").text();
|
271
|
+
setModelValue(attribute_name, value, text);
|
272
|
+
}
|
273
|
+
});
|
274
|
+
};
|
275
|
+
|
276
|
+
return methods;
|
277
|
+
})(Backbone);
|
278
|
+
|
279
|
+
// ----------------------------
|
280
|
+
// Radio Button Group Bi-Directional Binding Methods
|
281
|
+
// ----------------------------
|
282
|
+
var RadioGroupBinding = (function(Backbone){
|
283
|
+
var methods = {};
|
284
|
+
|
285
|
+
methods.bind = function(selector, view, model, config){
|
286
|
+
var modelBinder = this;
|
287
|
+
|
288
|
+
var foundElements = [];
|
289
|
+
view.$(selector).each(function(index){
|
290
|
+
var element = view.$(this);
|
291
|
+
|
292
|
+
var group_name = config.getBindingValue(element, 'radio');
|
293
|
+
if (!foundElements[group_name]) {
|
294
|
+
foundElements[group_name] = true;
|
295
|
+
var bindingAttr = config.getBindingAttr('radio');
|
296
|
+
|
297
|
+
var modelChange = function(model, val){
|
298
|
+
var value_selector = "input[type=radio][" + bindingAttr + "=" + group_name + "][value='" + val + "']";
|
299
|
+
view.$(value_selector).attr("checked", "checked");
|
300
|
+
};
|
301
|
+
modelBinder.registerModelBinding(model, group_name, modelChange);
|
302
|
+
|
303
|
+
var setModelValue = function(attr, val){
|
304
|
+
var data = {};
|
305
|
+
data[attr] = val;
|
306
|
+
model.set(data);
|
307
|
+
};
|
308
|
+
|
309
|
+
// bind the form changes to the model
|
310
|
+
var elementChange = function(ev){
|
311
|
+
var element = view.$(ev.currentTarget);
|
312
|
+
if (element.is(":checked")){
|
313
|
+
setModelValue(group_name, element.val());
|
314
|
+
}
|
315
|
+
};
|
316
|
+
|
317
|
+
var group_selector = "input[type=radio][" + bindingAttr + "=" + group_name + "]";
|
318
|
+
view.$(group_selector).each(function(){
|
319
|
+
var groupEl = $(this);
|
320
|
+
modelBinder.registerElementBinding(groupEl, elementChange);
|
321
|
+
});
|
322
|
+
|
323
|
+
var attr_value = getAttributeValue(model, group_name);
|
324
|
+
if (typeof attr_value !== "undefined" && attr_value !== null) {
|
325
|
+
// set the default value on the form, from the model
|
326
|
+
var value_selector = "input[type=radio][" + bindingAttr + "=" + group_name + "][value='" + attr_value + "']";
|
327
|
+
view.$(value_selector).attr("checked", "checked");
|
328
|
+
} else {
|
329
|
+
// set the model to the currently selected radio button
|
330
|
+
var value_selector = "input[type=radio][" + bindingAttr + "=" + group_name + "]:checked";
|
331
|
+
var value = view.$(value_selector).val();
|
332
|
+
setModelValue(group_name, value);
|
333
|
+
}
|
334
|
+
}
|
335
|
+
});
|
336
|
+
};
|
337
|
+
|
338
|
+
return methods;
|
339
|
+
})(Backbone);
|
340
|
+
|
341
|
+
// ----------------------------
|
342
|
+
// Checkbox Bi-Directional Binding Methods
|
343
|
+
// ----------------------------
|
344
|
+
var CheckboxBinding = (function(Backbone){
|
345
|
+
var methods = {};
|
346
|
+
|
347
|
+
methods.bind = function(selector, view, model, config){
|
348
|
+
var modelBinder = this;
|
349
|
+
|
350
|
+
view.$(selector).each(function(index){
|
351
|
+
var element = view.$(this);
|
352
|
+
var bindingAttr = config.getBindingAttr('checkbox');
|
353
|
+
var attribute_name = config.getBindingValue(element, 'checkbox');
|
354
|
+
|
355
|
+
var modelChange = function(model, val){
|
356
|
+
if (val){
|
357
|
+
element.attr("checked", "checked");
|
358
|
+
}
|
359
|
+
else{
|
360
|
+
element.removeAttr("checked");
|
361
|
+
}
|
362
|
+
};
|
363
|
+
|
364
|
+
var setModelValue = function(attr_name, value){
|
365
|
+
var data = {};
|
366
|
+
data[attr_name] = value;
|
367
|
+
model.set(data);
|
368
|
+
};
|
369
|
+
|
370
|
+
var elementChange = function(ev){
|
371
|
+
var changedElement = view.$(ev.target);
|
372
|
+
var checked = changedElement.is(":checked")? true : false;
|
373
|
+
setModelValue(attribute_name, checked);
|
374
|
+
};
|
375
|
+
|
376
|
+
modelBinder.registerModelBinding(model, attribute_name, modelChange);
|
377
|
+
modelBinder.registerElementBinding(element, elementChange);
|
378
|
+
|
379
|
+
var attr_exists = model.attributes.hasOwnProperty(attribute_name);
|
380
|
+
if (attr_exists) {
|
381
|
+
// set the default value on the form, from the model
|
382
|
+
var attr_value = getAttributeValue(model, attribute_name);
|
383
|
+
if (typeof attr_value !== "undefined" && attr_value !== null && attr_value != false) {
|
384
|
+
element.attr("checked", "checked");
|
385
|
+
}
|
386
|
+
else{
|
387
|
+
element.removeAttr("checked");
|
388
|
+
}
|
389
|
+
} else {
|
390
|
+
// bind the form's value to the model
|
391
|
+
var checked = element.is(":checked")? true : false;
|
392
|
+
setModelValue(attribute_name, checked);
|
393
|
+
}
|
394
|
+
});
|
395
|
+
};
|
396
|
+
|
397
|
+
return methods;
|
398
|
+
})(Backbone);
|
399
|
+
|
400
|
+
// ----------------------------
|
401
|
+
// Data-Bind Binding Methods
|
402
|
+
// ----------------------------
|
403
|
+
var DataBindBinding = (function(Backbone, _, $){
|
404
|
+
var dataBindSubstConfig = {
|
405
|
+
"default": ""
|
406
|
+
};
|
407
|
+
|
408
|
+
modelBinding.Configuration.dataBindSubst = function(config){
|
409
|
+
this.storeDataBindSubstConfig();
|
410
|
+
_.extend(dataBindSubstConfig, config);
|
411
|
+
};
|
412
|
+
|
413
|
+
modelBinding.Configuration.storeDataBindSubstConfig = function(){
|
414
|
+
modelBinding.Configuration._dataBindSubstConfig = _.clone(dataBindSubstConfig);
|
415
|
+
};
|
416
|
+
|
417
|
+
modelBinding.Configuration.restoreDataBindSubstConfig = function(){
|
418
|
+
if (modelBinding.Configuration._dataBindSubstConfig){
|
419
|
+
dataBindSubstConfig = modelBinding.Configuration._dataBindSubstConfig;
|
420
|
+
delete modelBinding.Configuration._dataBindSubstConfig;
|
421
|
+
}
|
422
|
+
};
|
423
|
+
|
424
|
+
modelBinding.Configuration.getDataBindSubst = function(elementType, value){
|
425
|
+
var returnValue = value;
|
426
|
+
if (value === undefined){
|
427
|
+
if (dataBindSubstConfig.hasOwnProperty(elementType)){
|
428
|
+
returnValue = dataBindSubstConfig[elementType];
|
429
|
+
} else {
|
430
|
+
returnValue = dataBindSubstConfig["default"];
|
431
|
+
}
|
432
|
+
}
|
433
|
+
return returnValue;
|
434
|
+
};
|
435
|
+
|
436
|
+
var setOnElement = function(element, attr, val){
|
437
|
+
var valBefore = val;
|
438
|
+
val = modelBinding.Configuration.getDataBindSubst(attr, val);
|
439
|
+
switch(attr){
|
440
|
+
case "html":
|
441
|
+
element.html(val);
|
442
|
+
break;
|
443
|
+
case "text":
|
444
|
+
element.text(val);
|
445
|
+
break;
|
446
|
+
case "enabled":
|
447
|
+
element.attr("disabled", !val);
|
448
|
+
break;
|
449
|
+
case "displayed":
|
450
|
+
element[val? "show" : "hide"]();
|
451
|
+
break;
|
452
|
+
case "hidden":
|
453
|
+
element[val? "hide" : "show"]();
|
454
|
+
break;
|
455
|
+
default:
|
456
|
+
element.attr(attr, val);
|
457
|
+
}
|
458
|
+
};
|
459
|
+
|
460
|
+
var splitBindingAttr = function(element)
|
461
|
+
{
|
462
|
+
var dataBindConfigList = [];
|
463
|
+
var dataBindAttributeName = modelBinding.Conventions.databind.selector.replace(/^(.*\[)([^\]]*)(].*)/g, '$2');
|
464
|
+
var databindList = element.attr(dataBindAttributeName).split(";");
|
465
|
+
_.each(databindList, function(attrbind){
|
466
|
+
var databind = $.trim(attrbind).split(" ");
|
467
|
+
|
468
|
+
// make the default special case "text" if none specified
|
469
|
+
if( databind.length == 1 ) databind.unshift("text");
|
470
|
+
|
471
|
+
dataBindConfigList.push({
|
472
|
+
elementAttr: databind[0],
|
473
|
+
modelAttr: databind[1]
|
474
|
+
});
|
475
|
+
});
|
476
|
+
return dataBindConfigList;
|
477
|
+
};
|
478
|
+
|
479
|
+
var getEventConfiguration = function(element, databind){
|
480
|
+
var config = {};
|
481
|
+
var eventName = databind.modelAttr;
|
482
|
+
var index = eventName.indexOf("event:");
|
483
|
+
|
484
|
+
if (index == 0) {
|
485
|
+
// "event:foo" binding
|
486
|
+
config.name = eventName.substr(6);
|
487
|
+
config.callback = function(val){
|
488
|
+
setOnElement(element, databind.elementAttr, val);
|
489
|
+
};
|
490
|
+
} else {
|
491
|
+
// standard model attribute binding
|
492
|
+
config.name = "change:" + eventName;
|
493
|
+
config.callback = function(model, val){
|
494
|
+
setOnElement(element, databind.elementAttr, val);
|
495
|
+
};
|
496
|
+
}
|
497
|
+
|
498
|
+
return config;
|
499
|
+
}
|
500
|
+
var methods = {};
|
501
|
+
|
502
|
+
methods.bind = function(selector, view, model, config){
|
503
|
+
var modelBinder = this;
|
504
|
+
|
505
|
+
view.$(selector).each(function(index){
|
506
|
+
var element = view.$(this);
|
507
|
+
var databindList = splitBindingAttr(element);
|
508
|
+
|
509
|
+
_.each(databindList, function(databind){
|
510
|
+
var eventConfig = getEventConfiguration(element, databind);
|
511
|
+
modelBinder.registerDataBinding(model, eventConfig.name, eventConfig.callback);
|
512
|
+
// set default on data-bind element
|
513
|
+
setOnElement(element, databind.elementAttr, getAttributeValue(model, databind.modelAttr));
|
514
|
+
});
|
515
|
+
|
516
|
+
});
|
517
|
+
};
|
518
|
+
|
519
|
+
return methods;
|
520
|
+
})(Backbone, _, $);
|
521
|
+
|
522
|
+
|
523
|
+
// ----------------------------
|
524
|
+
// Binding Conventions
|
525
|
+
// ----------------------------
|
526
|
+
modelBinding.Conventions = {
|
527
|
+
text: {selector: "input:text", handler: StandardBinding},
|
528
|
+
textarea: {selector: "textarea", handler: StandardBinding},
|
529
|
+
password: {selector: "input:password", handler: StandardBinding},
|
530
|
+
radio: {selector: "input:radio", handler: RadioGroupBinding},
|
531
|
+
checkbox: {selector: "input:checkbox", handler: CheckboxBinding},
|
532
|
+
select: {selector: "select", handler: SelectBoxBinding},
|
533
|
+
databind: { selector: "*[data-bind]", handler: DataBindBinding},
|
534
|
+
// HTML5 input
|
535
|
+
number: {selector: "input[type=number]", handler: StandardBinding},
|
536
|
+
range: {selector: "input[type=range]", handler: StandardBinding},
|
537
|
+
tel: {selector: "input[type=tel]", handler: StandardBinding},
|
538
|
+
search: {selector: "input[type=search]", handler: StandardBinding},
|
539
|
+
url: {selector: "input[type=url]", handler: StandardBinding},
|
540
|
+
email: {selector: "input[type=email]", handler: StandardBinding}
|
541
|
+
};
|
542
|
+
|
543
|
+
return modelBinding;
|
544
|
+
});
|
545
|
+
|
546
|
+
// Backbone.Modelbinding AMD wrapper with namespace fallback
|
547
|
+
if (typeof define === 'function' && define.amd) {
|
548
|
+
// AMD support
|
549
|
+
define([
|
550
|
+
'backbone', // use Backbone 0.5.3-optamd3 branch (https://github.com/jrburke/backbone/tree/optamd3)
|
551
|
+
'underscore', // AMD supported
|
552
|
+
'jquery' // AMD supported
|
553
|
+
], function (Backbone, _, jQuery) {
|
554
|
+
return modelbinding(Backbone, _, jQuery);
|
555
|
+
});
|
556
|
+
} else {
|
557
|
+
// No AMD, use Backbone namespace
|
558
|
+
root.Backbone = Backbone || {};
|
559
|
+
root.Backbone.ModelBinding = modelbinding(Backbone, _, jQuery);
|
560
|
+
}
|
561
|
+
|
562
|
+
})(this);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appetizer-ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-17 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appetizer
|
16
|
-
requirement: &
|
16
|
+
requirement: &70341860019700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70341860019700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: coffee-script
|
27
|
-
requirement: &
|
27
|
+
requirement: &70341860018680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '2.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70341860018680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: eco
|
38
|
-
requirement: &
|
38
|
+
requirement: &70341860017860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70341860017860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rack-contrib
|
49
|
-
requirement: &
|
49
|
+
requirement: &70341860016980 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '1.1'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70341860016980
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rack-ssl
|
60
|
-
requirement: &
|
60
|
+
requirement: &70341860016160 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.3'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70341860016160
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sass
|
71
|
-
requirement: &
|
71
|
+
requirement: &70341860015300 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '3.1'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70341860015300
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: sinatra
|
82
|
-
requirement: &
|
82
|
+
requirement: &70341860014480 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '1.3'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70341860014480
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: sprockets
|
93
|
-
requirement: &
|
93
|
+
requirement: &70341860013560 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,21 @@ dependencies:
|
|
98
98
|
version: '2.1'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70341860013560
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: sprockets-sass
|
104
|
+
requirement: &70341860012740 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.6'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *70341860012740
|
102
113
|
- !ruby/object:Gem::Dependency
|
103
114
|
name: uglifier
|
104
|
-
requirement: &
|
115
|
+
requirement: &70341860011920 !ruby/object:Gem::Requirement
|
105
116
|
none: false
|
106
117
|
requirements:
|
107
118
|
- - ~>
|
@@ -109,10 +120,10 @@ dependencies:
|
|
109
120
|
version: '1.0'
|
110
121
|
type: :runtime
|
111
122
|
prerelease: false
|
112
|
-
version_requirements: *
|
123
|
+
version_requirements: *70341860011920
|
113
124
|
- !ruby/object:Gem::Dependency
|
114
125
|
name: yajl-ruby
|
115
|
-
requirement: &
|
126
|
+
requirement: &70341860010480 !ruby/object:Gem::Requirement
|
116
127
|
none: false
|
117
128
|
requirements:
|
118
129
|
- - ~>
|
@@ -120,10 +131,10 @@ dependencies:
|
|
120
131
|
version: '1.0'
|
121
132
|
type: :runtime
|
122
133
|
prerelease: false
|
123
|
-
version_requirements: *
|
134
|
+
version_requirements: *70341860010480
|
124
135
|
- !ruby/object:Gem::Dependency
|
125
136
|
name: yui-compressor
|
126
|
-
requirement: &
|
137
|
+
requirement: &70341860009860 !ruby/object:Gem::Requirement
|
127
138
|
none: false
|
128
139
|
requirements:
|
129
140
|
- - ~>
|
@@ -131,7 +142,7 @@ dependencies:
|
|
131
142
|
version: '0.9'
|
132
143
|
type: :runtime
|
133
144
|
prerelease: false
|
134
|
-
version_requirements: *
|
145
|
+
version_requirements: *70341860009860
|
135
146
|
description: A painfully opinionated Appetizer extension for web apps.
|
136
147
|
email:
|
137
148
|
- tech@audiosocket.com
|
@@ -163,6 +174,7 @@ files:
|
|
163
174
|
- lib/appetizer/ui/rake.rb
|
164
175
|
- lib/appetizer/ui/spec.rb
|
165
176
|
- lib/appetizer/ui/vendor/js/backbone.js
|
177
|
+
- lib/appetizer/ui/vendor/js/backbone.modelbinding.js
|
166
178
|
- lib/appetizer/ui/vendor/js/jquery.js
|
167
179
|
- lib/appetizer/ui/vendor/js/json2.js
|
168
180
|
- lib/appetizer/ui/vendor/js/underscore.js
|