ember-bootstrap-source 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,954 @@
1
+ // Version: v0.0.2-22-g2410c9e
2
+ // Last commit: 2410c9e (2013-07-29 14:31:26 +0200)
3
+
4
+
5
+ (function() {
6
+ var define, requireModule;
7
+
8
+ (function() {
9
+ var registry = {}, seen = {};
10
+
11
+ define = function(name, deps, callback) {
12
+ registry[name] = { deps: deps, callback: callback };
13
+ };
14
+
15
+ requireModule = function(name) {
16
+ if (seen[name]) { return seen[name]; }
17
+ seen[name] = {};
18
+
19
+ var mod, deps, callback, reified , exports;
20
+
21
+ mod = registry[name];
22
+
23
+ if (!mod) {
24
+ throw new Error("Module '" + name + "' not found.");
25
+ }
26
+
27
+ deps = mod.deps;
28
+ callback = mod.callback;
29
+ reified = [];
30
+ exports;
31
+
32
+ for (var i=0, l=deps.length; i<l; i++) {
33
+ if (deps[i] === 'exports') {
34
+ reified.push(exports = {});
35
+ } else {
36
+ reified.push(requireModule(deps[i]));
37
+ }
38
+ }
39
+
40
+ var value = callback.apply(this, reified);
41
+ return seen[name] = exports || value;
42
+ };
43
+ })();
44
+ (function() {
45
+ window.Bootstrap = Ember.Namespace.create();
46
+
47
+ })();
48
+
49
+
50
+
51
+ (function() {
52
+ var get = Ember.get;
53
+
54
+ var modalPaneTemplate = [
55
+ '<div class="modal-header">',
56
+ ' <a href="#" class="close" rel="close">&times;</a>',
57
+ ' {{view view.headerViewClass}}',
58
+ '</div>',
59
+ '<div class="modal-body">{{view view.bodyViewClass}}</div>',
60
+ '<div class="modal-footer">',
61
+ ' {{view view.footerViewClass}}',
62
+ '</div>'].join("\n");
63
+
64
+ var footerTemplate = [
65
+ '{{#if view.parentView.secondary}}<a href="#" class="btn btn-secondary" rel="secondary">{{view.parentView.secondary}}</a>{{/if}}',
66
+ '{{#if view.parentView.primary}}<a href="#" class="btn btn-primary" rel="primary">{{view.parentView.primary}}</a>{{/if}}'].join("\n");
67
+
68
+ var modalPaneBackdrop = '<div class="modal-backdrop"></div>';
69
+
70
+ Bootstrap.ModalPane = Ember.View.extend(Ember.DeferredMixin, {
71
+ classNames: 'modal',
72
+ defaultTemplate: Ember.Handlebars.compile(modalPaneTemplate),
73
+ heading: null,
74
+ message: null,
75
+ primary: null,
76
+ secondary: null,
77
+ showBackdrop: true,
78
+ headerViewClass: Ember.View.extend({
79
+ tagName: 'h3',
80
+ template: Ember.Handlebars.compile('{{view.parentView.heading}}')
81
+ }),
82
+ bodyViewClass: Ember.View.extend({
83
+ tagName: 'p',
84
+ template: Ember.Handlebars.compile('{{{view.parentView.message}}}')
85
+ }),
86
+ footerViewClass: Ember.View.extend({
87
+ template: Ember.Handlebars.compile(footerTemplate)
88
+ }),
89
+
90
+ didInsertElement: function() {
91
+ if (get(this, 'showBackdrop')) this._appendBackdrop();
92
+ this._setupDocumentKeyHandler();
93
+ },
94
+
95
+ willDestroyElement: function() {
96
+ if (this._backdrop) this._backdrop.remove();
97
+ this._removeDocumentKeyHandler();
98
+ },
99
+
100
+ keyPress: function(event) {
101
+ if (event.keyCode === 27) {
102
+ this._triggerCallbackAndDestroy({ close: true }, event);
103
+ }
104
+ },
105
+
106
+ click: function(event) {
107
+ var target = event.target,
108
+ targetRel = target.getAttribute('rel');
109
+
110
+ if (targetRel) {
111
+ var options = {};
112
+ options[targetRel] = true;
113
+
114
+ this._triggerCallbackAndDestroy(options, event);
115
+ return false;
116
+ }
117
+ },
118
+
119
+ _appendBackdrop: function() {
120
+ var parentLayer = this.$().parent();
121
+ this._backdrop = jQuery(modalPaneBackdrop).appendTo(parentLayer);
122
+ },
123
+
124
+ _setupDocumentKeyHandler: function() {
125
+ var cc = this,
126
+ handler = function(event) {
127
+ cc.keyPress(event);
128
+ };
129
+ jQuery(window.document).bind('keyup', handler);
130
+ this._keyUpHandler = handler;
131
+ },
132
+
133
+ _removeDocumentKeyHandler: function() {
134
+ jQuery(window.document).unbind('keyup', this._keyUpHandler);
135
+ },
136
+
137
+ _resolveOrReject: function(options, event) {
138
+ if (options.primary) this.resolve(options, event);
139
+ else this.reject(options, event);
140
+ },
141
+
142
+ _triggerCallbackAndDestroy: function(options, event) {
143
+ var destroy;
144
+ if (this.callback) {
145
+ destroy = this.callback(options, event);
146
+ }
147
+ if (destroy === undefined || destroy) {
148
+ this._resolveOrReject(options, event);
149
+ this.destroy();
150
+ }
151
+ }
152
+ });
153
+
154
+ Bootstrap.ModalPane.reopenClass({
155
+ rootElement: ".ember-application",
156
+ popup: function(options) {
157
+ var modalPane, rootElement;
158
+ if (!options) options = {};
159
+ modalPane = this.create(options);
160
+ rootElement = get(this, 'rootElement');
161
+ modalPane.appendTo(rootElement);
162
+ return modalPane;
163
+ }
164
+ });
165
+
166
+
167
+ })();
168
+
169
+
170
+
171
+ (function() {
172
+ var get = Ember.get, set = Ember.set;
173
+
174
+ Bootstrap.TypeSupport = Ember.Mixin.create({
175
+ baseClassName: Ember.required(String),
176
+ classNameBindings: ['typeClass'],
177
+ type: null, // success, warning, error, info || inverse
178
+ typeClass: Ember.computed(function() {
179
+ var type = get(this, 'type'),
180
+ baseClassName = get(this, 'baseClassName');
181
+ return type ? baseClassName + '-' + type : null;
182
+ }).property('type').cacheable()
183
+ });
184
+
185
+ })();
186
+
187
+
188
+
189
+ (function() {
190
+ var get = Ember.get;
191
+ Bootstrap.AlertMessage = Ember.View.extend(Bootstrap.TypeSupport, {
192
+ classNames: ['alert', 'alert-message'],
193
+ baseClassName: 'alert',
194
+ template: Ember.Handlebars.compile('<a class="close" rel="close" href="#">&times;</a>{{{view.message}}}'),
195
+ message: null,
196
+ removeAfter: null,
197
+
198
+ didInsertElement: function() {
199
+ var removeAfter = get(this, 'removeAfter');
200
+ if (removeAfter > 0) {
201
+ Ember.run.later(this, 'destroy', removeAfter);
202
+ }
203
+ },
204
+
205
+ click: function(event) {
206
+ var target = event.target,
207
+ targetRel = target.getAttribute('rel');
208
+
209
+ if (targetRel === 'close') {
210
+ this.destroy();
211
+ return false;
212
+ }
213
+ }
214
+ });
215
+
216
+ })();
217
+
218
+
219
+
220
+ (function() {
221
+ Bootstrap.BlockAlertMessage = Bootstrap.AlertMessage.extend({
222
+ classNames: ['alert', 'alert-block']
223
+ });
224
+
225
+ })();
226
+
227
+
228
+
229
+ (function() {
230
+ var get = Ember.get;
231
+
232
+ Bootstrap.ItemViewValueSupport = Ember.Mixin.create({
233
+ value: Ember.computed(function() {
234
+ var parentView = get(this, 'parentView'),
235
+ content, valueKey;
236
+ if (!parentView) return null;
237
+ content = get(this, 'content');
238
+ valueKey = get(parentView, 'itemValueKey') || 'value';
239
+ return get(content, valueKey) || content;
240
+ }).property('content').cacheable()
241
+ });
242
+
243
+ })();
244
+
245
+
246
+
247
+ (function() {
248
+ var get = Ember.get;
249
+
250
+ Bootstrap.ItemViewTitleSupport = Ember.Mixin.create({
251
+ title: Ember.computed(function() {
252
+ var parentView = get(this, 'parentView'),
253
+ content,
254
+ titleKey;
255
+
256
+ content = get(this, 'content');
257
+ if (parentView) {
258
+ titleKey = get(parentView, 'itemTitleKey') || 'title';
259
+
260
+ return get(content, titleKey) || content;
261
+ }
262
+
263
+ return content;
264
+ }).property('content').cacheable()
265
+ });
266
+
267
+ })();
268
+
269
+
270
+
271
+ (function() {
272
+ var get = Ember.get, set = Ember.set;
273
+
274
+ Bootstrap.ItemSelectionSupport = Ember.Mixin.create(Bootstrap.ItemViewValueSupport, Bootstrap.ItemViewTitleSupport, {
275
+ classNameBindings: ["isActive:active"],
276
+ allowsEmptySelection: false,
277
+
278
+ isActive: Ember.computed(function() {
279
+ var parentView = get(this, 'parentView'),
280
+ selection, value;
281
+ if (!parentView) return false;
282
+ selection = get(parentView, 'selection');
283
+ value = get(this, 'value');
284
+ return selection === value;
285
+ }).property('parentView.selection', 'value').cacheable(),
286
+
287
+ click: function(event) {
288
+ var value = get(this, 'value'),
289
+ parentView = get(this, 'parentView'),
290
+ allowsEmptySelection = get(parentView, 'allowsEmptySelection'),
291
+ selection = get(parentView, 'selection');
292
+ if (allowsEmptySelection === true && selection === value) {
293
+ value = null;
294
+ }
295
+ set(parentView, 'selection', value);
296
+ return true;
297
+ }
298
+ });
299
+
300
+ })();
301
+
302
+
303
+
304
+ (function() {
305
+ var get = Ember.get;
306
+
307
+ Bootstrap.ItemViewHrefSupport = Ember.Mixin.create({
308
+ href: Ember.computed(function() {
309
+ var parentView = get(this, 'parentView'),
310
+ content, hrefKey;
311
+ content = get(this, 'content');
312
+ if (parentView) {
313
+ hrefKey = get(parentView, 'itemHrefKey') || 'link';
314
+ return get(content, hrefKey) || '#';
315
+ }
316
+ return content;
317
+ }).property('content').cacheable()
318
+ });
319
+
320
+ })();
321
+
322
+
323
+
324
+ (function() {
325
+ Bootstrap.PillItem = Ember.View.extend(Bootstrap.ItemSelectionSupport, Bootstrap.ItemViewHrefSupport, {
326
+ template: Ember.Handlebars.compile('{{view view.item}}'),
327
+
328
+ item: Ember.View.extend({
329
+ tagName: 'a',
330
+ template: Ember.Handlebars.compile('{{view.parentView.title}}'),
331
+ attributeBindings: ['href'],
332
+ hrefBinding: 'parentView.href'
333
+ })
334
+ });
335
+
336
+ })();
337
+
338
+
339
+
340
+ (function() {
341
+ Bootstrap.Pills = Ember.CollectionView.extend({
342
+ classNames: ['nav', 'nav-pills'],
343
+ classNameBindings: ['isStacked:nav-stacked'],
344
+ tagName: 'ul',
345
+ itemViewClass: Bootstrap.PillItem,
346
+ selection: null
347
+ });
348
+
349
+ })();
350
+
351
+
352
+
353
+ (function() {
354
+ Bootstrap.Tabs = Ember.CollectionView.extend({
355
+ classNames: ['nav', 'nav-tabs'],
356
+ classNameBindings: ['isStacked:nav-stacked'],
357
+ tagName: 'ul',
358
+ itemViewClass: Bootstrap.PillItem,
359
+ selection: null
360
+ });
361
+
362
+ })();
363
+
364
+
365
+
366
+ (function() {
367
+ Bootstrap.NavList = Ember.CollectionView.extend({
368
+ classNames: ['nav', 'nav-list'],
369
+ tagName: 'ul',
370
+ itemViewClass: Bootstrap.PillItem,
371
+ selection: null
372
+ });
373
+
374
+ })();
375
+
376
+
377
+
378
+ (function() {
379
+ var get = Ember.get, fmt = Ember.String.fmt;
380
+
381
+ Bootstrap.ProgressBar = Ember.View.extend({
382
+ classNames: ['progress'],
383
+ classNameBindings: ['isStriped:progress-striped', 'isAnimated:active'],
384
+ template: Ember.Handlebars.compile('<div class="bar" {{bindAttr style="view.style"}}></div>'),
385
+ isAnimated: false,
386
+ isStriped: false,
387
+ progress: 0,
388
+
389
+ style: Ember.computed(function() {
390
+ var progress = get(this, 'progress');
391
+
392
+ return fmt('width:%@%;', [progress]);
393
+ }).property('progress').cacheable()
394
+ });
395
+
396
+ })();
397
+
398
+
399
+
400
+ (function() {
401
+ Bootstrap.Badge = Ember.View.extend(Bootstrap.TypeSupport, {
402
+ tagName: 'span',
403
+ classNames: ['badge'],
404
+ baseClassName: 'badge',
405
+ template: Ember.Handlebars.compile('{{view.content}}')
406
+ });
407
+
408
+ })();
409
+
410
+
411
+
412
+ (function() {
413
+ Bootstrap.Label = Ember.View.extend(Bootstrap.TypeSupport, {
414
+ tagName: 'span',
415
+ classNames: ['label'],
416
+ baseClassName: 'label',
417
+ template: Ember.Handlebars.compile('{{view.content}}')
418
+ });
419
+
420
+ })();
421
+
422
+
423
+
424
+ (function() {
425
+ var get = Ember.get;
426
+
427
+ Bootstrap.Well = Ember.View.extend({
428
+ template: Ember.Handlebars.compile('{{view.content}}'),
429
+ classNames: 'well',
430
+ content: null
431
+ });
432
+
433
+ })();
434
+
435
+
436
+
437
+ (function() {
438
+ var A = Ember.A;
439
+
440
+ Bootstrap.Pagination = Ember.CollectionView.extend({
441
+ tagName: 'ul',
442
+ classNames: ['pagination'],
443
+ itemTitleKey: 'title',
444
+ itemHrefKey: 'href',
445
+ init: function() {
446
+ this._super();
447
+ if (!this.get('content')) {
448
+ this.set('content', new A([]));
449
+ }
450
+ },
451
+ itemViewClass: Ember.View.extend(Bootstrap.ItemSelectionSupport, Bootstrap.ItemViewHrefSupport, {
452
+ classNameBindings: ['content.disabled'],
453
+ template: Ember.Handlebars.compile('<a {{bindAttr href="view.href"}}>{{view.title}}</a>')
454
+ })
455
+ });
456
+
457
+ })();
458
+
459
+
460
+
461
+ (function() {
462
+ Bootstrap.Pager = Ember.CollectionView.extend({
463
+ tagName: 'ul',
464
+ classNames: ['pager'],
465
+ itemTitleKey: 'title',
466
+ itemHrefKey: 'href',
467
+ init: function() {
468
+ this._super();
469
+ if (!this.get('content')) {
470
+ this.set('content', Ember.A([
471
+ Ember.Object.create({ title: '&larr;' }),
472
+ Ember.Object.create({ title: '&rarr;' })
473
+ ]));
474
+ }
475
+ },
476
+ itemViewClass: Ember.View.extend(Bootstrap.ItemViewTitleSupport, Bootstrap.ItemViewHrefSupport, {
477
+ classNameBindings: ['content.next', 'content.previous', 'content.disabled'],
478
+ template: Ember.Handlebars.compile('<a {{bindAttr href="view.href"}}>{{{view.title}}}</a>')
479
+ }),
480
+ arrayDidChange: function(content, start, removed, added) {
481
+ if (content) {
482
+ Ember.assert('content must always has at the most 2 elements', content.get('length') <= 2);
483
+ }
484
+ return this._super(content, start, removed, added);
485
+ }
486
+ });
487
+
488
+ })();
489
+
490
+
491
+
492
+ (function() {
493
+ var get = Ember.get;
494
+
495
+ Bootstrap.FirstLastViewSupport = Ember.Mixin.create({
496
+ createChildView: function(view, attrs) {
497
+ var content;
498
+
499
+ if (attrs) {
500
+ content = get(this, 'content');
501
+
502
+ if (attrs.contentIndex === 0) {
503
+ view = get(this, 'firstItemViewClass') || view;
504
+ }
505
+ if (attrs.contentIndex === (get(content, 'length') - 1)) {
506
+ view = get(this, 'lastItemViewClass') || view;
507
+ }
508
+ }
509
+ return this._super(view, attrs);
510
+ }
511
+ });
512
+
513
+ })();
514
+
515
+
516
+
517
+ (function() {
518
+ var get = Ember.get;
519
+
520
+ Bootstrap.Breadcrumb = Ember.CollectionView.extend(Bootstrap.FirstLastViewSupport, {
521
+ tagName: 'ul',
522
+ classNames: ['breadcrumb'],
523
+ divider: '/',
524
+ arrayDidChange: function(content, start, removed, added) {
525
+ var view,
526
+ index,
527
+ length,
528
+ item,
529
+ lastItemViewClass = get(this, 'lastItemViewClass'),
530
+ itemViewClass = get(this, 'itemViewClass'),
531
+ lastView;
532
+
533
+ this._super.apply(this, arguments);
534
+
535
+ if (!content)
536
+ return;
537
+
538
+ length = get(content, 'length');
539
+
540
+ if (removed) {
541
+ lastView = get(this, 'childViews.lastObject');
542
+
543
+ if (lastItemViewClass.detectInstance(lastView))
544
+ return;
545
+
546
+ index = length - 1;
547
+
548
+ view = this.createChildView(lastItemViewClass, {
549
+ content: content[index],
550
+ contentIndex: index
551
+ });
552
+
553
+ this.replace(index, 1, [view]);
554
+ }
555
+
556
+ if (added) {
557
+ get(this, 'childViews').forEach(function(childView, index) {
558
+ if (lastItemViewClass.detectInstance(childView) && index !== length - 1) {
559
+ view = this.createChildView(itemViewClass, {
560
+ content: content[index],
561
+ contentIndex: index
562
+ });
563
+
564
+ this.replace(index, 1, [view]);
565
+ }
566
+ }, this);
567
+
568
+ }
569
+
570
+ },
571
+ itemViewClass: Ember.View.extend(Bootstrap.ItemViewTitleSupport, {
572
+ template: Ember.Handlebars.compile('<a href="#">{{view.title}}</a><span class="divider">{{view.parentView.divider}}</span>')
573
+ }),
574
+ lastItemViewClass: Ember.View.extend(Bootstrap.ItemViewTitleSupport, {
575
+ classNames: ['active'],
576
+ template: Ember.Handlebars.compile('{{view.title}}')
577
+ })
578
+ });
579
+
580
+ })();
581
+
582
+
583
+
584
+ (function() {
585
+ /**
586
+ * @property buttonDropdownTemplate
587
+ * @type {String}
588
+ */
589
+ var buttonDropdownTemplate = [
590
+ '<a {{bindAttr class="view.typeClass :btn :dropdown-toggle" }} data-toggle="dropdown" href="#">',
591
+ '{{view.label}}',
592
+ '<span class="caret"></span>',
593
+ '</a>',
594
+ '<ul class="dropdown-menu">',
595
+ ' {{#if view.items}}',
596
+ ' {{#each item in view.items}}',
597
+ ' <li {{bindAttr class="item.disabled:disabled"}}>{{view view.Item contextBinding="item"}}</li>',
598
+ ' {{/each}}',
599
+ ' {{/if}}',
600
+ '</ul>'
601
+ ].join("\n");
602
+
603
+ /**
604
+ * @property Bootstrap.ButtonDropdown
605
+ * @type {Ember.View}
606
+ */
607
+ Bootstrap.ButtonDropdown = Ember.View.extend({
608
+
609
+ /**
610
+ * @property label
611
+ * @type {String}
612
+ */
613
+ label: null,
614
+
615
+ /**
616
+ * @property items
617
+ * @type {Array}
618
+ */
619
+ items: [],
620
+
621
+ /**
622
+ * @property classNames
623
+ * @type {Array}
624
+ */
625
+ classNames: ['btn-group'],
626
+
627
+ /**
628
+ * @property defaultTemplate
629
+ * @type {String}
630
+ */
631
+ defaultTemplate: Ember.Handlebars.compile(buttonDropdownTemplate),
632
+
633
+ /**
634
+ * @property Item
635
+ * @type {Ember.View}
636
+ */
637
+ Item: Ember.View.extend({
638
+
639
+ /**
640
+ * @property tagName
641
+ * @type {String}
642
+ * @default "a"
643
+ */
644
+ tagName: 'a',
645
+
646
+ /**
647
+ * @property attributeBindings
648
+ * @type {Array}
649
+ */
650
+ attributeBindings: ['href'],
651
+
652
+ /**
653
+ * @property template
654
+ * @type {Function}
655
+ */
656
+ template: Ember.Handlebars.compile('{{label}}'),
657
+
658
+ /**
659
+ * @property href
660
+ * @type {Object}
661
+ * @return {String}
662
+ */
663
+ href: '#',
664
+
665
+ /**
666
+ * @method click
667
+ * Attempt to invoke the specified action name on the controller.
668
+ * @return {void}
669
+ */
670
+ click: function() {
671
+
672
+ var item = Ember.get(this, 'context'),
673
+ actionName = Ember.get(item, 'actionName'),
674
+ controller = Ember.get(this, 'controller');
675
+ var disabled = Ember.get(item, 'disabled');
676
+
677
+ if (disabled === true) {
678
+ // We won't invoke the action if it's disabled.
679
+ return;
680
+ }
681
+
682
+ Ember.assert('View `Bootstrap.ButtonDropdown` does not have a controller attached.', !!Ember.get(this, 'controller'));
683
+ Ember.assert(Ember.String.fmt('Controller `%@` does not have an action `%@`!', controller, actionName), !!Ember.canInvoke(controller, actionName));
684
+
685
+ // Invoke the action on the controller, passing in the item as the first param.
686
+ Ember.tryInvoke(controller, actionName, [item]);
687
+ }
688
+
689
+ })
690
+
691
+ });
692
+
693
+ })();
694
+
695
+
696
+
697
+ (function() {
698
+ Bootstrap.Forms = Ember.Namespace.create({
699
+
700
+ human: function(value) {
701
+ if (value === undefined || value === false)
702
+ return;
703
+
704
+ // Underscore string
705
+ value = Ember.String.decamelize(value);
706
+ // Replace all _ with spaces
707
+ value = value.replace(/_/g, " ");
708
+ // Capitalize the first letter of every word
709
+ value = value.replace(/(^|\s)([a-z])/g, function(m,p1,p2){ return p1+p2.toUpperCase(); });
710
+ return value;
711
+ }
712
+ });
713
+
714
+ })();
715
+
716
+
717
+
718
+ (function() {
719
+ Bootstrap.Forms.Field = Ember.View.extend({
720
+ tagName: 'div',
721
+ classNames: ['control-group'],
722
+ labelCache: undefined,
723
+ help: undefined,
724
+ template: Ember.Handlebars.compile([
725
+ '{{view view.labelView viewName="labelView"}}',
726
+ '<div class="controls">',
727
+ ' {{view view.inputField viewName="inputField"}}',
728
+ ' {{view view.errorsView}}',
729
+ ' {{view view.helpView}}',
730
+ '</div>'].join("\n")),
731
+
732
+ label: Ember.computed(function(key, value) {
733
+ if(arguments.length === 1){
734
+ if(this.get('labelCache') === undefined){
735
+ var path = this.get('valueBinding._from');
736
+ if (path) {
737
+ path = path.split(".");
738
+ return path[path.length - 1];
739
+ }
740
+ } else {
741
+ return this.get('labelCache');
742
+ }
743
+ } else {
744
+ this.set('labelCache', value);
745
+ return value;
746
+ }
747
+ }).property(),
748
+
749
+ labelView: Ember.View.extend({
750
+ tagName: 'label',
751
+ classNames: ['control-label'],
752
+ template: Ember.Handlebars.compile('{{view.value}}'),
753
+
754
+ value: Ember.computed(function(key, value) {
755
+ var parent = this.get('parentView');
756
+
757
+ if (value && value !== parent.get('label')) {
758
+ parent.set('label', value);
759
+ } else {
760
+ value = parent.get('label');
761
+ }
762
+
763
+ // If the labelCache property is present on parent, then the
764
+ // label was set manually, and there's no need to humanise it.
765
+ // Otherwise, it comes from the binding and needs to be
766
+ // humanised.
767
+ return parent.get('labelCache') === undefined || parent.get('labelCache') === false ?
768
+ Bootstrap.Forms.human(value) : value;
769
+ }).property('parentView.label'),
770
+
771
+ inputElementId: 'for',
772
+ forBinding: 'inputElementId',
773
+ attributeBindings: ['for']
774
+ }),
775
+
776
+ inputField: Ember.View.extend({
777
+ classNames: ['ember-bootstrap-extend'],
778
+ tagName: 'div',
779
+ template: Ember.Handlebars.compile('This class is not meant to be used directly, but extended.')
780
+ }),
781
+
782
+ errorsView: Ember.View.extend({
783
+ tagName: 'div',
784
+ classNames: ['errors', 'help-inline'],
785
+
786
+ _updateContent: Ember.observer(function() {
787
+ var parent = this.get('parentView');
788
+
789
+ if (parent !== null) {
790
+ var binding = parent.get('valueBinding._from');
791
+ var fieldName = null;
792
+ var object = null;
793
+
794
+ if (binding) {
795
+ binding = binding.replace("_parentView.", "").split(".");
796
+ fieldName = binding[binding.length - 1];
797
+ object = parent.get(binding.slice(0, binding.length-1).join('.'));
798
+ } else {
799
+ fieldName = parent.get('label');
800
+ object = parent.get('context');
801
+ }
802
+
803
+ if (object && !object.get('isValid')) {
804
+ var errors = object.get('errors');
805
+
806
+ if (errors && fieldName in errors && !Ember.isEmpty(errors[fieldName])) {
807
+ parent.$().addClass('error');
808
+ this.$().html(errors[fieldName].join(', '));
809
+ } else {
810
+ parent.$().removeClass('error');
811
+ this.$().html('');
812
+ }
813
+ } else {
814
+ parent.$().removeClass('error');
815
+ this.$().html('');
816
+ }
817
+ }
818
+ }, 'parentView.context.isValid', 'parentView.label')
819
+ }),
820
+
821
+ helpView: Ember.View.extend({
822
+ tagName: 'div',
823
+ classNames: ['help-block'],
824
+ template: Ember.Handlebars.compile('{{view.content}}'),
825
+ contentBinding: 'parentView.help'
826
+ }),
827
+
828
+ didInsertElement: function() {
829
+ this.set('labelView.inputElementId', this.get('inputField.elementId'));
830
+ }
831
+ });
832
+
833
+ })();
834
+
835
+
836
+
837
+ (function() {
838
+ Bootstrap.Forms.Select = Bootstrap.Forms.Field.extend({
839
+ optionLabelPath: 'content',
840
+ optionValuePath: 'content',
841
+
842
+ inputField: Ember.Select.extend({
843
+ contentBinding: 'parentView.content',
844
+
845
+ optionLabelPathBinding: 'parentView.optionLabelPath',
846
+ optionValuePathBinding: 'parentView.optionValuePath',
847
+
848
+ valueBinding: 'parentView.value',
849
+ selectionBinding: 'parentView.selection',
850
+ promptBinding: 'parentView.prompt',
851
+ multipleBinding: 'parentView.multiple',
852
+ disabledBinding: 'parentView.disabled',
853
+ classNameBindings: ['parentView.inputClassNames'],
854
+ name: Ember.computed(function() {
855
+ return this.get('parentView.name') || this.get('parentView.label');
856
+ }).property('parentView.name', 'parentView.label')
857
+ })
858
+ });
859
+
860
+ })();
861
+
862
+
863
+
864
+ (function() {
865
+ var get = Ember.get;
866
+
867
+ Bootstrap.TextSupport = Ember.Mixin.create({
868
+ valueBinding: 'parentView.value',
869
+ placeholderBinding: 'parentView.placeholder',
870
+ disabledBinding: 'parentView.disabled',
871
+ maxlengthBinding: 'parentView.maxlength',
872
+ classNameBindings: 'parentView.inputClassNames',
873
+ attributeBindings: ['name'],
874
+ name: Ember.computed(function() {
875
+ return get(this, 'parentView.name') || get(this, 'parentView.label');
876
+ }).property('parentView.name', 'parentView.label').cacheable()
877
+ });
878
+
879
+ })();
880
+
881
+
882
+
883
+ (function() {
884
+ Bootstrap.Forms.TextArea = Bootstrap.Forms.Field.extend({
885
+
886
+ inputField: Ember.TextArea.extend(Bootstrap.TextSupport, {
887
+ rowsBinding: 'parentView.rows',
888
+ colsBinding: 'parentView.cols'
889
+ })
890
+ });
891
+
892
+ })();
893
+
894
+
895
+
896
+ (function() {
897
+ Bootstrap.Forms.TextField = Bootstrap.Forms.Field.extend({
898
+ type: 'text',
899
+
900
+ inputField: Ember.TextField.extend(Bootstrap.TextSupport, {
901
+ typeBinding: 'parentView.type',
902
+ sizeBinding: 'parentView.size'
903
+ })
904
+ });
905
+
906
+ })();
907
+
908
+
909
+
910
+ (function() {
911
+ Bootstrap.Forms.Checkbox = Bootstrap.Forms.Field.extend({
912
+
913
+ inputField: Ember.Checkbox.extend({
914
+ attributeBindings: ['name'],
915
+ checkedBinding: 'parentView.checked',
916
+ disabledBinding: 'parentView.disabled',
917
+ classNameBindings: ['parentView.inputClassNames'],
918
+ name: Ember.computed(function() {
919
+ return this.get('parentView.name') || this.get('parentView.label');
920
+ }).property('parentView.name', 'parentView.label')
921
+ })
922
+ });
923
+
924
+ })();
925
+
926
+
927
+
928
+ (function() {
929
+ Bootstrap.Forms.UneditableInput = Bootstrap.Forms.Field.extend({
930
+
931
+ inputField: Ember.View.extend({
932
+ tagName: 'span',
933
+ classNames: ['uneditable-input'],
934
+ attributeBindings: ['name'],
935
+ template: Ember.Handlebars.compile('{{view.value}}'),
936
+
937
+ valueBinding: 'parentView.value',
938
+ classNameBindings: ['parentView.inputClassNames'],
939
+ name: Ember.computed(function() {
940
+ return this.get('parentView.name') || this.get('parentView.label');
941
+ }).property('parentView.name', 'parentView.label')
942
+ })
943
+ });
944
+
945
+ })();
946
+
947
+
948
+
949
+ (function() {
950
+
951
+ })();
952
+
953
+
954
+ })();