rasputin 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,9 +11,9 @@ It provide direct requires for official sproutcore packages :
11
11
 
12
12
  And it also provides some unnoficial packages :
13
13
 
14
- * sproutcore-ajax (backport form sc 1.x API but using jQuery $.ajax)
15
14
  * sproutcore-jui (jQuery UI wrappers for sc 2.0)
16
- * sproutcore-throbber (jQuery UI throbber and it's wrapper for JUI)
15
+ * sproutcore-ajax (backport form sc 1.x API but using jQuery $.ajax)
16
+ * sproutcore-i18n (integration with i18n-js gem)
17
17
 
18
18
  Rasputin also provide sprockets engine for handlebars templates. Any template in your
19
19
  javascript assets folder with extention handlebars will be availabel in sproutcore.
@@ -22,3 +22,9 @@ Examples :
22
22
 
23
23
  todos/templates/item.handlebars >> SC.TEMPLATES['todos_item']
24
24
  todos/ui/templates/stats.handlebars >> SC.TEMPLATES['todos_ui_stats']
25
+
26
+ Changelog :
27
+
28
+ 0.6.0 :
29
+ - update to lates sproutcore 2 (beta3)
30
+ - lots of fixes for sproutcore-jui
@@ -1,3 +1,3 @@
1
1
  module Rasputin
2
- VERSION = "0.5.4"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -1,7 +1,5 @@
1
1
 
2
- (function(exports) {
3
-
4
- if ('I18n' in window) {
2
+ (function() {
5
3
 
6
4
  SC.I18n = I18n;
7
5
 
@@ -16,25 +14,9 @@ Handlebars.registerHelper('loc', function(property) {
16
14
  });
17
15
 
18
16
  if (SC.EXTEND_PROTOTYPES) {
19
-
20
- String.prototype.loc = function(options) {
21
- return SC.String.loc(this, options);
22
- };
23
-
24
- }
25
-
17
+ String.prototype.loc = function(options) {
18
+ return SC.String.loc(String(this), options);
19
+ };
26
20
  }
27
21
 
28
- })({});
29
-
30
-
31
- (function(exports) {
32
- // ==========================================================================
33
- // Project: SproutCore I18N
34
- // Copyright: ©2011 Paul Chavard
35
- // License: Licensed under MIT license (see license.js)
36
- // ==========================================================================
37
-
38
- if ('undefined' === typeof I18n) require('i18n');
39
-
40
- })({});
22
+ })();
@@ -1,4 +1,20 @@
1
1
 
2
+ (function(exports) {
3
+ /*
4
+ * jQuery UI Autocomplete SC Extension
5
+ */
6
+
7
+ $.widget('ui.sc_autocomplete', $.ui.autocomplete, {
8
+ _renderItem: function(ul, item) {
9
+ var view = this.options.itemViewClass.create({content:item, widget: this});
10
+ view.appendTo(ul);
11
+ return view.$();
12
+ }
13
+ });
14
+
15
+ })({});
16
+
17
+
2
18
  (function(exports) {
3
19
  if ('undefined' === typeof JUI) {
4
20
 
@@ -22,7 +38,7 @@ if ('undefined' !== typeof window) {
22
38
  @default '1.0.alpha'
23
39
  @constant
24
40
  */
25
- JUI.VERSION = '1.0.alpha';
41
+ JUI.VERSION = '1.0.beta.1.pre';
26
42
 
27
43
  })({});
28
44
 
@@ -49,8 +65,6 @@ JUI.Widget = SC.Mixin.create({
49
65
 
50
66
  var ui = get(this, 'uiWidget')(options, get(this, 'element'));
51
67
  set(this, 'ui', ui);
52
-
53
- this._defineMethods();
54
68
  },
55
69
 
56
70
  willDestroyElement: function() {
@@ -110,23 +124,122 @@ JUI.Widget = SC.Mixin.create({
110
124
  };
111
125
 
112
126
  this.addObserver(key, observer);
113
- this._observers = this._observers || {};
114
- this._observers[key] = observer;
127
+ //this._observers = this._observers || {};
128
+ //this._observers[key] = observer;
115
129
  }, this);
116
130
 
117
131
  return options;
118
- },
132
+ }
133
+ });
119
134
 
