4 | function readonly(elements, selector, parent) |
5 | { |
6 | control.call(this, elements, selector, parent); |
7 | Object.defineProperty(this, "__elements", {value: Array.prototype.slice.call(parent.__element.querySelectorAll(selector)), configurable: true}); |
8 | this.__binder.defineDataProperties(this, |
9 | { |
10 | attributes: |
11 | { |
12 | get: function(){return this.__attributes;}, |
13 | set: function(value) |
14 | { |
15 | if (value!==undefined&&value.isObserver) value=value(); |
16 | this.__attributes=value; |
17 | |
18 | if (value!==undefined) |
19 | for(var key in value) |
20 | { |
21 | each(this.__elements, function(element){element.setAttribute("data-"+key, value[key]);}); |
22 | this.__element.setAttribute("data-" + key, value[key]); |
23 | } |
24 | } |
25 | }, |
26 | disabled: {get: function(){return this.__element.disabled;}, set: function(value){each(this.__elements, function(element){element.disabled = !(!value);}); this.__element.disabled=!(!value);}}, |
27 | display: {get: function(){return this.__element.style.display=="";}, set: function(value){this[value?"show":"hide"]();}}, |
28 | enabled: {get: function(){return !this.__element.disabled;}, set: function(value){each(this.__elements, function(element){element.disabled = !value;}); this.__element.disabled=!value;}}, |
29 | tooltip: {get: function(){return this.__element.title;}, set: function(value){var val = value&&value.isObserver?value():(value||""); each(this.__elements, function(element){element.title = val;}); this.__element.title = val;}}, |
30 | value: {get: function(){return this.__element.innerHTML;}, set: function(value){var val = value&&value.isObserver?value():value; each(this.__elements, function(element){element.innerHTML = val;}); this.__element.innerHTML = val;}} |
31 | }); |
32 | } |