MDL-54944 js: Remove uncessary bind() calls
authorDan Poltawski <dan@moodle.com>
Tue, 28 Jun 2016 21:34:44 +0000 (22:34 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 7 Jul 2016 11:11:06 +0000 (12:11 +0100)
Most of these cases, we are already capturing this in a temporary
variable, so the bind becomes uncessary.

Discovered by http://eslint.org/docs/rules/no-extra-bind

admin/tool/lp/amd/src/actionselector.js
admin/tool/lp/amd/src/competencyactions.js
admin/tool/lp/amd/src/competencypicker.js
admin/tool/lp/amd/src/competencypicker_user_plans.js
admin/tool/lp/amd/src/grade_user_competency_inline.js
admin/tool/lp/amd/src/parentcompetency_form.js
admin/tool/lp/amd/src/planactions.js
admin/tool/lp/amd/src/scaleconfig.js
admin/tool/lp/amd/src/user_evidence_actions.js
lib/amd/src/fragment.js
mod/assign/amd/src/grading_navigation.js

index 396ac78..582478b 100644 (file)
@@ -87,13 +87,13 @@ define(['jquery',
             self._selectedValue = $("input[type='radio']:checked").val();
             self._find('[data-action="action-selector-confirm"]').removeAttr('disabled');
             self._refresh.bind(self);
-        }.bind(self));
+        });
 
         // Add listener for cancel.
         self._find('[data-action="action-selector-cancel"]').click(function(e) {
             e.preventDefault();
             self.close();
-        }.bind(self));
+        });
 
         // Add listener for confirm.
         self._find('[data-action="action-selector-confirm"]').click(function(e) {
@@ -103,7 +103,7 @@ define(['jquery',
             }
             self._trigger('save', {action: self._selectedValue});
             self.close();
-        }.bind(self));
+        });
     };
 
     /**
@@ -131,7 +131,7 @@ define(['jquery',
                 html,
                 self._afterRender.bind(self)
             );
-        }.bind(self)).fail(Notification.exception);
+        }).fail(Notification.exception);
     };
 
     /**
@@ -156,7 +156,7 @@ define(['jquery',
         return self._render().then(function(html) {
             self._find('[data-region="action-selector"]').replaceWith(html);
             self._afterRender();
-        }.bind(self));
+        });
     };
 
     /**
index a3fa8fa..c0943c0 100644 (file)
@@ -608,8 +608,8 @@ define(['jquery',
             templates.render('tool_lp/related_competencies', context).done(function(html) {
                 $('[data-region="relatedcompetencies"]').replaceWith(html);
                 updatedRelatedCompetencies();
-            }.bind(this)).fail(notification.exception);
-        }.bind(this)).fail(notification.exception);
+            }).fail(notification.exception);
+        }).fail(notification.exception);
     };
 
     /**
index 31dc47d..28c4ce3 100644 (file)
@@ -118,7 +118,7 @@ define(['jquery',
                 if (valid) {
                     validIds.push(compId);
                 }
-            }.bind(self));
+            });
 
             self._selectedCompetencies = validIds;
 
@@ -128,14 +128,14 @@ define(['jquery',
             } else {
                 self._find('[data-region="competencylinktree"] [data-action="add"]').removeAttr('disabled');
             }
-        }.bind(self));
+        });
 
         // Add listener for framework change.
         if (!self._singleFramework) {
             self._find('[data-action="chooseframework"]').change(function(e) {
                 self._frameworkId = $(e.target).val();
                 self._loadCompetencies().then(self._refresh.bind(self));
-            }.bind(self));
+            });
         }
 
         // Add listener for search.
@@ -146,13 +146,13 @@ define(['jquery',
             return self._refresh().always(function() {
                 $(e.target).removeAttr('disabled');
             });
-        }.bind(self));
+        });
 
         // Add listener for cancel.
         self._find('[data-region="competencylinktree"] [data-action="cancel"]').click(function(e) {
             e.preventDefault();
             self.close();
-        }.bind(self));
+        });
 
         // Add listener for add.
         self._find('[data-region="competencylinktree"] [data-action="add"]').click(function(e) {
@@ -169,7 +169,7 @@ define(['jquery',
             }
 
             self.close();
-        }.bind(self));
+        });
 
         // The list of selected competencies will be modified while looping (because of the listeners above).
         var currentItems = self._selectedCompetencies.slice(0);
@@ -180,7 +180,7 @@ define(['jquery',
                 tree.toggleItem(node);
                 tree.updateFocus(node);
             }
-        }.bind(self));
+        });
 
     };
 
@@ -210,8 +210,8 @@ define(['jquery',
                     html,
                     self._afterRender.bind(self)
                 );
-            }.bind(self));
-        }.bind(self)).fail(Notification.exception);
+            });
+        }).fail(Notification.exception);
     };
 
     /**
@@ -261,7 +261,7 @@ define(['jquery',
 
             self._competencies = tree;
 
-        }.bind(self)).fail(Notification.exception);
+        }).fail(Notification.exception);
     };
 
     /**
@@ -373,7 +373,7 @@ define(['jquery',
             }
 
             return self._loadCompetencies();
-        }.bind(self));
+        });
     };
 
     /**
@@ -387,7 +387,7 @@ define(['jquery',
         return self._render().then(function(html) {
             self._find('[data-region="competencylinktree"]').replaceWith(html);
             self._afterRender();
-        }.bind(self));
+        });
     };
 
     /**
@@ -419,7 +419,7 @@ define(['jquery',
             };
 
             return Templates.render('tool_lp/competency_picker', context);
-        }.bind(self));
+        });
     };
 
     /**
index c1afb13..8046c29 100644 (file)
@@ -78,7 +78,7 @@ define(['jquery',
             self._find('[data-action="chooseplan"]').change(function(e) {
                 self._planId = $(e.target).val();
                 self._loadCompetencies().then(self._refresh.bind(self));
-            }.bind(self));
+            });
         }
     };
 
@@ -200,7 +200,7 @@ define(['jquery',
             }
 
             return self._loadCompetencies();
-        }.bind(self));
+        });
     };
 
     /**
@@ -232,7 +232,7 @@ define(['jquery',
             };
 
             return Templates.render('tool_lp/competency_picker_user_plans', context);
-        }.bind(self));
+        });
     };
 
     return /** @alias module:tool_lp/competencypicker_user_plans */ Picker;
