Sha256: 68bdbba9f87c4a334c2954b6899c807e62f35a2c311594c138cd0d54e4103828
Contents?: true
Size: 1.56 KB
Versions: 9
Compression:
Stored size: 1.56 KB
Contents
// ========================================================================== // Project: SproutCore - JavaScript Application Framework // Copyright: ©2006-2011 Strobe Inc. and contributors. // ©2008-2011 Apple Inc. All rights reserved. // License: Licensed under MIT license (see license.js) // ========================================================================== sc_require('views/template'); /** @class */ SC.Checkbox = SC.TemplateView.extend( /** @scope SC.Checkbox.prototype */ { title: null, value: null, classNames: ['sc-checkbox'], template: SC.Handlebars.compile('<label><input type="checkbox">{{title}}</label>'), didCreateLayer: function() { var self = this; this.$('input').bind('change', function() { self.domValueDidChange(this); }); }, domValueDidChange: function(node) { this.set('value', !!$(node).attr('checked')); }, value: function(key, value) { if (value !== undefined) { this.$('input').attr('checked', value); } else { value = this.$('input').attr('checked'); } return value; }.property() }); SC.CheckboxSupport = /** @scope SC.CheckboxSupport */{ didCreateLayer: function() { this.$('input').change(jQuery.proxy(function() { SC.RunLoop.begin(); this.notifyPropertyChange('value'); SC.RunLoop.end(); }, this)); }, value: function(key, value) { if (value !== undefined) { this.$('input').attr('checked', value); } else { value = this.$('input').attr('checked'); } return value; }.property().idempotent() };
Version data entries
9 entries across 9 versions & 1 rubygems