Build 0.4.8.
Showing
5 changed files
with
45 additions
and
28 deletions
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | "name": "rivets", | 2 | "name": "rivets", |
3 | "repo": "mikeric/rivets", | 3 | "repo": "mikeric/rivets", |
4 | "description": "Declarative data binding facility.", | 4 | "description": "Declarative data binding facility.", |
5 | "version": "0.4.7", | 5 | "version": "0.4.8", |
6 | "keywords": ["data binding", "templating"], | 6 | "keywords": ["data binding", "templating"], |
7 | "scripts": ["lib/rivets.js"], | 7 | "scripts": ["lib/rivets.js"], |
8 | "main": "lib/rivets.js", | 8 | "main": "lib/rivets.js", | ... | ... |
1 | // rivets.js | 1 | // rivets.js |
2 | // version: 0.4.7 | 2 | // version: 0.4.8 |
3 | // author: Michael Richards | 3 | // author: Michael Richards |
4 | // license: MIT | 4 | // license: MIT |
5 | (function() { | 5 | (function() { |
... | @@ -405,21 +405,31 @@ | ... | @@ -405,21 +405,31 @@ |
405 | 405 | ||
406 | getInputValue = function(el) { | 406 | getInputValue = function(el) { |
407 | var o, _i, _len, _results; | 407 | var o, _i, _len, _results; |
408 | switch (el.type) { | 408 | if (window.jQuery != null) { |
409 | case 'checkbox': | 409 | el = jQuery(el); |
410 | return el.checked; | 410 | switch (el[0].type) { |
411 | case 'select-multiple': | 411 | case 'checkbox': |
412 | _results = []; | 412 | return el.is(':checked'); |
413 | for (_i = 0, _len = el.length; _i < _len; _i++) { | 413 | default: |
414 | o = el[_i]; | 414 | return el.val(); |
415 | if (o.selected) { | 415 | } |
416 | _results.push(o.value); | 416 | } else { |
417 | switch (el.type) { | ||
418 | case 'checkbox': | ||
419 | return el.checked; | ||
420 | case 'select-multiple': | ||
421 | _results = []; | ||
422 | for (_i = 0, _len = el.length; _i < _len; _i++) { | ||
423 | o = el[_i]; | ||
424 | if (o.selected) { | ||
425 | _results.push(o.value); | ||
426 | } | ||
417 | } | 427 | } |
418 | } | 428 | return _results; |
419 | return _results; | 429 | break; |
420 | break; | 430 | default: |
421 | default: | 431 | return el.value; |
422 | return el.value; | 432 | } |
423 | } | 433 | } |
424 | }; | 434 | }; |
425 | 435 | ||
... | @@ -482,18 +492,25 @@ | ... | @@ -482,18 +492,25 @@ |
482 | return unbindEvent(el, 'change', this.currentListener); | 492 | return unbindEvent(el, 'change', this.currentListener); |
483 | }, | 493 | }, |
484 | routine: function(el, value) { | 494 | routine: function(el, value) { |
485 | var o, _i, _len, _ref, _ref1, _results; | 495 | var o, _i, _len, _ref, _ref1, _ref2, _results; |
486 | if (el.type === 'select-multiple') { | 496 | if (window.jQuery != null) { |
487 | if (value != null) { | 497 | el = jQuery(el); |
488 | _results = []; | 498 | if ((value != null ? value.toString() : void 0) !== ((_ref = el.val()) != null ? _ref.toString() : void 0)) { |
489 | for (_i = 0, _len = el.length; _i < _len; _i++) { | 499 | return el.val(value != null ? value : ''); |
490 | o = el[_i]; | 500 | } |
491 | _results.push(o.selected = (_ref = o.value, __indexOf.call(value, _ref) >= 0)); | 501 | } else { |
502 | if (el.type === 'select-multiple') { | ||
503 | if (value != null) { | ||
504 | _results = []; | ||
505 | for (_i = 0, _len = el.length; _i < _len; _i++) { | ||
506 | o = el[_i]; | ||
507 | _results.push(o.selected = (_ref1 = o.value, __indexOf.call(value, _ref1) >= 0)); | ||
508 | } | ||
509 | return _results; | ||
492 | } | 510 | } |
493 | return _results; | 511 | } else if ((value != null ? value.toString() : void 0) !== ((_ref2 = el.value) != null ? _ref2.toString() : void 0)) { |
512 | return el.value = value != null ? value : ''; | ||
494 | } | 513 | } |
495 | } else if ((value != null ? value.toString() : void 0) !== ((_ref1 = el.value) != null ? _ref1.toString() : void 0)) { | ||
496 | return el.value = value != null ? value : ''; | ||
497 | } | 514 | } |
498 | } | 515 | } |
499 | }, | 516 | }, | ... | ... |
This diff is collapsed.
Click to expand it.
1 | { | 1 | { |
2 | "name" : "rivets", | 2 | "name" : "rivets", |
3 | "description" : "Declarative data binding facility.", | 3 | "description" : "Declarative data binding facility.", |
4 | "version" : "0.4.7", | 4 | "version" : "0.4.8", |
5 | "author" : "Michael Richards", | 5 | "author" : "Michael Richards", |
6 | "url" : "http://rivetsjs.com", | 6 | "url" : "http://rivetsjs.com", |
7 | "main" : "./lib/rivets.js", | 7 | "main" : "./lib/rivets.js", | ... | ... |
-
Please register or sign in to post a comment