120
- _defineMethods: function() {
121
- var uiMethods = get(this, 'uiMethods'),
122
- methods = {};
123
- uiMethods.forEach(function(methodName) {
124
- methods[methodName] = function() {
125
- var ui = get(this, 'ui');
126
- return ui[methodName].apply(ui, arguments);
127
- };
135
+ })({});
136
+
137
+
138
+ (function(exports) {
139
+
140
+ var get = SC.get;
141
+
142
+ /**
143
+ @mixin
144
+ @since SproutCore JUI 1.0
145
+ @extends JUI.TargetSupport
146
+ */
147
+ JUI.TargetSupport = SC.Mixin.create({
148
+
149
+ // @private
150
+ targetObject: function() {
151
+ var target = get(this, 'target');
152
+
153
+ if (SC.typeOf(target) === 'string') {
154
+ return SC.getPath(this, target);
155
+ } else {
156
+ return target;
157
+ }
158
+ }.property('target').cacheable(),
159
+
160
+ // @private
161
+ executeAction: function() {
162
+ var args = SC.$.makeArray(arguments),
163
+ action = args.shift(),
164
+ target = get(this, 'targetObject');
165
+ if (target && action) {
166
+ if (SC.typeOf(action) === 'string') {
167
+ action = target[action];
168
+ }
169
+ action.apply(target, args);
170
+ }
171
+ }
172
+
173
+ });
174
+
175
+ })({});
176
+
177
+
178
+ (function(exports) {
179
+
180
+
181
+
182
+ var get = SC.get;
183
+
184
+ /**
185
+ @class
186
+ @since SproutCore JUI 1.0
187
+ @extends JUI.AutocompleteItem
188
+ */
189
+ JUI.AutocompleteItem = SC.View.extend({
190
+ tagName: 'li',
191
+ defaultTemplate: SC.Handlebars.compile('<a>{{content.label}}</a>'),
192
+ didInsertElement: function() {
193
+ this._super();
194
+ this.$().data('item.autocomplete', {
195
+ value: this.getPath('content.value'),
196
+ label: this.getPath('content.label')
128
197
  });
129
- this.reopen(methods);
198
+ this.get('widget').menu.refresh();
199
+ }
200
+ });
201
+
202
+ /**
203
+ @class
204
+ @since SproutCore JUI 1.0
205
+ @extends JUI.AutocompleteTextField
206
+ */
207
+ JUI.AutocompleteTextField = SC.TextField.extend(JUI.Widget, JUI.TargetSupport, {
208
+ uiType: 'sc_autocomplete',
209
+ uiOptions: ['_source', 'delay', 'autoFocus', 'position', 'minLength', 'itemViewClass'],
210
+ uiEvents: ['select', 'focus', 'open', 'close'],
211
+
212
+ itemViewClass: JUI.AutocompleteItem,
213
+ requestContent: SC.K,
214
+ content: [],
215
+
216
+ _source: function() {
217
+ var source = this.get('source');
218
+ if (source) {
219
+ this.set('content', source);
220
+ return source;
221
+ } else {
222
+ return $.proxy(this, '_requestContent');
223
+ }
224
+ }.property('source').cacheable(),
225
+
226
+ _requestContent: function (data, callback) {
227
+ this._lastCallback = callback;
228
+ this.requestContent(data);
229
+ },
230
+
231
+ _contentDidChange: function() {
232
+ if (this._lastCallback) {
233
+ this._lastCallback(this.get('content'));
234
+ this._lastCallback = null;
235
+ }
236
+ }.observes('content'),
237
+
238
+ select: function(event, ui) {
239
+ if (ui.item) {
240
+ this.executeAction(get(this, 'action'), ui.item.value);
241
+ event.preventDefault();
242
+ }
130
243
  }
131
244
  });
132
245
 
@@ -135,6 +248,8 @@ JUI.Widget = SC.Mixin.create({
135
248
 
136
249
  (function(exports) {
137
250
 
251
+ var get = SC.get;
252
+
138
253
  /**
139
254
  @class
140
255
  @since SproutCore JUI 1.0
@@ -142,9 +257,18 @@ JUI.Widget = SC.Mixin.create({
142
257
  */
143
258
  JUI.Button = SC.Button.extend(JUI.Widget, {
144
259
  uiType: 'button',
145
- uiOptions: ['label'],
260
+ uiOptions: ['label', '_icons'],
261
+
262
+ isActiveBinding: SC.Binding.oneWay('.disabled'),
146
263
 
147
- isActiveBinding: SC.Binding.oneWay('.disabled')
264
+ _icons: function() {
265
+ var icons = {};
266
+ icons.primary = get(this, 'icon');
267
+ if (icons.primary) {
268
+ icons.primary = 'ui-icon-'.fmt(icons.primary);
269
+ }
270
+ return icons;
271
+ }.property('icon').cacheable()
148
272
  });
149
273
 
150
274
  })({});
@@ -271,50 +395,18 @@ jQuery(window).resize(function() {
271
395
 
272
396
  (function(exports) {
273
397
 
274
- var get = SC.get;
275
398
 
276
- /**
277
- @mixin
278
- @since SproutCore JUI 1.0
279
- @extends JUI.TargetSupport
280
- */
281
- JUI.TargetSupport = SC.Mixin.create({
282
399
 
283
- // @private
284
- targetObject: function() {
285
- var target = get(this, 'target');
286
-
287
- if (SC.typeOf(target) === 'string') {
288
- return SC.getPath(this, target);
289
- } else {
290
- return target;
291
- }
292
- }.property('target').cacheable(),
400
+ var get = SC.get, set = SC.set;
293
401
 
294
- // @private
402
+ JUI.DialogButton = SC.Object.extend(JUI.TargetSupport, {
403
+ label: 'OK',
404
+ action: 'close',
295
405
  executeAction: function() {
296
- var args = SC.$.makeArray(arguments),
297
- action = args.shift(),
298
- target = get(this, 'targetObject');
299
- if (target && action) {
300
- if (SC.typeOf(action) === 'string') {
301
- action = target[action];
302
- }
303
- action.apply(target, args);
304
- }
406
+ this._super(get(this, 'action'));
305
407
  }
306
-
307
408
  });
308
409
 
309
- })({});
310
-
311
-
312
- (function(exports) {
313
-
314
-
315
-
316
- var get = SC.get, set = SC.set;
317
-
318
410
  /**
319
411
  @class
320
412
  @since SproutCore JUI 1.0
@@ -326,56 +418,50 @@ JUI.Dialog = SC.View.extend(JUI.Widget, JUI.TargetSupport, {
326
418
  uiOptions: ['title', '_buttons', 'position', 'closeOnEscape',
327
419
  'modal', 'draggable', 'resizable', 'autoReposition',
328
420
  'width', 'height', 'maxWidth', 'maxHeight', 'minWidth', 'minHeight'],
329
- uiMethods: ['open', 'close'],
330
421
 
331
422
  isOpen: false,
332
-
333
423
  message: '',
334
- icon: null,
335
424
  buttons: [],
336
425
 
337
- _iconClassNames: function() {
338
- var icon = get(this, 'icon');
339
- if (icon) {
340
- return "ui-icon ui-icon-%@".fmt(icon === 'error' ? 'alert' : icon);
341
- }
342
- return '';
343
- }.property('icon').cacheable(),
344
-
345
- _stateClassNames: function() {
346
- var icon = get(this, 'icon');
347
- if (icon === 'error') {
348
- return 'ui-state-error';
349
- } else if (icon === 'info') {
350
- return 'ui-state-highlight';
426
+ defaultTemplate: SC.Handlebars.compile('<p>{{message}}</p>'),
427
+
428
+ open: function() {
429
+ if (get(this, 'state') !== 'inDOM') {
430
+ this._insertElementLater(SC.K);
431
+ } else {
432
+ get(this, 'ui').open();
351
433
  }
352
- return '';
353
- }.property('icon').cacheable(),
434
+ },
354
435
 
355
- defaultTemplate: SC.Handlebars.compile('<p {{bindAttr class="_stateClassNames"}}>\
356
- <span {{bindAttr class="_iconClassNames"}}></span>{{message}}</p>'),
436
+ close: function() {
437
+ get(this, 'ui').close();
438
+ },
439
+
440
+ didInsertElement: function() {
441
+ this._super();
442
+ get(this, 'ui')._bind({
443
+ dialogopen: $.proxy(this._open, this),
444
+ dialogclose: $.proxy(this._close, this)
445
+ });
446
+ },
357
447
 
358
448
  _buttons: function() {
359
- var buttons = [],
360
- target = get(this, 'targetObject');
361
- get(this, 'buttons').forEach(function(button) {
362
- var action = button.action,
363
- context = this;
364
- if (!this[action] && target) {
365
- context = target;
366
- }
367
- buttons.push({
368
- text: button.label,
369
- click: function(event) {
370
- if (context && context[action]) {
371
- context[action].call(context, event);
372
- }
373
- }
374
- });
375
- }, this);
376
- return buttons;
449
+ return get(this, 'buttons').map(this._buildButton, this);
377
450
  }.property('buttons').cacheable(),
378
451
 
452
+ _buildButton: function(buttonPath) {
453
+ var button = this.getPath(buttonPath);
454
+ if (!button.isInstance) {
455
+ button = button.create({
456
+ target: get(this, 'targetObject') || this
457
+ });
458
+ set(this, buttonPath, button);
459
+ }
460
+ var props = {text: get(button, 'label')};
461
+ props.click = $.proxy(button, 'executeAction')
462
+ return props;
463
+ },
464
+
379
465
  _open: function() {
380
466
  set(this, 'isOpen', true);
381
467
  this.didOpenDialog();
@@ -386,20 +472,6 @@ JUI.Dialog = SC.View.extend(JUI.Widget, JUI.TargetSupport, {
386
472
  this.didCloseDialog();
387
473
  },
388
474
 
389
- open: function() {
390
- this._insertElementLater(SC.K);
391
- this._open();
392
- },
393
-
394
- didInsertElement: function() {
395
- this._super();
396
- get(this, 'ui')._bind({
397
- dialogopen: $.proxy(this._open, this),
398
- dialogclose: $.proxy(this._close, this)
399
- });
400
- },
401
-
402
- close: SC.K,
403
475
  didOpenDialog: SC.K,
404
476
  didCloseDialog: SC.K
405
477
  });
@@ -408,40 +480,36 @@ JUI.Dialog.close = function() {
408
480
  $('.ui-dialog-content:visible').dialog('close');
409
481
  };
410
482
 
411
- var alertDialog, confirmDialog;
412
-
413
- JUI.AlertDialog = JUI.Dialog.extend({
414
- buttons: [{label: 'OK', action: 'close'}],
483
+ JUI.ModalDialog = JUI.Dialog.extend({
484
+ buttons: ['ok'],
485
+ ok: JUI.DialogButton,
415
486
  resizable: false,
416
487
  draggable: false,
417
488
  modal: true
418
489
  });
419
490
 
420
- JUI.AlertDialog.reopenClass({
491
+ JUI.AlertDialog = JUI.ModalDialog.create({
421
492
  open: function(message, title, type) {
422
- if (!alertDialog) {
423
- alertDialog = JUI.AlertDialog.create();
424
- }
425
- set(alertDialog, 'title', title ? title : null);
426
- set(alertDialog, 'message', message);
427
- set(alertDialog, 'icon', type);
428
- alertDialog.open();
493
+ set(this, 'title', title);
494
+ set(this, 'message', message);
495
+ set(this, 'icon', type);
496
+ this._super();
429
497
  },
430
-
431
498
  info: function(message, title) {
432
- JUI.AlertDialog.open(message, title, 'info');
499
+ this.open(message, title, 'info');
433
500
  },
434
-
435
501
  error: function(message, title) {
436
- JUI.AlertDialog.open(message, title, 'error');
502
+ this.open(message, title, 'error');
437
503
  }
438
504
  });
439
505
 
440
- JUI.ConfirmDialog = JUI.AlertDialog.extend({
441
- buttons: [
442
- {label: 'YES', action: 'didConfirm'},
443
- {label: 'NO', action: 'close'}
444
- ],
506
+ JUI.ConfirmDialog = JUI.ModalDialog.create({
507
+ buttons: ['yes', 'no'],
508
+ yes: JUI.DialogButton.extend({
509
+ label: 'YES',
510
+ action: 'didConfirm'
511
+ }),
512
+ no: JUI.DialogButton.extend({label: 'NO'}),
445
513
  didConfirm: function() {
446
514
  get(this, 'answer').resolve();
447
515
  this.close();
@@ -452,19 +520,13 @@ JUI.ConfirmDialog = JUI.AlertDialog.extend({
452
520
  answer.reject();
453
521
  }
454
522
  set(this, 'answer', null);
455
- }
456
- });
457
-
458
- JUI.ConfirmDialog.reopenClass({
523
+ },
459
524
  open: function(message, title) {
460
- if (!confirmDialog) {
461
- confirmDialog = JUI.ConfirmDialog.create();
462
- }
463
525
  var answer = SC.$.Deferred();
464
- set(confirmDialog, 'answer', answer);
465
- set(confirmDialog, 'title', title ? title : null);
466
- set(confirmDialog, 'message', message);
467
- confirmDialog.open();
526
+ set(this, 'answer', answer);
527
+ set(this, 'title', title);
528
+ set(this, 'message', message);
529
+ this._super();
468
530
  return answer.promise();
469
531
  }
470
532
  });
@@ -636,57 +698,247 @@ JUI.ResizableView = SC.View.extend(JUI.Widget, {
636
698
 
637
699
 
638
700
  (function(exports) {
701
+ /*!
702
+ * jQuery UI Throbber
703
+ *
704
+ * Copyright (c) 2011 Paul Chavard
705
+ * Licensed under the MIT license
706
+ *
707
+ * Author: Paul Chavard [paul at chavard dot net]
708
+ * Version: 0.5.0
709
+ *
710
+ * Credits: Felix Gnass [fgnass at neteye dot de]
711
+ *
712
+ */
639
713
 
714
+ (function($, undefined) {
715
+
716
+ $.widget('ui.throbber', {
717
+ options: {
718
+ segments: 12,
719
+ space: 3,
720
+ length: 7,
721
+ width: 4,
722
+ speed: 1.2,
723
+ align: 'center',
724
+ valign: 'center',
725
+ padding: 4,
726
+ autoStart: false,
727
+ outside: true
728
+ },
640
729
 
730
+ _create: function() {
731
+ this.options = $.extend({color: this.element.css('color')}, this.options);
732
+ this._prepare();
733
+ if (this.options.autoStart) {
734
+ this._activate();
735
+ }
736
+ },
641
737
 
738
+ _setOption: function(key, value) {
739
+ this.options[key] = value;
642
740
 
741
+ if (key === 'disabled') {
742
+ if (this.throbber) {
743
+ clearInterval(this.interval);
744
+ this.throbber.remove();
745
+ }
746
+ if (value === false) {
747
+ this._activate();
748
+ }
749
+ }
643
750
 
751
+ return this;
752
+ },
644
753
 
754
+ _activate: function() {
755
+ var options = this.options;
756
+ this.throbber = this._render().css('position', 'absolute').prependTo(options.outside ? 'body' : this.element);
757
+ var h = this.element.outerHeight() - this.throbber.height();
758
+ var w = this.element.outerWidth() - this.throbber.width();
759
+ var margin = {
760
+ top: options.valign == 'top' ? options.padding : options.valign == 'bottom' ? h - options.padding : Math.floor(h / 2),
761
+ left: options.align == 'left' ? options.padding : options.align == 'right' ? w - options.padding : Math.floor(w / 2)
762
+ };
763
+ var offset = this.element.offset();
764
+ if (options.outside) {
765
+ this.throbber.css({top: offset.top + 'px', left: offset.left + 'px'});
766
+ } else {
767
+ margin.top -= this.throbber.offset().top - offset.top;
768
+ margin.left -= this.throbber.offset().left - offset.left;
769
+ }
770
+ this.throbber.css({marginTop: margin.top + 'px', marginLeft: margin.left + 'px'});
771
+ this._animate(options.segments, Math.round(10 / options.speed) / 10);
772
+ },
645
773
 
774
+ _prepare: function() {
775
+ if ($.ui.throbber.renderMethod) {
776
+ this.renderMethod = $.ui.throbber.renderMethod;
777
+ this.animateMethod = $.ui.throbber.animateMethod;
778
+ return;
779
+ }
780
+ if (document.createElementNS && document.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) {
781
+ $.ui.throbber.renderMethod = 'SVG';
782
+ if (document.createElement('div').style.WebkitAnimationName !== undefined) {
783
+ $.ui.throbber.animateMethod = 'CSS';
784
+ } else {
785
+ $.ui.throbber.animateMethod = 'SVG';
786
+ }
787
+ } else if (this._prepareVML()) {
788
+ $.ui.throbber.renderMethod = $.ui.throbber.animateMethod = 'VML';
789
+ } else {
790
+ $.ui.throbber.renderMethod = $.ui.throbber.animateMethod = 'DOM';
791
+ }
792
+ this.renderMethod = $.ui.throbber.renderMethod;
793
+ this.animateMethod = $.ui.throbber.animateMethod;
794
+ },
646
795
 
796
+ _prepareVML: function() {
797
+ var s = $('<shape>').css('behavior', 'url(#default#VML)');
798
+ var ok = false;
799
+ $('body').append(s);
800
+ if (s.get(0).adj) {
801
+ // VML support detected. Insert CSS rules for group, shape and stroke.
802
+ var sheet = document.createStyleSheet();
803
+ $.each(['group', 'shape', 'stroke'], function() {
804
+ sheet.addRule(this, "behavior:url(#default#VML);");
805
+ });
806
+ ok = true;
807
+ }
808
+ $(s).remove();
809
+ return ok;
810
+ },
647
811
 
812
+ _getOpacity: function(i) {
813
+ var steps = this.options.steps || this.options.segments-1;
814
+ var end = this.options.opacity !== undefined ? this.options.opacity : 1/steps;
815
+ return 1 - Math.min(i, steps) * (1 - end) / steps;
816
+ },
648
817
 
649
- })({});
818
+ _render: function() {
819
+ return this['_render'+this.renderMethod]();
820
+ },
650
821
 
822
+ _renderDOM: function() {
823
+ return $('<div>').addClass('ui-throbber');
824
+ },
651
825
 
652
- (function(exports) {
653
- /*
654
- * jQuery UI Autocomplete HTML Extension
655
- *
656
- * Copyright 2010, Scott González (http://scottgonzalez.com)
657
- * Dual licensed under the MIT or GPL Version 2 licenses.
658
- *
659
- * http://github.com/scottgonzalez/jquery-ui-extensions
660
- */
826
+ _renderSVG: function() {
827
+ var o = this.options;
828
+ var innerRadius = o.width*2 + o.space;
829
+ var r = (innerRadius + o.length + Math.ceil(o.width / 2) + 1);
830
+
831
+ var el = svg().width(r*2).height(r*2);
832
+
833
+ var g = svg('g', {
834
+ 'stroke-width': o.width,
835
+ 'stroke-linecap': 'round',
836
+ stroke: o.color
837
+ }).appendTo(svg('g', {transform: 'translate('+ r +','+ r +')'}).appendTo(el));
838
+
839
+ for (var i = 0; i < o.segments; i++) {
840
+ g.append(svg('line', {
841
+ x1: 0,
842
+ y1: innerRadius,
843
+ x2: 0,
844
+ y2: innerRadius + o.length,
845
+ transform: 'rotate(' + (360 / o.segments * i) + ', 0, 0)',
846
+ opacity: this._getOpacity(i)
847
+ }));
848
+ }
849
+ return $('<div>').append(el).width(2*r).height(2*r);
850
+ },
661
851
 
662
- var proto = jQuery.ui.autocomplete.prototype,
663
- initSource = proto._initSource,
664
- escapeRegex = jQuery.ui.autocomplete.escapeRegex;
852
+ _renderVML: function() {
853
+ var o = this.options;
854
+ var innerRadius = o.width*2 + o.space;
855
+ var r = (innerRadius + o.length + Math.ceil(o.width / 2) + 1);
856
+ var s = r*2;
857
+ var c = -Math.ceil(s/2);
858
+
859
+ var el = $('<group>', {coordsize: s + ' ' + s, coordorigin: c + ' ' + c}).css({top: c, left: c, width: s, height: s});
860
+ for (var i = 0; i < o.segments; i++) {
861
+ el.append($('<shape>', {path: 'm ' + innerRadius + ',0 l ' + (innerRadius + o.length) + ',0'}).css({
862
+ width: s,
863
+ height: s,
864
+ rotation: (360 / o.segments * i) + 'deg'
865
+ }).append($('<stroke>', {color: o.color, weight: o.width + 'px', endcap: 'round', opacity: this._getOpacity(i)})));
866
+ }
867
+ return $('<group>', {coordsize: s + ' ' + s}).css({width: s, height: s, overflow: 'hidden'}).append(el);
868
+ },
665
869
 
666
- function filter(array, term) {
667
- var matcher = new RegExp(escapeRegex(term), 'i');
668
- return jQuery.grep(array, function(value) {
669
- return matcher.test(jQuery('<div>').html(value.label || value.value || value).text());
670
- });
671
- }
870
+ _animate: function(steps, duration) {
871
+ this['_animate'+this.animateMethod](steps, duration);
872
+ },
672
873
 
673
- jQuery.extend(proto, {
674
- _initSource: function() {
675
- if (this.options.html && jQuery.isArray(this.options.source)) {
676
- this.source = function(request, response) {
677
- response(filter( this.options.source, request.term));
678
- };
679
- } else {
680
- initSource.call(this);
874
+ _animateCSS: function(steps, duration) {
875
+ if (!animations[steps]) {
876
+ var name = 'spin' + steps;
877
+ var rule = '@-webkit-keyframes '+ name +' {';
878
+ for (var i=0; i < steps; i++) {
879
+ var p1 = Math.round(100000 / steps * i) / 1000;
880
+ var p2 = Math.round(100000 / steps * (i+1) - 1) / 1000;
881
+ var value = '% { -webkit-transform:rotate(' + Math.round(360 / steps * i) + 'deg); }\n';
882
+ rule += p1 + value + p2 + value;
883
+ }
884
+ rule += '100% { -webkit-transform:rotate(100deg); }\n}';
885
+ document.styleSheets[0].insertRule(rule);
886
+ animations[steps] = name;
681
887
  }
888
+ this.throbber.css('-webkit-animation', animations[steps] + ' ' + duration +'s linear infinite');
682
889
  },
683
890
 
684
- _renderItem: function(ul, item) {
685
- return jQuery('<li></li>')
686
- .data('item.autocomplete', item)
687
- .append(jQuery('<a></a>')[this.options.html ? 'html' : 'text'](item.label))
688
- .appendTo(ul);
891
+ _animateSVG: function(steps, duration) {
892
+ var rotation = 0;
893
+ var g = this.throbber.find('g g').get(0);
894
+ this.interval = setInterval(function() {
895
+ g.setAttributeNS(null, 'transform', 'rotate(' + (++rotation % steps * (360 / steps)) + ')');
896
+ }, duration * 1000 / steps);
897
+ },
898
+
899
+ _animateVML: function(steps, duration) {
900
+ var rotation = 0;
901
+ var g = this.throbber.get(0);
902
+ this.interval = setInterval(function() {
903
+ g.style.rotation = ++rotation % steps * (360 / steps);
904
+ }, duration * 1000 / steps);
905
+ },
906
+
907
+ _animateDOM: function(steps, duration) {}
908
+
909
+ });
910
+
911
+ /**
912
+ * Utility function to create elements in the SVG namespace.
913
+ */
914
+ function svg(tag, attr) {
915
+ var el = document.createElementNS("http://www.w3.org/2000/svg", tag || 'svg');
916
+ if (attr) {
917
+ $.each(attr, function(k, v) {
918
+ el.setAttributeNS(null, k, v);
919
+ });
689
920
  }
921
+ return $(el);
922
+ }
923
+
924
+ var animations = {};
925
+
926
+ })(jQuery);
927
+
928
+ })({});
929
+
930
+
931
+ (function(exports) {
932
+
933
+
934
+ /*
935
+ * JUI.Throbber
936
+ */
937
+
938
+ JUI.Throbber = SC.View.extend(JUI.Widget, {
939
+ uiType: 'throbber',
940
+ uiOptions: ['segments', 'space', 'length', 'width',
941
+ 'speed', 'align', 'valign', 'padding', 'autoStart', 'outside']
690
942
  });
691
943
 
692
944
  })({});
@@ -696,26 +948,14 @@ jQuery.extend(proto, {
696
948
 
697
949
 
698
950
 
699
- var get = SC.get;
700
951
 
701
- /**
702
- @class
703
- @since SproutCore JUI 1.0
704
- @extends JUI.AutocompleteTextField
705
- */
706
- JUI.AutocompleteTextField = SC.TextField.extend(JUI.Widget, JUI.TargetSupport, {
707
- uiType: 'autocomplete',
708
- uiOptions: ['source', 'delay', 'position', 'minLength', 'html'],
709
- uiEvents: ['select', 'focus', 'open', 'close'],
710
952
 
711
- select: function(event, ui) {
712
- if (ui.item) {
713
- this.executeAction(get(this, 'action'), ui.item.value);
714
- event.target.value = '';
715
- event.preventDefault();
716
- }
717
- }
718
- });
953
+
954
+
955
+
956
+
957
+
958
+
719
959
 
720
960
  })({});
721
961
 
@@ -727,6 +967,7 @@ JUI.AutocompleteTextField = SC.TextField.extend(JUI.Widget, JUI.TargetSupport, {
727
967
  // License: Licensed under MIT license (see license.js)
728
968
  // ==========================================================================
729
969
 
970
+ //require('jquery-ui');
730
971
 
731
972
 
732
973
  })({});
@@ -1,7 +1,9 @@
1
1
 
2
2
  (function(exports) {
3
3
  // lib/handlebars/base.js
4
- Handlebars = {};
4
+ var Handlebars = {};
5
+
6
+ window.Handlebars = Handlebars;
5
7
 
6
8
  Handlebars.VERSION = "1.0.beta.2";
7
9
 
@@ -1573,7 +1575,7 @@ if ('undefined' === typeof SC) {
1573
1575
  /**
1574
1576
  @namespace
1575
1577
  @name SC
1576
- @version 2.0.alpha
1578
+ @version 2.0.beta.3
1577
1579
 
1578
1580
  All SproutCore methods and functions are defined inside of this namespace.
1579
1581
  You generally should not add new properties to this namespace as it may be
@@ -1602,10 +1604,10 @@ if ('undefined' !== typeof window) {
1602
1604
  /**
1603
1605
  @static
1604
1606
  @type String
1605
- @default '2.0.alpha'
1607
+ @default '2.0.beta.3'
1606
1608
  @constant
1607
1609
  */
1608
- SC.VERSION = '2.0.alpha';
1610
+ SC.VERSION = '2.0.beta.3';
1609
1611
 
1610
1612
  /**
1611
1613
  @static
@@ -2645,7 +2647,7 @@ Dp.set = function(obj, keyName, value) {
2645
2647
  @returns {Object} the current value
2646
2648
  */
2647
2649
  Dp.get = function(obj, keyName) {
2648
- return obj[keyName];
2650
+ return w_get(obj, keyName, obj);
2649
2651
  };
2650
2652
 
2651
2653
  /**
@@ -2722,11 +2724,12 @@ var WATCHED_DESC = {
2722
2724
  set: SC.Descriptor.MUST_USE_SETTER
2723
2725
  };
2724
2726
 
2725
- function w_get(obj, keyName) {
2726
- var m = meta(obj, false), values = m.values;
2727
+ function w_get(obj, keyName, values) {
2728
+ values = values || meta(obj, false).values;
2727
2729
 
2728
2730
  if (values) {
2729
- if (keyName in values) { return values[keyName]; }
2731
+ var ret = values[keyName];
2732
+ if (ret !== undefined) { return ret; }
2730
2733
  if (obj.unknownProperty) { return obj.unknownProperty(keyName); }
2731
2734
  }
2732
2735
 
@@ -2814,7 +2817,7 @@ if (SC.platform.hasPropertyAccessors) {
2814
2817
  };
2815
2818
 
2816
2819
  }
2817
-
2820
+
2818
2821
  /**
2819
2822
  The default descriptor for simple properties. Pass as the third argument
2820
2823
  to SC.defineProperty() along with a value to set a simple value.
@@ -4778,7 +4781,7 @@ SC.Enumerable = SC.Mixin.create( /** @lends SC.Enumerable */ {
4778
4781
  to nextObject for the current iteration. This is a useful way to
4779
4782
  manage iteration if you are tracing a linked list, for example.
4780
4783
 
4781
- Finally the context paramter will always contain a hash you can use as
4784
+ Finally the context parameter will always contain a hash you can use as
4782
4785
  a "scratchpad" to maintain any other state you need in order to iterate
4783
4786
  properly. The context object is reused and is not reset between
4784
4787
  iterations so make sure you setup the context with a fresh state whenever
@@ -8857,7 +8860,10 @@ function getTransformedValue(binding, val, obj, dir) {
8857
8860
  len = transforms ? transforms.length : 0,
8858
8861
  idx;
8859
8862
 
8860
- for(idx=0;idx<len;idx++) { val = transforms[idx][dir].call(this, val, obj); }
8863
+ for(idx=0;idx<len;idx++) {
8864
+ var transform = transforms[idx][dir];
8865
+ if (transform) { val = transform.call(this, val, obj); }
8866
+ }
8861
8867
  return val;
8862
8868
  }
8863
8869
 
@@ -8871,6 +8877,11 @@ function getTransformedFromValue(obj, binding) {
8871
8877
  return getTransformedValue(binding, fromValue, obj, 'to');
8872
8878
  }
8873
8879
 
8880
+ function getTransformedToValue(obj, binding) {
8881
+ var toValue = getPath(obj, binding._to);
8882
+ return getTransformedValue(binding, toValue, obj, 'from');
8883
+ }
8884
+
8874
8885
  var AND_OPERATION = function(obj, left, right) {
8875
8886
  return getPath(obj, left) && getPath(obj, right);
8876
8887
  };
@@ -9134,7 +9145,9 @@ var Binding = SC.Object.extend({
9134
9145
  @returns {SC.Binding} this
9135
9146
  */
9136
9147
  transform: function(transform) {
9137
- sc_assert("Binding transforms must be a hash with a `to` and optional `from` property", transform && transform.to);
9148
+ if ('function' === typeof transform) {
9149
+ transform = { to: transform };
9150
+ }
9138
9151
 
9139
9152
  if (!this._transforms) this._transforms = [];
9140
9153
  this._transforms.push(transform);
@@ -9386,7 +9399,7 @@ var Binding = SC.Object.extend({
9386
9399
 
9387
9400
  // apply any operations to the object, then apply transforms
9388
9401
  var fromValue = getTransformedFromValue(obj, this);
9389
- var toValue = getPath(obj, toPath);
9402
+ var toValue = getTransformedToValue(obj, this);
9390
9403
 
9391
9404
  if (toValue === fromValue) { return; }
9392
9405
 
@@ -10923,18 +10936,18 @@ SC.View = SC.Object.extend(
10923
10936
  // Loop through all of the configured bindings. These will be either
10924
10937
  // property names ('isUrgent') or property paths relative to the view
10925
10938
  // ('content.isUrgent')
10926
- classBindings.forEach(function(property) {
10939
+ classBindings.forEach(function(binding) {
10927
10940
 
10928
10941
  // Variable in which the old class value is saved. The observer function
10929
10942
  // closes over this variable, so it knows which string to remove when
10930
10943
  // the property changes.
10931
- var oldClass;
10944
+ var oldClass, property;
10932
10945
 
10933
10946
  // Set up an observer on the context. If the property changes, toggle the
10934
10947
  // class name.
10935
10948
  var observer = function() {
10936
10949
  // Get the current value of the property
10937
- newClass = this._classStringForProperty(property);
10950
+ newClass = this._classStringForProperty(binding);
10938
10951
  elem = this.$();
10939
10952
 
10940
10953
  // If we had previously added a class to the element, remove it.
@@ -10952,10 +10965,8 @@ SC.View = SC.Object.extend(
10952
10965
  }
10953
10966
  };
10954
10967
 
10955
- addObserver(this, property, observer);
10956
-
10957
10968
  // Get the class name for the property at its current value
10958
- dasherizedClass = this._classStringForProperty(property);
10969
+ dasherizedClass = this._classStringForProperty(binding);
10959
10970
 
10960
10971
  if (dasherizedClass) {
10961
10972
  // Ensure that it gets into the classNames array
@@ -10967,6 +10978,10 @@ SC.View = SC.Object.extend(
10967
10978
  // been closed over by the observer.
10968
10979
  oldClass = dasherizedClass;
10969
10980
  }
10981
+
10982
+ // Extract just the property name from bindings like 'foo:bar'
10983
+ property = binding.split(':')[0];
10984
+ addObserver(this, property, observer);
10970
10985
  }, this);
10971
10986
  },
10972
10987
 
@@ -11419,13 +11434,9 @@ SC.View = SC.Object.extend(
11419
11434
 
11420
11435
  viewMeta.lengthBeforeRender = getPath(this, 'childViews.length');
11421
11436
 
11422
- SC.beginPropertyChanges(this);
11423
-
11424
11437
  this.applyAttributesToBuffer(buffer);
11425
11438
  this.render(buffer);
11426
11439
 
11427
- SC.endPropertyChanges(this);
11428
-
11429
11440
  viewMeta.lengthAfterRender = getPath(this, 'childViews.length');
11430
11441
 
11431
11442
  return buffer;
@@ -11590,9 +11601,10 @@ SC.View = SC.Object.extend(
11590
11601
  var view;
11591
11602
 
11592
11603
  if ('string' === typeof viewName) {
11593
- view = this[viewName];
11604
+ view = get(this, viewName);
11594
11605
  view = this.createChildView(view);
11595
- childViews[idx] = this[viewName] = view;
11606
+ childViews[idx] = view;
11607
+ set(this, viewName, view);
11596
11608
  } else if (viewName.isClass) {
11597
11609
  view = this.createChildView(viewName);
11598
11610
  childViews[idx] = view;
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rasputin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.4
5
+ version: 0.6.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Chavard
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-09 00:00:00 Z
13
+ date: 2011-08-13 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties