Ignore:
Timestamp:
03/12/14 15:16:54 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • 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:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/widgets/LineWithActionsWidget.js

    r494 r510  
    1 define(['dojo/_base/declare',
    2     'dojo/_base/lang',
    3     'dojo/on',
    4     'dojo/dom',
    5     'dojo/_base/event',
    6     'dojo/dom-class',
    7     'dijit/form/Button',
    8     'dijit/_WidgetBase',
    9     'dijit/_TemplatedMixin',
    10     'dijit/_WidgetsInTemplateMixin',
    11     'dojo/text!./templates/LineWithActionsWidget.html'
    12 ],function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
     1define([
     2    "../lib/object",
     3    "dijit/_TemplatedMixin",
     4    "dijit/_WidgetBase",
     5    "dijit/_WidgetsInTemplateMixin",
     6    "dijit/form/Button",
     7    "dojo/_base/declare",
     8    "dojo/_base/event",
     9    "dojo/_base/lang",
     10    "dojo/dom",
     11    "dojo/dom-class",
     12    "dojo/on",
     13    "dojo/text!./templates/LineWithActionsWidget.html"
     14], function(objectFuns, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, declare, event, lang, dom, domClass, on, templateString) {
    1315    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
    1416        templateString: templateString,
     
    3335                return;
    3436            }
    35             for (var action in this.actions) {
    36                 if ( this.actions.hasOwnProperty(action) ) {
    37                     var properties;
    38                     if (this.actions[action].properties.blockButton === true) {
    39                         properties = lang.mixin({
    40                             baseClass: 'rftBlockButton',
    41                             label: "Default",
    42                             iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
    43                             title: this.actions[action].properties.tooltip,
    44                             onClick: lang.hitch(this, function(action, e){
    45                                 if ( action.callback ) { action.callback(e); }
    46                                 if ( e ) { event.stop(e); }
    47                                 return false;
    48                             }, this.actions[action])
    49                         }, this.actions[action].properties);
    50                         new Button(properties).placeAt(this.buttonsNode);
    51                     } else {
    52                         properties = lang.mixin({
    53                             baseClass: 'rftInlineButton',
    54                             label: "Default",
    55                             showLabel: false,
    56                             iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
    57                             title: this.actions[action].properties.tooltip,
    58                             onClick: lang.hitch(this, function(action, e){
    59                                 if ( action.callback ) { action.callback(e); }
    60                                 if ( e ) { event.stop(e); }
    61                                 return false;
    62                             }, this.actions[action])
    63                         }, this.actions[action].properties);
    64                         new Button(properties).placeAt(this.buttonsNode);
    65                     }
     37            objectFuns.forEach(this.actions, function(value,action){
     38                var properties;
     39                if (value.properties.blockButton === true) {
     40                    properties = lang.mixin({
     41                        baseClass: 'rftBlockButton',
     42                        label: "Default",
     43                        iconClass: 'rftIcon rftIcon'+value.properties.icon,
     44                        title: value.properties.tooltip,
     45                        onClick: lang.hitch(this, function(action, e){
     46                            if ( action.callback ) { action.callback(e); }
     47                            if ( e ) { event.stop(e); }
     48                            return false;
     49                        }, value)
     50                    }, value.properties);
     51                    new Button(properties).placeAt(this.buttonsNode);
     52                } else {
     53                    properties = lang.mixin({
     54                        baseClass: 'rftInlineButton',
     55                        label: "Default",
     56                        showLabel: false,
     57                        iconClass: 'rftIcon rftIcon'+value.properties.icon,
     58                        title: value.properties.tooltip,
     59                        onClick: lang.hitch(this, function(action, e){
     60                            if ( action.callback ) { action.callback(e); }
     61                            if ( e ) { event.stop(e); }
     62                            return false;
     63                        }, value)
     64                    }, value.properties);
     65                    new Button(properties).placeAt(this.buttonsNode);
    6666                }
    67             }
     67            },this);
    6868        },
    6969        refresh: function() {
Note: See TracChangeset for help on using the changeset viewer.