Changeset 426


Ignore:
Timestamp:
03/13/13 17:07:58 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Added grunt tasks and code cleanup.

Added grunt for less and jshint procesing.
Cleanup of code to pass jshint (one bug found :).

Location:
Dev/trunk
Files:
1 added
27 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Dev/trunk

    • Property svn:ignore
      •  

        old new  
        11data
        22nbproject
         3node_modules
  • Dev/trunk/client

    • Property svn:externals
      •  

        old new  
        1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojo
        2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8.0/dijit
        3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojox
        4 util http://svn.dojotoolkit.org/src/tags/release-1.8.0/util
         1dojo http://svn.dojotoolkit.org/src/tags/release-1.8.3/dojo
         2dijit http://svn.dojotoolkit.org/src/tags/release-1.8.3/dijit
         3dojox http://svn.dojotoolkit.org/src/tags/release-1.8.3/dojox
         4util http://svn.dojotoolkit.org/src/tags/release-1.8.3/util
  • Dev/trunk/client/qed/lib/async.js

    r420 r426  
    11define([
    2      'dojo/_base/array',
    3      'dojo/_base/lang',
    4      'dojo/when',
    5      'dojo/Deferred'
     2    'dojo/_base/array',
     3    'dojo/_base/lang',
     4    'dojo/when',
     5    'dojo/Deferred'
    66],function(array,lang,when,Deferred){
    77
     
    2020        var running = null;
    2121        function cancel(err) {
    22             if ( cancelled ) return;
     22            if ( cancelled ) { return; }
    2323            cancelled = true;
    24             running && running.cancel && !running.isFulfilled() && running.cancel();
     24            if ( running && running.cancel && !running.isFulfilled() ) {
     25                running.cancel();
     26            }
    2527            d.reject(err);
    2628        }
    2729
    2830        function update(fs,arg) {
    29             if ( cancelled ) return;
     31            if ( cancelled ) { return; }
    3032            if ( fs.length > 0 ) {
    3133                try {
     
    5860     */
    5961    function par(functions,ctx) {
    60         var d = new Deferred(cancel);
    61 
     62        var d; // later: Deferred
     63       
    6264        var cancelled = false;
    6365        var running = [];
    6466        function cancel(err) {
    65             if (cancelled) return;
     67            if (cancelled) { return; }
    6668            cancelled = true;
    6769            array.forEach(running,function(running){
    68                 running && running.cancel && !running.isFulfilled() && running.cancel();
     70                if ( running && running.cancel && !running.isFulfilled() ) {
     71                    running.cancel();
     72                }
    6973            });
    7074            d.reject(err);
    7175        }
    7276
     77        d = new Deferred(cancel);
     78
    7379        var results = [];
    7480        var left = functions.length;
    7581        function update(res,idx) {
    76             if (cancelled) return;
     82            if (cancelled) { return; }
    7783            results[idx] = res;
    7884            left -= 1; // Works because/as long as AJAX/JS is single-threaded.
     
    8389
    8490        array.forEach(functions,function(f,idx){
    85             if (cancelled) return;
     91            if (cancelled) { return; }
    8692            try {
    8793                running.push(when(f.call(ctx)).then(function(res){
  • Dev/trunk/client/qed/main-response.js

    r420 r426  
    1414    'dojo/domReady!',
    1515    'qed/stddeps'
    16 ],function(date,locale,hash,parser,store,Content,Page,Path,async,Response,SurveyRun,response) {
     16],function(date,locale,hash,parser,store,Content,Page,Path,async,Response,SurveyRun,ResponsePage) {
    1717    parser.parse();
    1818    Content.startup();
     
    7373    .then(function(responseId){
    7474        hash(Path.format("/"+surveyRunId,{ id: responseId }));
    75         Content.set(new response({
     75        Content.set(new ResponsePage({
    7676            surveyRunId: surveyRunId,
    7777            options: {
  • Dev/trunk/client/qed/model/schema.js

    r420 r426  
    2828    var string = mkType({ type:'string' });
    2929    var integer = mkType({ type: 'integer' });
    30     var boolean = mkType({ type: 'boolean' });
     30    var bool = mkType({ type: 'boolean' });
    3131    var pattern = function(p){
    3232        return mixin({
     
    102102            }),
    103103            typedobject('MultipleChoiceInput',{
    104                 multiple:boolean(),
     104                multiple:bool(),
    105105                items:array(nestring())
    106106            })
  • Dev/trunk/client/qed/model/widgets/CategoryListView.js

    r417 r426  
    22    'dojo/_base/declare',
    33    'dojo/_base/lang',
     4    'dojo/dom-construct',
    45    '../../widgets/LineWithActionsWidget',
    56    '../../widgets/list/List'
    6 ],function(
    7     declare,
    8     lang,
    9     LineWithActionsWidget,
    10     List
    11 ) {
     7],function(declare, lang, domConstruct, LineWithActionsWidget, List) {
    128    return declare([List],{
    139        baseClass: 'rftLineListView',
    1410
    1511        _createAvatarNode: function(item) {
    16             var node = document.createElement("div");
    17             node.className = "dragAvatar";
    18             node.innerHTML = item.title;
     12            var node = domConstruct.create("div",{
     13                className: "dragAvatar",
     14                innerHTML: item.title
     15            });
    1916            return node;
    2017        },
  • Dev/trunk/client/qed/model/widgets/QuestionEditorToolkit.js

    r417 r426  
    1414    './CategoryListView',
    1515    'dojo/text!./templates/QuestionEditorToolkit.html'
    16     ], function(declare, lang, Source, domConstruct, Memory, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button, ComboBox, store, CategoryListView, template) {
    17         return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {
     16], function(declare, lang, Source, domConstruct, Memory, _Container,
     17        _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, Button,
     18        ComboBox, store, CategoryListView, template) {
     19    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {
    1820
    19             templateString: template,
    20             _list: null,
    21             _categorySelect: null,
    22             _categoryStore: null,
    23             _topicSelect: null,
    24             _topicStore: null,
    25             _categories : null,
     21        templateString: template,
     22        _list: null,
     23        _categorySelect: null,
     24        _categoryStore: null,
     25        _topicSelect: null,
     26        _topicStore: null,
     27        _categories : null,
    2628
    27             _contentItems: [
    28                 { type: "Header" },
    29                 { type: "Text" },
    30                 { type: "Image" },
    31                 { type: "ExternalMedia" },
    32                 { type: "Divider" }
    33             ],
    34             _inputsItems: [
    35                 { type: "StringInput" },
    36                 { type: "TextInput" },
    37                 { type: "IntegerInput" },
    38                 { type: "ScaleInput" },
    39                 { type: "MultipleChoiceInput" }
    40             ],
    41             _labelMap: {
    42                 "Header": "Header",
    43                 "Text": "Text",
    44                 "Image": "Image",
    45                 "ExternalMedia": "External media",
    46                 "Divider": "Divider",
    47                 "StringInput": "Text line",
    48                 "TextInput": "Free text",
    49                 "IntegerInput": "Integer number",
    50                 "ScaleInput": "Scale",
    51                 "MultipleChoiceInput": "Multiple choice"
    52             },
    53             _iconMap: {
    54                 "Header": "Header",
    55                 "Text": "TextBox",
    56                 "Image": "Image",
    57                 "ExternalMedia": "External",
    58                 "Divider": "Divider",
    59                 "StringInput": "Text",
    60                 "TextInput": "Text",
    61                 "IntegerInput": "Integer",
    62                 "ScaleInput": "Scale",
    63                 "MultipleChoiceInput": "MultipleChoice"
    64             },
     29        _contentItems: [
     30            { type: "Header" },
     31            { type: "Text" },
     32            { type: "Image" },
     33            { type: "ExternalMedia" },
     34            { type: "Divider" }
     35        ],
     36        _inputsItems: [
     37            { type: "StringInput" },
     38            { type: "TextInput" },
     39            { type: "IntegerInput" },
     40            { type: "ScaleInput" },
     41            { type: "MultipleChoiceInput" }
     42        ],
     43        _labelMap: {
     44            "Header": "Header",
     45            "Text": "Text",
     46            "Image": "Image",
     47            "ExternalMedia": "External media",
     48            "Divider": "Divider",
     49            "StringInput": "Text line",
     50            "TextInput": "Free text",
     51            "IntegerInput": "Integer number",
     52            "ScaleInput": "Scale",
     53            "MultipleChoiceInput": "Multiple choice"
     54        },
     55        _iconMap: {
     56            "Header": "Header",
     57            "Text": "TextBox",
     58            "Image": "Image",
     59            "ExternalMedia": "External",
     60            "Divider": "Divider",
     61            "StringInput": "Text",
     62            "TextInput": "Text",
     63            "IntegerInput": "Integer",
     64            "ScaleInput": "Scale",
     65            "MultipleChoiceInput": "MultipleChoice"
     66        },
    6567
    66             postCreate: function(){
    67                 this.inherited(arguments);
    68                 var creator = lang.hitch(this,"_creator");
    69                 this.contentSource = new Source(this.ToolkitContentSourceNode, {
    70                     accept: [],
    71                     copyOnly: true,
    72                     selfAccept: false,
    73                     singular: true,
    74                     creator: creator
     68        postCreate: function(){
     69            this.inherited(arguments);
     70            var creator = lang.hitch(this,"_creator");
     71            this.contentSource = new Source(this.ToolkitContentSourceNode, {
     72                accept: [],
     73                copyOnly: true,
     74                selfAccept: false,
     75                singular: true,
     76                creator: creator
     77            });
     78            this.inputsSource = new Source(this.ToolkitInputsSourceNode, {
     79                accept: [],
     80                copyOnly: true,
     81                selfAccept: false,
     82                singular: true,
     83                creator: creator
     84            });
     85            this.contentSource.insertNodes(false, this._contentItems);
     86            this.inputsSource.insertNodes(false, this._inputsItems);
     87        },
     88        _setValueAttr: function(question) {
     89            this.propertiesForm.set('value', question);
     90            this._categories = question.categories || [];
     91            this._setupListView();
     92            this._setupCategories();
     93            this._setupTopic(question.topic);
     94        },
     95        _getValueAttr: function() {
     96            var value = this.propertiesForm.get('value');
     97            value.categories = this._categories;
     98            return value;
     99        },
     100        onCategoryAdd: function() {
     101            this._addCategory(this._categorySelect.get('displayedValue'));
     102            this._categorySelect.reset();
     103        },
     104        _creator: function(item, hint) {
     105            var node;
     106            if (hint === "avatar") {
     107                node = domConstruct.create('span',{
     108                    innerHTML: this._labelMap[item.type] || item.type
    75109                });
    76                 this.inputsSource = new Source(this.ToolkitInputsSourceNode, {
    77                     accept: [],
    78                     copyOnly: true,
    79                     selfAccept: false,
    80                     singular: true,
    81                     creator: creator
     110            } else {
     111                var w = new Button({
     112                    baseClass: "rftLargeButton",
     113                    iconClass: "rftIcon rftIcon"+(this._iconMap[item.type]||"Unknown"),
     114                    label: this._labelMap[item.type] || item.type,
     115                    showLabel: true,
     116                    'class': "newline"
    82117                });
    83                 this.contentSource.insertNodes(false, this._contentItems);
    84                 this.inputsSource.insertNodes(false, this._inputsItems);
    85             },
    86             _setValueAttr: function(question) {
    87                 this.propertiesForm.set('value', question);
    88                 this._categories = question.categories || [];
    89                 this._setupListView();
    90                 this._setupCategories();
    91                 this._setupTopic(question.topic);
    92             },
    93             _getValueAttr: function() {
    94                 var value = this.propertiesForm.get('value');
    95                 value.categories = this._categories;
    96                 return value;
    97             },
    98             onCategoryAdd: function() {
    99                 this._addCategory(this._categorySelect.get('displayedValue'));
    100                 this._categorySelect.reset();
    101             },
    102             _creator: function(item, hint) {
    103                 var node;
    104                 if (hint == "avatar") {
    105                     node = domConstruct.create('span',{
    106                         innerHTML: this._labelMap[item.type] || item.type
    107                     });
    108                 } else {
    109                     var w = new Button({
    110                         baseClass: "rftLargeButton",
    111                         iconClass: "rftIcon rftIcon"+(this._iconMap[item.type]||"Unknown"),
    112                         label: this._labelMap[item.type] || item.type,
    113                         showLabel: true,
    114                         'class': "newline"
    115                     });
    116                     node = w.domNode;
    117                 }
    118                 return {node: node, data: item, type: ["questionContent"]};
    119             },
    120             _setupListView: function() {
    121                 this._list = new CategoryListView( {
    122                     removeCallback: lang.hitch(this, this._removeCategory)
    123                 }).placeAt(this.listNode);
    124                 this._list.startup();               
    125                 for (var category in this._categories) {
    126                     this._list.appendItem(this._categories[category]);
    127                 }   
    128             },
    129             _setupCategories: function() {
    130                 this._categoryStore = new Memory({data: [] });
    131                 store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1})
    132                 .forPairs(lang.hitch(this, function(value, key) {
    133                     this._categoryStore.put({ id: key[0] });
    134                 }));
    135                 this._categorySelect = new ComboBox( {
    136                     name: "categories",
    137                     store: this._categoryStore,
    138                     searchAttr: "id"
    139                 }, this.categoriesBoxNode);
    140                 this._supportingWidgets.push(this._categorySelect);
     118                node = w.domNode;
     119            }
     120            return {node: node, data: item, type: ["questionContent"]};
     121        },
     122        _setupListView: function() {
     123            this._list = new CategoryListView( {
     124                removeCallback: lang.hitch(this, this._removeCategory)
     125            }).placeAt(this.listNode);
     126            this._list.startup();               
     127            for (var category in this._categories) {
     128                this._list.appendItem(this._categories[category]);
     129            }   
     130        },
     131        _setupCategories: function() {
     132            this._categoryStore = new Memory({data: [] });
     133            store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1})
     134            .forPairs(lang.hitch(this, function(value, key) {
     135                this._categoryStore.put({ id: key[0] });
     136            }));
     137            this._categorySelect = new ComboBox( {
     138                name: "categories",
     139                store: this._categoryStore,
     140                searchAttr: "id"
     141            }, this.categoriesBoxNode);
     142            this._supportingWidgets.push(this._categorySelect);
    141143
    142             },
    143             _setupTopic: function(topic) {
    144                 this._topicStore = new Memory( {data: [] });
    145                 store.query("_design/questions/_view/all_topics", {reduce:true, group:true})
    146                 .forPairs(lang.hitch(this, function(value, key) {
    147                     this._topicStore.put({ id: key });
    148                 }));
    149                 this._topicSelect = new ComboBox( {
    150                     name: "topic",
    151                     store: this._topicStore,
    152                     searchAttr: "id",
    153                     value: topic
    154                 }, this.topicBoxNode);
    155                 this._supportingWidgets.push(this._topicSelect);
    156             },
    157             _addCategory: function(item) {
    158                 this._categories.push(item);
    159                 this._list.appendItem(item);
    160             },
    161             _removeCategory: function(item) {
    162                 this._categories.splice(this._categories.indexOf(item), 1);
    163             }
     144        },
     145        _setupTopic: function(topic) {
     146            this._topicStore = new Memory( {data: [] });
     147            store.query("_design/questions/_view/all_topics", {reduce:true, group:true})
     148            .forPairs(lang.hitch(this, function(value, key) {
     149                this._topicStore.put({ id: key });
     150            }));
     151            this._topicSelect = new ComboBox( {
     152                name: "topic",
     153                store: this._topicStore,
     154                searchAttr: "id",
     155                value: topic
     156            }, this.topicBoxNode);
     157            this._supportingWidgets.push(this._topicSelect);
     158        },
     159        _addCategory: function(item) {
     160            this._categories.push(item);
     161            this._list.appendItem(item);
     162        },
     163        _removeCategory: function(item) {
     164            this._categories.splice(this._categories.indexOf(item), 1);
     165        }
    164166
    165         });
    166167    });
     168});
  • Dev/trunk/client/qed/model/widgets/QuestionListView.js

    r417 r426  
    3636                    },
    3737                    "Info" : {
    38                         callback: function(){ item.description && alert(item.description); },
     38                        callback: function(){
     39                            if ( item.description ) { alert(item.description); }
     40                        },
    3941                        properties: {
    4042                            blockButton: false,
  • Dev/trunk/client/qed/model/widgets/QuestionWidget.js

    r417 r426  
    22    'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
    33    'dojo/text!./templates/QuestionWidget.html','dijit/form/TextBox',
    4     'dijit/form/Textarea','../../widgets/MultipleChoiceWidget'],
    5     function(declare,lang,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
    6         return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
    7             templateString: templateString,
    8             mode: 'view', // view || edit
    9             name: '',
    10             value: null,
    11             _scale: null,
    12             _widgetCache: null,
    13             constructor: function() {
    14                 this.inherited(arguments);
    15                 this.value = {};
    16                 this._widgetCache = {};
    17             },
    18             postCreate: function() {
    19                 this._resetValue = this.value;
    20                 this.scaleSelector.set('disabled', this.mode == 'edit');
    21             },
    22             _setValueAttr: function(value) {
    23                 this.value = value;
    24                 this._onTypeChange(value.scale || 'string');
    25                 this.ourForm.set('value',value);
    26             },
    27             _getValueAttr: function() {
    28                 var value = this.ourForm.get('value');
    29                 lang.mixin(this.value,value);
    30                 return this.value;
    31             },
    32             _onTypeChange: function(scale) {
    33                 if ( this._scale == scale ) return;
    34                 this._scale = scale;
    35                 domConstruct.empty(this.scaleDetails);
    36                 var widget = this._getTypeWidget(scale);
    37                 widget && widget.placeAt(this.scaleDetails,'only');
    38             },
    39             _getTypeWidget: function(scale) {
    40                 var widget = this._widgetCache[scale];
    41                 if (!widget) {
    42                     switch(scale) {
    43                         case 'string':
    44                             widget = new TextBox({
    45                                 name: 'answers',
    46                                 disabled: this.mode == 'view'
    47                             });
    48                             break;
    49                         case 'text':
    50                             widget = new Textarea({
    51                                 name: 'answers',
    52                                 disabled: this.mode == 'view',
    53                                 style: 'min-height: 120px'
    54                             });
    55                             break;
    56                         case 'singleChoice':
    57                         case 'multipleChoice':
    58                             widget = new MultipleChoiceWidget({
    59                                 name: 'answers',
    60                                 mode: this.mode,
    61                                 allowMultiple: scale == 'multipleChoice'
    62                             });
    63                             break;
    64                     }
    65                     this._widgetCache[scale] = widget;
     4    'dijit/form/Textarea','../../widgets/MultipleChoiceWidget'
     5], function(declare,lang,domConstruct,_WidgetBase,_TemplatedMixin,
     6        _WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
     7    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
     8        templateString: templateString,
     9        mode: 'view', // view || edit
     10        name: '',
     11        value: null,
     12        _scale: null,
     13        _widgetCache: null,
     14        constructor: function() {
     15            this.inherited(arguments);
     16            this.value = {};
     17            this._widgetCache = {};
     18        },
     19        postCreate: function() {
     20            this._resetValue = this.value;
     21            this.scaleSelector.set('disabled', this.mode === 'edit');
     22        },
     23        _setValueAttr: function(value) {
     24            this.value = value;
     25            this._onTypeChange(value.scale || 'string');
     26            this.ourForm.set('value',value);
     27        },
     28        _getValueAttr: function() {
     29            var value = this.ourForm.get('value');
     30            lang.mixin(this.value,value);
     31            return this.value;
     32        },
     33        _onTypeChange: function(scale) {
     34            if ( this._scale === scale ) { return; }
     35            this._scale = scale;
     36            domConstruct.empty(this.scaleDetails);
     37            var widget = this._getTypeWidget(scale);
     38            if ( widget ) { widget.placeAt(this.scaleDetails,'only'); }
     39        },
     40        _getTypeWidget: function(scale) {
     41            var widget = this._widgetCache[scale];
     42            if (!widget) {
     43                switch(scale) {
     44                case 'string':
     45                    widget = new TextBox({
     46                        name: 'answers',
     47                        disabled: this.mode === 'view'
     48                    });
     49                    break;
     50                case 'text':
     51                    widget = new Textarea({
     52                        name: 'answers',
     53                        disabled: this.mode === 'view',
     54                        style: 'min-height: 120px'
     55                    });
     56                    break;
     57                case 'singleChoice':
     58                case 'multipleChoice':
     59                    widget = new MultipleChoiceWidget({
     60                        name: 'answers',
     61                        mode: this.mode,
     62                        allowMultiple: scale === 'multipleChoice'
     63                    });
     64                    break;
    6665                }
    67                 return widget;
    68             },
    69             reset: function() {
    70                 this.ourForm.reset();
    71                 this._setValueAttr(this._resetValue);
     66                this._widgetCache[scale] = widget;
    7267            }
    73         });
     68            return widget;
     69        },
     70        reset: function() {
     71            this.ourForm.reset();
     72            this._setValueAttr(this._resetValue);
     73        }
    7474    });
     75});
  • Dev/trunk/client/qed/model/widgets/QuestionWidgetFactory.js

    r421 r426  
    3030            var fun = this['create'+options.type+'EditWidget'];
    3131            var view = fun !== undefined ? fun() : null;
    32             if(view)
     32            if (view) {
    3333                view.set('value', options);
     34            }
    3435            return view;
    3536        },
     
    272273            var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );
    273274
    274             var ctor = this.options.multiple === true ? CheckBox : RadioButton;
    275             array.forEach(this.options.items || [],function(item){
    276                 table.addChild(new ctor({
    277                         name: this.options.code || '',
    278                         title: item
     275            var Ctor = this.options.multiple === true ? CheckBox : RadioButton;
     276            array.forEach(this.options.items || [], function(item){
     277                table.addChild(new Ctor({
     278                    name: this.options.code || '',
     279                    title: item
    279280                }));
    280281            },this);
     
    342343            w.startup();
    343344            w.set('value',item);
    344             w.on('delete',lang.hitch(this,'_onRemove',w));
     345            w.on('delete',lang.hitch(this,'_onRemove',w,item));
    345346            return w.domNode;
    346347        },
    347         _onRemove: function(w) {
     348        _onRemove: function(w,item) {
    348349            w.destroyRecursive();
    349             this.removeCallback && this.removeCallback(item);
     350            if ( this.removeCallback ) { this.removeCallback(item); }
    350351            this.source.sync();
    351352        }
  • Dev/trunk/client/qed/package.json

    r407 r426  
    11{
    2     "name": "rft",
    3     "description": "Research Facilitator Tool",
    4     "dependencies": {
    5         "dojo": "~1.8.0",
    6         "dijit": "~1.8.0",
    7         "dojox": "~1.8.0"
    8     },
    9     "dojoBuild": "package.js"
     2  "name": "qed",
     3  "description": "QED",
     4  "dependencies": {
     5    "dojo": "~1.8.0",
     6    "dijit": "~1.8.0",
     7    "dojox": "~1.8.0"
     8  },
     9  "dojoBuild": "qed.profile.js",
     10  "devDependencies": {
     11    "grunt": "~0.4.0",
     12    "grunt-contrib-less": "~0.5.0",
     13    "grunt-contrib-jshint": "~0.2.0"
     14  }
    1015}
  • Dev/trunk/client/qed/pages/question.js

    r420 r426  
    5454                Content.notify(err,'error');
    5555            });
    56             evt && event.stop( evt );
     56            if ( evt ) { event.stop( evt ); }
    5757            return false;
    5858        },
  • Dev/trunk/client/qed/pages/response.js

    r420 r426  
    6262            this._getAnswersAndSaveResponse();
    6363            this.content.domNode.innerHTML = "<div>Thanks for filling in the survey.</div>";
    64             e && event.stop(e);
     64            if ( e ) { event.stop(e); }
    6565            return false;
    6666        },
     
    6868            this._getAnswersAndSaveResponse();
    6969            this.content.domNode.innerHTML = "<div>To continue with this survey later, just save the URL in the location bar and revisit it later. Your answers will still be there.</div>";
    70             e && event.stop(e);
     70            if ( e ) { event.stop(e); }
    7171            return false;
    7272        },
    7373        _ignoreEvent: function(e) {
    74             e && event.stop(e);
     74            if ( e ) { event.stop(e); }
    7575            return false;
    7676        }
  • Dev/trunk/client/qed/pages/survey.js

    r420 r426  
    4343                itemActions: {
    4444                    "Info": {
    45                         callback: function(item){ item.description && alert(item.description); },
     45                        callback: function(item){
     46                            if ( item.description ) { alert(item.description); }
     47                        },
    4648                        icon: "Inspect",
    4749                        description: "Show item description"
  • Dev/trunk/client/qed/pages/surveys.js

    r422 r426  
    6868        refreshDrafts: function() {
    6969            this.draftsContainer.set('content','');
    70             when(store.query("_design/surveys/_view/drafts")
    71                     ,lang.hitch(this,function(surveys){
     70            when(store.query("_design/surveys/_view/drafts"),
     71                    lang.hitch(this,function(surveys) {
    7272                this.draftsTab.set('title','Drafts ('+surveys.length+')');
    7373                array.forEach(surveys,function(survey){
     
    110110        refreshPublished: function() {
    111111            this.publishedContainer.set('content','');
    112             when(store.query("_design/surveys/_view/published")
    113                     ,lang.hitch(this,function(surveys){
     112            when(store.query("_design/surveys/_view/published"),
     113                    lang.hitch(this, function(surveys) {
    114114                this.publishedTab.set('title','Published ('+surveys.length+')');
    115115                array.forEach(surveys,function(survey){
     
    138138        refreshRuns: function() {
    139139            this.runsContainer.set('content','');
    140             when(store.query("_design/default/_view/by_type",{key:'SurveyRun'})
    141                     ,lang.hitch(this,function(surveyRuns){
     140            when(store.query("_design/default/_view/by_type",{key:'SurveyRun'}),
     141                    lang.hitch(this,function(surveyRuns){
    142142                this.runsTab.set('title','Runs ('+surveyRuns.length+')');
    143143                array.forEach(surveyRuns,function(surveyRun){
  • Dev/trunk/client/qed/qed.profile.js

    r424 r426  
    33        resourceTags: {
    44            amd: function (filename, mid) {
    5                 return /\.js$/.test(filename);
     5                return (/\.js$/).test(filename);
    66            },
    77            declarative: function (filename, mid) {
    8                 return /\.html$/.test(filename);
     8                return (/\.html$/).test(filename);
    99            },
    1010            copyOnly: function(filename,mid) {
  • Dev/trunk/client/qed/store/CouchStore.js

    r418 r426  
    271271                dfd.reject(getCouchError(err));
    272272            });
    273             return CouchResults(dfd.promise);
     273            return couchResults(dfd.promise);
    274274        }
    275275    });
    276276
    277     function CouchResults(results) {
    278         results = QueryResults(results);
     277    var queryResults = QueryResults;
     278
     279    function couchResults(results) {
     280        results = queryResults(results);
    279281        results.forPairs = function(callback,thisObject) {
    280282            callback = lang.hitch(thisObject,callback);
  • Dev/trunk/client/qed/store/ElasticReadStore.js

    r410 r426  
    2323            });
    2424            return this.inherited(arguments);
    25           },
     25        },
    2626        _fetchItems: function(request, fetchHandler, errorHandler){
    2727            var serverQuery = request.serverQuery;
  • Dev/trunk/client/qed/ui/MenuBarLink.js

    r410 r426  
    1 define(['dojo/_base/declare','dijit/MenuBarItem','../app/Router'],
    2 function(declare,MenuBarItem,Router){
    3     return declare([MenuBarItem],{
     1define(['dojo/_base/declare','dijit/MenuBarItem','../app/Router'
     2], function(declare,MenuBarItem,Router) {
     3    return declare([MenuBarItem], {
    44        options:{
    55            path: null
    66        },
    77        onClick: function(){
    8             this.path && Router.go(this.path);
     8            if ( this.path ) { Router.go(this.path); }
    99        }
    1010    });
  • Dev/trunk/client/qed/ui/MenuLink.js

    r410 r426  
    1 define(['dojo/_base/declare','dijit/MenuItem','../app/Router'],
    2 function(declare,MenuItem,Router){
     1define(['dojo/_base/declare','dijit/MenuItem','../app/Router'
     2], function(declare,MenuItem,Router) {
    33    return declare([MenuItem],{
    44        options:{
    55            path: null
    66        },
    7         onClick: function(){
    8             this.path && Router.go(this.path);
     7        onClick: function() {
     8            if ( this.path ) { Router.go(this.path); }
    99        }
    1010    });
  • Dev/trunk/client/qed/widgets/LineWithActionsWidget.js

    r417 r426  
    4242                        title: this.actions[action].properties.tooltip,
    4343                        onClick: lang.hitch(this, function(action, e){
    44                             action.callback && action.callback(e);
     44                            if ( action.callback ) { action.callback(e); }
    4545                            event.stop(e);
    4646                            return false;
     
    5656                        title: this.actions[action].properties.tooltip,
    5757                        onClick: lang.hitch(this, function(action, e){
    58                             action.callback && action.callback(e);
     58                            if ( action.callback ) { action.callback(e); }
    5959                            event.stop(e);
    6060                            return false;
     
    7575            return !preventDefault;
    7676        },
    77         onClick: function(e) {
     77        onClick: function(/*e*/) {
    7878        },
    7979        _setTitleAttr: function(value){
  • Dev/trunk/client/qed/widgets/MultipleChoiceWidget.js

    r417 r426  
    33    'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dijit/_Container',
    44    'dojo/text!./templates/MultipleChoiceWidget.html',
    5     'dijit/form/RadioButton','dijit/form/CheckBox','dijit/form/TextBox','dijit/form/Button'],
    6     function(declare,array,lang,domConstruct,registry,_WidgetBase,_TemplatedMixin,
    7         _WidgetsInTemplateMixin,_Container,
    8         templateString,RadioButton,CheckBox,TextBox,Button){
    9         return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
    10             templateString: templateString,
    11             multiple: true,
    12             baseClass: 'rftMultipleChoiceWidget',
    13            
    14             allowMultiple: false,
    15             name: '',
    16             value: null,
    17            
    18             _widgetCache: null,
    19             constuctor: function() {
    20                 this.inherited(arguments);
    21                 this.value = [];
    22                 this._widgetCache = {};
    23             },
    24             _setValueAttr: function(value) {
    25                 this.reset();
    26                 this.value = value;
    27                 array.forEach(this.value,lang.hitch(this,function(val){
    28                     this._addRow(val);
    29                 }));
    30             },
    31             _getValueAttr: function() {
    32                 var value = [];
    33                 registry.findWidgets(this.domNode).forEach(function(w){
    34                     w.isInstanceOf(TextBox) && value.push(w.get('value'));
    35                 });
    36                 this.value = value;
    37                 return value;
    38             },
    39             reset: function() {
    40                 this._removeWidgetsBelowNode(this.rows);
    41                 domConstruct.empty(this.rows);
    42             },
    43             _onAddRow: function() {
    44                 this._addRow();
    45             },
    46             _addRow: function(value,tagRow,pos) {
    47                 var row = domConstruct.create('div',{'class':'row'});
    48                 if ( this.allowMultiple ) {
    49                     new CheckBox({
    50                         name:this.name,
    51                         'class':'rowBox',
    52                         disabled: this.mode == 'edit'
    53                     }).placeAt(row);
    54                 } else {
    55                     new RadioButton({
    56                         name:this.name,
    57                         'class':'rowBox',
    58                         disabled: this.mode == 'edit'
    59                     }).placeAt(row);
    60                 }
    61                 new TextBox({
     5    'dijit/form/RadioButton','dijit/form/CheckBox','dijit/form/TextBox','dijit/form/Button'
     6], function(declare,array,lang,domConstruct,registry,_WidgetBase,_TemplatedMixin,
     7    _WidgetsInTemplateMixin,_Container, templateString,RadioButton,CheckBox,TextBox,Button){
     8    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
     9        templateString: templateString,
     10        multiple: true,
     11        baseClass: 'rftMultipleChoiceWidget',
     12       
     13        allowMultiple: false,
     14        name: '',
     15        value: null,
     16       
     17        _widgetCache: null,
     18        constuctor: function() {
     19            this.inherited(arguments);
     20            this.value = [];
     21            this._widgetCache = {};
     22        },
     23        _setValueAttr: function(value) {
     24            this.reset();
     25            this.value = value;
     26            array.forEach(this.value,lang.hitch(this,function(val){
     27                this._addRow(val);
     28            }));
     29        },
     30        _getValueAttr: function() {
     31            var value = [];
     32            registry.findWidgets(this.domNode).forEach(function(w){
     33                if ( w.isInstanceOf(TextBox) ) { value.push(w.get('value')); }
     34            });
     35            this.value = value;
     36            return value;
     37        },
     38        reset: function() {
     39            this._removeWidgetsBelowNode(this.rows);
     40            domConstruct.empty(this.rows);
     41        },
     42        _onAddRow: function() {
     43            this._addRow();
     44        },
     45        _addRow: function(value,tagRow,pos) {
     46            var row = domConstruct.create('div',{'class':'row'});
     47            if ( this.allowMultiple ) {
     48                new CheckBox({
    6249                    name:this.name,
    63                     value:value || '',
    64                     'class':'rowText'
     50                    'class':'rowBox',
     51                    disabled: this.mode === 'edit'
    6552                }).placeAt(row);
    66                 new Button({
    67                     label:'-',
    68                     'class':'rowBtn',
    69                     onClick:lang.hitch(this,'_removeNodeWithWidgets',row)
     53            } else {
     54                new RadioButton({
     55                    name:this.name,
     56                    'class':'rowBox',
     57                    disabled: this.mode === 'edit'
    7058                }).placeAt(row);
    71                 new Button({
    72                     label:'+',
    73                     'class':'rowBtn',
    74                     onClick:lang.hitch(this,'_addRow','',row,'before')
    75                 }).placeAt(row);
    76                 domConstruct.place(row,tagRow || this.rows,pos||'last');
    77             },
    78             _removeNodeWithWidgets: function(node) {
    79                 this._removeWidgetsBelowNode(node);
    80                 domConstruct.destroy(node);
    81             },
    82             _removeWidgetsBelowNode: function(node) {
    83                 registry.findWidgets(node).forEach(function(w){
    84                     w.destroyRecursive();
    85                 });
    86             },
    87             _onRowChange: function(row) {
    88                
    8959            }
    90         });
     60            new TextBox({
     61                name:this.name,
     62                value:value || '',
     63                'class':'rowText'
     64            }).placeAt(row);
     65            new Button({
     66                label:'-',
     67                'class':'rowBtn',
     68                onClick:lang.hitch(this,'_removeNodeWithWidgets',row)
     69            }).placeAt(row);
     70            new Button({
     71                label:'+',
     72                'class':'rowBtn',
     73                onClick:lang.hitch(this,'_addRow','',row,'before')
     74            }).placeAt(row);
     75            domConstruct.place(row,tagRow || this.rows,pos||'last');
     76        },
     77        _removeNodeWithWidgets: function(node) {
     78            this._removeWidgetsBelowNode(node);
     79            domConstruct.destroy(node);
     80        },
     81        _removeWidgetsBelowNode: function(node) {
     82            registry.findWidgets(node).forEach(function(w){
     83                w.destroyRecursive();
     84            });
     85        },
     86        _onRowChange: function(/*row*/) {}
    9187    });
     88});
  • Dev/trunk/client/qed/widgets/ObjectBox.js

    r417 r426  
    4343                line3Actions[action] = {
    4444                    callback: lang.hitch(this, function(callback){
    45                         this.value && callback(this.value);
     45                        if ( this.value ) { callback(this.value); }
    4646                    }, this.actions[action]),
    4747                    properties: {
     
    5454            return line3Actions;
    5555        },
    56         _showInfoBox: function() {
    57             alert(this.value.description);
    58         },
     56        _showInfoBox: function() {},
    5957        _setValueAttr: function(value) {
    6058            this.value = value;
  • Dev/trunk/client/qed/widgets/Selector.js

    r417 r426  
    7070                                        action.callback),
    7171                        properties: {
    72                              blockButton: true,
    73                              label: action.title || actionName,
    74                              icon: action.icon,
    75                              tooltip: action.description
    76                          }
     72                            blockButton: true,
     73                            label: action.title || actionName,
     74                            icon: action.icon,
     75                            tooltip: action.description
     76                        }
    7777
    7878                    };
     
    145145                this._folded = true;
    146146            }
    147             evt && event.stop(evt);
     147            if ( evt ) { event.stop(evt); }
    148148            return false;
    149149        },
     
    174174        },
    175175
    176         onSelect: function(item) {}
     176        onSelect: function(/*item*/) {}
    177177    });
    178178});
  • Dev/trunk/client/qed/widgets/ThresholdFilteringSelect.js

    r417 r426  
    44], function(declare, FilteringSelect) {
    55    return declare(FilteringSelect, {
    6          // custom min input character count to trigger search
    7          minKeyCount: 3,
     6        // custom min input character count to trigger search
     7        minKeyCount: 3,
    88
    9          // override search method, count the input length
    10          _startSearch: function (/*String*/key) {
    11              if (!key || key.length < this.minKeyCount) {
    12                  this.closeDropDown();
    13                  return;
    14              }
    15              this.inherited(arguments);
    16          }
     9        // override search method, count the input length
     10        _startSearch: function (/*String*/key) {
     11            if (!key || key.length < this.minKeyCount) {
     12                this.closeDropDown();
     13                return;
     14            }
     15            this.inherited(arguments);
     16        }
    1717    });
    1818});
  • Dev/trunk/client/qed/widgets/list/List.js

    r420 r426  
    5252            };
    5353        },
    54         _createListNode: function(item) {},
    55         _createAvatarNode: function(item) {},
     54        _createListNode: function(/*item*/) {},
     55        _createAvatarNode: function(/*item*/) {},
    5656
    5757        appendItem: function(item) {
     
    8686            .forEach(lang.hitch(this,function(node){
    8787                registry.byNode(node).destroyRecursive();
    88                 this.removeCallback && this.removeCallback(item);
     88                if ( this.removeCallback ) { this.removeCallback(item); }
    8989            }));
    9090            this.source.sync();
  • Dev/trunk/client/qed/widgets/list/OrderedList.js

    r407 r426  
    55    './List',
    66    'dojo/text!./templates/OrderedList.html'
    7     ],function(
    8         declare,
    9         lang,
    10         Button,
    11         List,
    12         templateString
    13         ){
    14         return declare([List],{
    15             templateString: templateString,
    16             baseClass: 'rftLineListView',
     7],function(
     8    declare,
     9    lang,
     10    Button,
     11    List,
     12    templateString
     13    ){
     14    return declare([List],{
     15        templateString: templateString,
     16        baseClass: 'rftLineListView',
    1717
    18             startup: function() {
    19                 if ( this._started ){ return; }
    20                 this.inherited(arguments);
     18        startup: function() {
     19            if ( this._started ){ return; }
     20            this.inherited(arguments);
    2121
    22                 new Button({
    23                     label: "Move up",
    24                     showLabel: false,
    25                     iconClass: "rftIcon rftIconFullArrowUp",
    26                     baseClass: "rftBlockButton",
    27                     'class': "trans",
    28                     onClick: lang.hitch(this, function() {
    29                         this._moveSelectedItem("up");
    30                     })
    31                 }, this.btnListMoveUp).startup();
     22            new Button({
     23                label: "Move up",
     24                showLabel: false,
     25                iconClass: "rftIcon rftIconFullArrowUp",
     26                baseClass: "rftBlockButton",
     27                'class': "trans",
     28                onClick: lang.hitch(this, function() {
     29                    this._moveSelectedItem("up");
     30                })
     31            }, this.btnListMoveUp).startup();
    3232
    33                 new Button({
    34                     label: "Move down",
    35                     showLabel: false,
    36                     iconClass: "rftIcon rftIconFullArrowDown",
    37                     baseClass: "rftBlockButton",
    38                     'class': "trans",
    39                     onClick: lang.hitch(this, function() {
    40                         this._moveSelectedItem("down");
    41                     })
    42                 }, this.btnListMoveDown).startup();
    43             },
     33            new Button({
     34                label: "Move down",
     35                showLabel: false,
     36                iconClass: "rftIcon rftIconFullArrowDown",
     37                baseClass: "rftBlockButton",
     38                'class': "trans",
     39                onClick: lang.hitch(this, function() {
     40                    this._moveSelectedItem("down");
     41                })
     42            }, this.btnListMoveDown).startup();
     43        },
    4444
    45             _moveSelectedItem: function(dir) {
    46                 var node = this.source.getSelectedNodes()[0];
    47                 if (node) {
    48                     if (dir === "up") {
    49                         if (node.previousSibling) {
    50                             return node.parentNode.insertBefore(node, node.previousSibling);
    51                         } else {
    52                             return false;
    53                         }
     45        _moveSelectedItem: function(dir) {
     46            var node = this.source.getSelectedNodes()[0];
     47            if (node) {
     48                if (dir === "up") {
     49                    if (node.previousSibling) {
     50                        return node.parentNode.insertBefore(node, node.previousSibling);
     51                    } else {
     52                        return false;
     53                    }
    5454
    55                     } else if (dir === "down") {
    56                         if (node.nextSibling) {
    57                             return node.parentNode.insertBefore(node.nextSibling, node);
    58                         } else {
    59                             return false;
    60                         }
     55                } else if (dir === "down") {
     56                    if (node.nextSibling) {
     57                        return node.parentNode.insertBefore(node.nextSibling, node);
    6158                    } else {
    62                         throw "Invalid move direction passed!";
     59                        return false;
    6360                    }
    6461                } else {
    65                     return false;
     62                    throw "Invalid move direction passed!";
    6663                }
    67             },
     64            } else {
     65                return false;
     66            }
     67        },
    6868
    69             insertItem: function(item) {
    70                 var anchor = this.source.getSelectedNodes()[0];
    71                 if (anchor) {
    72                     this.source.insertNodes(false,[item], false, anchor);
    73                 } else {
    74                     this.appendItem(item);
    75                 }
     69        insertItem: function(item) {
     70            var anchor = this.source.getSelectedNodes()[0];
     71            if (anchor) {
     72                this.source.insertNodes(false,[item], false, anchor);
     73            } else {
     74                this.appendItem(item);
    7675            }
     76        }
    7777
    78         });
    7978    });
     79});
  • Dev/trunk/client/qed/widgets/list/_EditableListMixin.js

    r407 r426  
    99            .map(function(node){
    1010                var value = registry.byId(node.id).get('value');
    11                 this.source.setItem(node.id, value)
     11                this.source.setItem(node.id, value);
    1212                return value;
    1313            },this);
Note: See TracChangeset for help on using the changeset viewer.