canjs-rails 0.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ## 1.1.2 (28 November 2012)
2
+
3
+ - updated to use canjs v1.1.2
4
+ - updated version to stay be in sync with Can.JS
5
+
1
6
  ## 0.1.0 (26 June 2012)
2
7
 
3
8
  - initial release
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.email = ["craig@mindscratch.org"]
10
10
  s.homepage = "https://github.com/mindscratch/canjs-rails"
11
11
  s.summary = "Use CanJS with Rails 3.1+"
12
- s.description = "This gem provides CanJS for your Rails 3.1+ application."
12
+ s.description = "This gem provides CanJS (for jQuery) for your Rails 3.1+ application."
13
13
 
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "canjs-rails"
@@ -1,6 +1,6 @@
1
1
  module Canjs
2
2
  module Rails
3
- VERSION = "0.1.0"
4
- CANJS_VERSION = "1.0.7"
3
+ VERSION = "1.1.2"
4
+ CANJS_VERSION = "1.1.2"
5
5
  end
6
6
  end
@@ -1,9 +1,16 @@
1
- (function(can, window, undefined){
2
- var isFunction = can.isFunction,
3
- isArray = can.isArray,
4
- makeArray = can.makeArray,
5
-
6
- proxy = function( funcs ) {
1
+ /*
2
+ * CanJS - 1.1.2 (2012-11-28)
3
+ * http://canjs.us/
4
+ * Copyright (c) 2012 Bitovi
5
+ * Licensed MIT
6
+ */
7
+ (function (can, window, undefined) {
8
+ // ## can/construct/proxy/proxy.js
9
+ var isFunction = can.isFunction,
10
+ isArray = can.isArray,
11
+ makeArray = can.makeArray,
12
+
13
+ proxy = function (funcs) {
7
14
 
8
15
  //args that should be curried
9
16
  var args = makeArray(arguments),
@@ -13,48 +20,42 @@ proxy = function( funcs ) {
13
20
  funcs = args.shift();
14
21
 
15
22
  // if there is only one function, make funcs into an array
16
- if (!isArray(funcs) ) {
23
+ if (!isArray(funcs)) {
17
24
  funcs = [funcs];
18
25
  }
19
-
26
+
20
27
  // keep a reference to us in self
21
28
  self = this;
22
-
23
-
29
+
30
+
24
31
  return function class_cb() {
25
32
  // add the arguments after the curried args
26
33
  var cur = args.concat(makeArray(arguments)),
27
- isString,
28
- length = funcs.length,
34
+ isString, length = funcs.length,
29
35
  f = 0,
30
36
  func;
31
-
37
+
32
38
  // go through each function to call back
33
- for (; f < length; f++ ) {
39
+ for (; f < length; f++) {
34
40
  func = funcs[f];
35
- if (!func ) {
41
+ if (!func) {
36
42
  continue;
37
43
  }
38
-
44
+
39
45
  // set called with the name of the function on self (this is how this.view works)
40
46
  isString = typeof func == "string";
41
-
47
+
42
48
  // call the function
43
49
  cur = (isString ? self[func] : func).apply(self, cur || []);
44
-
50
+
45
51
  // pass the result to the next function (if there is a next function)
46
- if ( f < length - 1 ) {
52
+ if (f < length - 1) {
47
53
  cur = !isArray(cur) || cur._use_call ? [cur] : cur
48
54
  }
49
55
  }
50
56
  return cur;
51
57
  }
52
58
  }
53
- can.Construct.proxy = can.Construct.prototype.proxy = proxy;
54
-
55
-
56
-
57
-
58
-
59
+ can.Construct.proxy = can.Construct.prototype.proxy = proxy;
59
60
 
60
- })(this.can, this )
61
+ })(can, this);
@@ -1,44 +1,48 @@
1
- (function(can, window, undefined){
2
-
3
- // tests if we can get super in .toString()
1
+ /*
2
+ * CanJS - 1.1.2 (2012-11-28)
3
+ * http://canjs.us/
4
+ * Copyright (c) 2012 Bitovi
5
+ * Licensed MIT
6
+ */
7
+ (function (can, window, undefined) {
8
+ // ## can/construct/super/super.js
9
+ // tests if we can get super in .toString()
4
10
  var isFunction = can.isFunction,
5
-
6
- fnTest = /xyz/.test(function() {
11
+
12
+ fnTest = /xyz/.test(function () {
7
13
  xyz;
8
14
  }) ? /\b_super\b/ : /.*/;
9
-
10
- // overwrites a single property so it can still call super
11
- can.Construct._overwrite = function(addTo, base, name, val){
12
- // Check if we're overwriting an existing function
13
- addTo[name] = isFunction(val) &&
14
- isFunction(base[name]) &&
15
- fnTest.test(val) ? (function( name, fn ) {
16
- return function() {
17
- var tmp = this._super,
18
- ret;
19
15
 
20
- // Add a new ._super() method that is the same method
21
- // but on the super-class
22
- this._super = base[name];
16
+ // overwrites a single property so it can still call super
17
+ can.Construct._overwrite = function (addTo, base, name, val) {
18
+ // Check if we're overwriting an existing function
19
+ addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? (function (name, fn) {
20
+ return function () {
21
+ var tmp = this._super,
22
+ ret;
23
23
 
24
- // The method only need to be bound temporarily, so we
25
- // remove it when we're done executing
26
- ret = fn.apply(this, arguments);
27
- this._super = tmp;
28
- return ret;
29
- };
30
- })(name, val) : val;
31
- }
32
- // overwrites an object with methods, sets up _super
33
- // newProps - new properties
34
- // oldProps - where the old properties might be
35
- // addTo - what we are adding to
36
- can.Construct._inherit = function( newProps, oldProps, addTo ) {
37
- addTo = addTo || newProps
38
- for ( var name in newProps ) {
39
- can.Construct._overwrite(addTo, oldProps, name, newProps[name]);
40
- }
24
+ // Add a new ._super() method that is the same method
25
+ // but on the super-class
26
+ this._super = base[name];
27
+
28
+ // The method only need to be bound temporarily, so we
29
+ // remove it when we're done executing
30
+ ret = fn.apply(this, arguments);
31
+ this._super = tmp;
32
+ return ret;
33
+ };
34
+ })(name, val) : val;
35
+ }
36
+ // overwrites an object with methods, sets up _super
37
+ // newProps - new properties
38
+ // oldProps - where the old properties might be
39
+ // addTo - what we are adding to
40
+ can.Construct._inherit = function (newProps, oldProps, addTo) {
41
+ addTo = addTo || newProps
42
+ for (var name in newProps) {
43
+ can.Construct._overwrite(addTo, oldProps, name, newProps[name]);
41
44
  }
45
+ }
42
46
 
43
47
 
44
- })(this.can, this )
48
+ })(can, this);
@@ -1,245 +1,108 @@
1
- (function(can, window, undefined){
2
-
3
-
4
-
5
- //used to determine if a control instance is one of controllers
6
- //controllers can be strings or classes
7
- var i,
8
- isAControllerOf = function( instance, controllers ) {
9
- for ( i = 0; i < controllers.length; i++ ) {
10
- if ( typeof controllers[i] == 'string' ? instance.constructor._shortName == controllers[i] : instance instanceof controllers[i] ) {
1
+ /*
2
+ * CanJS - 1.1.2 (2012-11-28)
3
+ * http://canjs.us/
4
+ * Copyright (c) 2012 Bitovi
5
+ * Licensed MIT
6
+ */
7
+ (function (window, $, can, undefined) {
8
+ // ## can/control/plugin/plugin.js
9
+ //used to determine if a control instance is one of controllers
10
+ //controllers can be strings or classes
11
+ var i, isAControllerOf = function (instance, controllers) {
12
+ for (i = 0; i < controllers.length; i++) {
13
+ if (typeof controllers[i] == 'string' ? instance.constructor._shortName == controllers[i] : instance instanceof controllers[i]) {
11
14
  return true;
12
15
  }
13
16
  }
14
17
  return false;
15
18
  },
16
- data = function(el, data){
17
- return $el.data('controls');
18
- },
19
- makeArray = can.makeArray,
20
- old = can.Control.setup;
19
+ makeArray = can.makeArray,
20
+ old = can.Control.setup;
21
21
 
22
- /*
23
- * static
24
- */
25
- can.Control.setup = function() {
26
- // if you didn't provide a name, or are control, don't do anything
27
- if ( this !== can.Control ) {
28
-
29
- /**
30
- * @attribute can.Control.plugin.static.pluginName
31
- * @parent can.Control.plugin
32
- *
33
- * Setting the static `pluginName` property allows you to override the default name
34
- * with your own.
35
- *
36
- * var Filler = can.Control({
37
- * pluginName: 'fillWith'
38
- * },{});
39
- *
40
- * $("#foo").fillWith();
41
- *
42
- * If you don't provide a `pluginName`, the control falls back to the
43
- * [can.Construct.fullName fullName] attribute:
44
- *
45
- * can.Control('Ui.Layout.FillWith', {}, {});
46
- * $("#foo").ui_layout_fill_with();
47
- *
48
- */
49
- var pluginName = this.pluginName || this._fullName;
50
-
51
- // create jQuery plugin
52
- if(pluginName !== 'can_control'){
53
- this.plugin(pluginName);
54
- }
55
-
56
- old.apply(this, arguments);
57
- }
58
- };
22
+ can.Control.setup = function () {
23
+ // if you didn't provide a name, or are control, don't do anything
24
+ if (this !== can.Control) {
59
25
 
60
- /*
61
- * prototype
62
- */
63
- $.fn.extend({
64
-
65
- /**
66
- * @function jQuery.fn.controls
67
- * @parent can.Control.plugin
68
- *
69
- * When the widget is initialized, the plugin control creates an array
70
- * of control instance(s) with the DOM element it was initialized on using
71
- * [can.data] method.
72
- *
73
- * The `controls` method allows you to get the control instance(s) for any element.
74
- *
75
- * //- Inits the widgets
76
- * $('.widgets:eq(0)').my_box();
77
- * $('.widgets:eq(1)').my_clock();
78
- *
79
- * <div class="widgets my_box" />
80
- * <div class="widgets my_clock" />
81
- *
82
- * $('.widgets').controls() //-> [ MyBox, MyClock ]
83
- *
84
- * Additionally, you can invoke it passing the name of a control
85
- * to fetch a specific instance(s).
86
- *
87
- * //- Inits the widgets
88
- * $('.widgets:eq(0)').my_box();
89
- * $('.widgets:eq(1)').my_clock();
90
- *
91
- * <div class="widgets my_box" />
92
- * <div class="widgets my_clock" />
93
- *
94
- * $('.widgets').controls('MyBox') //-> [ MyBox ]
95
- *
96
- * @param {Object} control (optional) if exists the control instance(s) with that constructor function or type will be returned.
97
- * @return {Array} an array of control instance(s).
98
- */
99
- controls: function() {
100
- var controllerNames = makeArray(arguments),
101
- instances = [],
102
- controls, c, cname;
103
- //check if arguments
104
- this.each(function() {
105
-
106
- controls = can.$(this).data("controls");
107
- if(!controls){
108
- return;
26
+
27
+ var pluginName = this.pluginName || this._fullName;
28
+
29
+ // create jQuery plugin
30
+ if (pluginName !== 'can_control') {
31
+ this.plugin(pluginName);
109
32
  }
110
- for(var i=0; i<controls.length; i++){
111
- c = controls[i];
112
- if (!controllerNames.length || isAControllerOf(c, controllerNames) ) {
113
- instances.push(c);
33
+
34
+ old.apply(this, arguments);
35
+ }
36
+ };
37
+
38
+ $.fn.extend({
39
+
40
+
41
+ controls: function () {
42
+ var controllerNames = makeArray(arguments),
43
+ instances = [],
44
+ controls, c, cname;
45
+ //check if arguments
46
+ this.each(function () {
47
+
48
+ controls = can.$(this).data("controls");
49
+ if (!controls) {
50
+ return;
114
51
  }
115
- }
116
- });
117
- return instances;
118
- },
119
-
120
- /**
121
- * @function jQuery.fn.control
122
- * @parent can.Control.plugin
123
- *
124
- * The `control` does the same as [jQuery.fn.controls controls] execept it only
125
- * returns the first instance found.
126
- *
127
- * //- Init MyBox widget
128
- * $('.widgets').my_box();
129
- *
130
- * <div class="widgets my_box" />
131
- *
132
- * $('.widgets').controls() //-> MyBox
133
- *
134
- * @param {Object} control (optional) if exists the first control instance with that constructor function or type will be returned.
135
- * @return {can.Control} the first control.
136
- */
137
- control: function( control ) {
138
- return this.controls.apply(this, arguments)[0];
139
- }
140
- });
141
-
142
- can.Control.plugin = function(pluginname){
143
- var control = this;
144
-
145
- if (!$.fn[pluginname]) {
146
- $.fn[pluginname] = function(options){
147
-
148
- var args = makeArray(arguments), //if the arg is a method on this control
149
- isMethod = typeof options == "string" && $.isFunction(control.prototype[options]), meth = args[0];
150
- return this.each(function(){
151
- //check if created
152
- var plugin = can.$(this).control(control);
153
-
154
- if (plugin) {
155
- if (isMethod) {
156
- // call a method on the control with the remaining args
157
- plugin[meth].apply(plugin, args.slice(1));
52
+ for (var i = 0; i < controls.length; i++) {
53
+ c = controls[i];
54
+ if (!controllerNames.length || isAControllerOf(c, controllerNames)) {
55
+ instances.push(c);
158
56
  }
159
- else {
160
- // call the plugin's update method
161
- plugin.update.apply(plugin, args);
162
- }
163
- }
164
- else {
165
- //create a new control instance
166
- control.newInstance.apply(control, [this].concat(args));
167
57
  }
168
58
  });
169
- };
59
+ return instances;
60
+ },
61
+
62
+
63
+ control: function (control) {
64
+ return this.controls.apply(this, arguments)[0];
65
+ }
66
+ });
67
+
68
+ can.Control.plugin = function (pluginname) {
69
+ var control = this;
70
+
71
+ if (!$.fn[pluginname]) {
72
+ $.fn[pluginname] = function (options) {
73
+
74
+ var args = makeArray(arguments),
75
+ //if the arg is a method on this control
76
+ isMethod = typeof options == "string" && $.isFunction(control.prototype[options]),
77
+ meth = args[0],
78
+ returns;
79
+ this.each(function () {
80
+ //check if created
81
+ var plugin = can.$(this).control(control);
82
+
83
+ if (plugin) {
84
+ if (isMethod) {
85
+ // call a method on the control with the remaining args
86
+ returns = plugin[meth].apply(plugin, args.slice(1));
87
+ }
88
+ else {
89
+ // call the plugin's update method
90
+ plugin.update.apply(plugin, args);
91
+ }
92
+ }
93
+ else {
94
+ //create a new control instance
95
+ control.newInstance.apply(control, [this].concat(args));
96
+ }
97
+ });
98
+ return returns !== undefined ? returns : this;
99
+ };
100
+ }
170
101
  }
171
- }
172
-
173
- /**
174
- * @function can.Control.prototype.update
175
- * @parent can.Control.plugin
176
- *
177
- * Update extends [can.Control.prototype.options options]
178
- * with the `options` argument and rebinds all events. It
179
- * re-configures the control.
180
- *
181
- * For example, the following control wraps a recipe form. When the form
182
- * is submitted, it creates the recipe on the server. When the recipe
183
- * is `created`, it resets the form with a new instance.
184
- *
185
- * var Creator = can.Control({
186
- * "{recipe} created" : function(){
187
- * this.update({recipe : new Recipe()});
188
- * this.element[0].reset();
189
- * this.element.find("[type=submit]").val("Create Recipe")
190
- * },
191
- * "submit" : function(el, ev){
192
- * ev.preventDefault();
193
- * var recipe = this.options.recipe;
194
- * recipe.attrs( this.element.formParams() );
195
- * this.element.find("[type=submit]").val("Saving...")
196
- * recipe.save();
197
- * }
198
- * });
199
- *
200
- * $('#createRecipes').creator({ recipe : new Recipe() })
201
- *
202
- * *Update* is called if a control's plugin helper is called with the plugin options on an element
203
- * that already has a control instance of the same type. If you want to implement your
204
- * own update method make sure to call the old one either using the [can.Construct.super super] plugin or
205
- * by calling `can.Control.prototype.update.apply(this, arguments);`.
206
- * For example, you can change the content of the control element every time the options change:
207
- *
208
- * var Plugin = can.Control({
209
- * pluginName: 'myPlugin'
210
- * }, {
211
- * init : function(el, options) {
212
- * this.updateCount = 0;
213
- * this.update({
214
- * text : 'Initialized'
215
- * });
216
- * },
217
- * update : function(options) {
218
- * // Call the can.Control update first.
219
- * // Use this._super when using can/construct/super
220
- * can.Control.prototype.update.call(this, options);
221
- * this.element.html(this.options.text + ' ' +
222
- * (++this.updateCount) + ' times');
223
- * }
224
- * });
225
- *
226
- * $('#control').myPlugin();
227
- * $('#control').html();
228
- * // Initialized. Updated 1 times
229
- *
230
- * $('#control').myPlugin({ text : 'Calling update. Updated' });
231
- * $('#control').html();
232
- * // Calling update. Updated 2 times
233
- *
234
- * @demo can/control/plugin/demo-update.html
235
- *
236
- * @param {Object} options A list of options to merge with
237
- * [can.Control.prototype.options this.options]. Often this method
238
- * is called by the [can.Control.plugin jQuery helper function].
239
- */
240
- can.Control.prototype.update = function( options ) {
102
+
103
+ can.Control.prototype.update = function (options) {
241
104
  can.extend(this.options, options);
242
105
  this.on();
243
- };
106
+ };
244
107
 
245
- })(this.can, this )
108
+ })(this, jQuery, can);