index 412cf2a..7a030b6 100644 (file)
@@ -119,10 +119,10 @@ define(['jquery',
                     args: args,
                     done: function(evidence) {
                         self._trigger('competencyupdated', {args: args, evidence: evidence});
-                    }.bind(self),
+                    },
                     fail: notification.exception
                 }]);
-            }.bind(self));
+            });
         }).fail(notification.exception);
     };
 
index 8a26d75..705ab29 100644 (file)
@@ -112,13 +112,13 @@ define(['jquery', 'core/ajax', 'core/str', 'tool_lp/competencypicker', 'core/tem
                     };
 
                     return Templates.render('tool_lp/competency_picker_competencyform', context);
-                }.bind(self));
+                });
             };
 
             // On selected competency.
             picker.on('save', function(e, data) {
                 self.setParent(data);
-            }.bind(self));
+            });
 
             picker.display();
         });
index d959f66..5e1ee24 100644 (file)
@@ -117,7 +117,7 @@ define(['jquery',
             .done(function(newhtml, newjs) {
                 $(self._region).replaceWith(newhtml);
                 templates.runTemplateJS(newjs);
-            }.bind(self))
+            })
             .fail(notification.exception);
     };
 
@@ -186,7 +186,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doDelete(planData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
@@ -233,7 +233,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doReopenPlan(planData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
@@ -280,7 +280,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doCompletePlan(planData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
@@ -326,7 +326,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doUnlinkPlan(planData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
index 48afdc6..67c41ee 100644 (file)
@@ -140,7 +140,7 @@ define(['jquery', 'core/notification', 'core/templates', 'core/ajax', 'tool_lp/d
         }.bind(this));
         body.on('click', '[data-action="cancel"]', function() {
             popup.close();
-        }.bind(this));
+        });
     };
 
     /**
index 838230f..174c47e 100644 (file)
@@ -104,7 +104,7 @@ define(['jquery',
         templates.render(self._template, context)
             .done(function(newhtml, newjs) {
                 templates.replaceNode($(self._region), newhtml, newjs);
-            }.bind(self))
+            })
             .fail(notification.exception);
     };
 
@@ -173,7 +173,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doDelete(evidenceData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
@@ -227,7 +227,7 @@ define(['jquery',
         picker.on('save', function(e, data) {
             var competencyIds = data.competencyIds;
             self._doCreateUserEvidenceCompetency(evidenceData, competencyIds, data.requestReview);
-        }.bind(self));
+        });
 
         picker.display();
     };
@@ -328,7 +328,7 @@ define(['jquery',
                     strings[3], // Cancel.
                     function() {
                         self._doReviewUserEvidenceCompetencies(evidenceData);
-                    }.bind(self)
+                    }
                 );
             }).fail(notification.exception);
         }).fail(notification.exception);
index f12e49a..28627fc 100644 (file)
@@ -109,7 +109,7 @@ define(['jquery', 'core/ajax'], function($, ajax) {
                             allScript += ' ' + scriptNode.text();
                         }
                     }
-                }.bind(this));
+                });
                 promise.resolve(data.html, allScript);
             }).fail(function(ex) {
                 promise.reject(ex);
index 997db9a..b284435 100644 (file)
@@ -64,7 +64,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
 
         str.get_string('changeuser', 'mod_assign').done(function(s) {
                 autocomplete.enhance('[data-action=change-user]', false, 'mod_assign/participant_selector', s);
-            }.bind(this)
+            }
         ).fail(notification.exception);
 
         // We do not allow navigation while ajax requests are pending.
@@ -180,7 +180,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
             if ($(ele).prop('checked')) {
                 filterlist[filterlist.length] = $(ele).closest('label').text();
             }
-        }.bind(this));
+        });
         if (filterlist.length) {
             this._region.find('[data-region="user-filters"] span').text(filterlist.join(', '));
         } else {
@@ -213,7 +213,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
                         show = false;
                     }
                 }
-            }.bind(this));
+            });
 
             if (show) {
                 this._filteredUsers[this._filteredUsers.length] = user;
@@ -252,7 +252,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
                 notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
                     $(document).trigger('save-changes', -1);
                 });
-            }.bind(this));
+            });
         } else {
             $(document).trigger('user-changed', -1);
         }
@@ -284,7 +284,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
                 notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
                     $(document).trigger('save-changes', useridnumber);
                 });
-            }.bind(this));
+            });
         } else {
             select.attr('data-selected', userid);
 
@@ -456,7 +456,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
                 notification.confirm(strs[0], strs[1], strs[2], strs[3], function() {
                     $(document).trigger('save-changes', userid);
                 });
-            }.bind(this));
+            });
         } else {
             if (!isNaN(userid) && userid > 0) {
                 select.attr('data-selected', userid);