source: Dev/trunk/src/client/qed-client/lib/object.js @ 510

Last change on this file since 510 was 510, checked in by hendrikvanantwerpen, 11 years ago
  • Factored out general object mapping and iteration.
  • Split widgets for multiplechoice and singlechoice.
  • Restored readOnly/disabled setting for QuestionEditorPreviewItem? on innerWidget (since view innerWidget is not a form anymore, we cannot just set it on that, we iterate over all form children now).
File size: 966 bytes
Line 
1define([
2],function(){
3    var object = {
4        forEach: function(obj,callback,thisObject) {
5            for ( var prop in obj ) {
6                if ( obj.hasOwnProperty(prop) ) {
7                    callback.call(thisObject,obj[prop],prop,obj);
8                }
9            }
10        },
11        map: function(obj,callback,thisObject) {
12            var newObj = {};
13            for ( var prop in obj ) {
14                if ( obj.hasOwnProperty(prop) ) {
15                    newObj[prop] = callback.call(thisObject,obj[prop],prop,obj);
16                }
17            }
18            return newObj;
19        },
20        mapToArray: function(obj,callback,thisObject) {
21            var newArray = [];
22            for ( var prop in obj ) {
23                if ( obj.hasOwnProperty(prop) ) {
24                    newArray.push(callback.call(thisObject,obj[prop],prop,obj));
25                }
26            }
27            return newArray;
28        }
29    };
30    return object;
31});
Note: See TracBrowser for help on using the repository browser.