Переглянути джерело

More linting on select2/*

Kevin Brown 10 роки тому
батько
коміт
981432ee89
5 змінених файлів з 50 додано та 48 видалено
  1. 1 0
      .jshintrc
  2. 25 24
      src/js/select2/core.js
  3. 2 2
      src/js/select2/dropdown.js
  4. 1 1
      src/js/select2/options.js
  5. 21 21
      src/js/select2/results.js

+ 1 - 0
.jshintrc

@@ -1,5 +1,6 @@
 {
   "bitwise": true,
+  "eqnull": true,
   "globals": {
     "define": true
   },

+ 25 - 24
src/js/select2/core.js

@@ -8,7 +8,7 @@ define([
 
     options = options || {};
 
-    options.multiple = options.multiple || $element.prop("multiple");
+    options.multiple = options.multiple || $element.prop('multiple');
 
     this.options = new Options(options);
 
@@ -27,21 +27,22 @@ define([
 
     this.selection = new this.options.selectionAdapter($element, this.options);
 
-    var $selectionContainer = $container.find(".selection");
+    var $selectionContainer = $container.find('.selection');
     var $selection = this.selection.render();
 
     $selectionContainer.append($selection);
 
     this.dropdown = new this.options.dropdownAdapter($element, this.options);
 
-    var $dropdownContainer = $container.find(".dropdown");
+    var $dropdownContainer = $container.find('.dropdown');
     var $dropdown = this.dropdown.render();
 
     $dropdownContainer.append($dropdown);
 
-    this.results = new this.options.resultsAdapter($element, this.options, this.data);
+    this.results = new this.options.resultsAdapter(
+      $element, this.options, this.data);
 
-    var $resultsContainer = $dropdown.find(".results");
+    var $resultsContainer = $dropdown.find('.results');
     var $results = this.results.render();
 
     $resultsContainer.append($results);
@@ -54,48 +55,48 @@ define([
     this.selection.bind(this, $container);
     this.results.bind(this, $container);
 
-    this.$element.on("change", function () {
+    this.$element.on('change', function () {
       self.data.current(function (data) {
-        self.trigger("selection:update", {
+        self.trigger('selection:update', {
           data: data
         });
       });
     });
 
-    this.selection.on("toggle", function () {
+    this.selection.on('toggle', function () {
       self.toggleDropdown();
     });
 
-    this.results.on("selected", function (params) {
-      self.trigger("select", params);
+    this.results.on('selected', function (params) {
+      self.trigger('select', params);
 
-      self.trigger("close");
+      self.trigger('close');
     });
 
-    this.results.on("unselected", function (params) {
-      self.trigger("unselect", params);
+    this.results.on('unselected', function (params) {
+      self.trigger('unselect', params);
 
-      self.trigger("close");
+      self.trigger('close');
     });
 
-    this.on("open", function () {
-      $container.addClass("open");
+    this.on('open', function () {
+      $container.addClass('open');
     });
 
-    this.on("close", function () {
-      $container.removeClass("open");
+    this.on('close', function () {
+      $container.removeClass('open');
     });
 
     // Set the initial state
 
     this.data.current(function (initialData) {
-      self.trigger("selection:update", {
+      self.trigger('selection:update', {
         data: initialData
       });
     });
 
     this.data.query({}, function (data) {
-      self.results.trigger("results:all", data);
+      self.results.trigger('results:all', data);
     });
 
     // Hide the original select
@@ -106,12 +107,12 @@ define([
   Utils.Extend(Select2, Utils.Observable);
 
   Select2.prototype.toggleDropdown = function () {
-    if (this.$container.hasClass("open")) {
-      this.trigger("close");
+    if (this.$container.hasClass('open')) {
+      this.trigger('close');
     } else {
-      this.trigger("open");
+      this.trigger('open');
     }
-  }
+  };
 
   Select2.prototype.render = function () {
     var $container = $(

+ 2 - 2
src/js/select2/dropdown.js

@@ -15,7 +15,7 @@ define([
     );
 
     return $dropdown;
-  }
+  };
 
   return Dropdown;
-})
+});

+ 1 - 1
src/js/select2/options.js

@@ -27,4 +27,4 @@ define([
   }
 
   return Options;
-})
+});

+ 21 - 21
src/js/select2/results.js

@@ -44,16 +44,16 @@ define([
     this.data.current(function (selected) {
       selected = $.map(selected, function (s) { return s.id; });
 
-      self.$results.find(".option.selected").removeClass("selected");
+      self.$results.find('.option.selected').removeClass('selected');
 
-      var $options = self.$results.find(".option");
+      var $options = self.$results.find('.option');
 
       $options.each(function () {
         var $option = $(this);
-        var item = $option.data("data");
+        var item = $option.data('data');
 
         if (selected.indexOf(item.id) > -1) {
-          $option.addClass("selected");
+          $option.addClass('selected');
         }
       });
     });
@@ -65,43 +65,43 @@ define([
     );
 
     $option.html(data.text);
-    $option.data("data", data);
+    $option.data('data', data);
 
     return $option;
-  }
+  };
 
   Results.prototype.bind = function (container, $container) {
     var self = this;
 
-    this.on("results:all", function (data) {
+    this.on('results:all', function (data) {
       self.clear();
       self.append(data);
 
       self.setClasses();
     });
 
-    this.on("results:append", function (data) {
+    this.on('results:append', function (data) {
       self.append(data);
 
       self.setClasses();
-    })
+    });
 
-    this.$results.on("mouseup", ".option", function (evt) {
+    this.$results.on('mouseup', '.option', function (evt) {
       var $this = $(this);
 
-      var data = $this.data("data");
-      if ($this.hasClass("selected")) {
-        self.trigger("unselected", {
+      var data = $this.data('data');
+      if ($this.hasClass('selected')) {
+        self.trigger('unselected', {
           originalEvent: evt,
           data: data
-        })
+        });
 
         self.setClasses();
 
         return;
       }
 
-      self.trigger("selected", {
+      self.trigger('selected', {
         originalEvent: evt,
         data: data
       });
@@ -109,15 +109,15 @@ define([
       self.setClasses();
     });
 
-    this.$results.on("mouseenter", ".option", function (evt) {
-      self.$results.find(".option.highlighted").removeClass("highlighted");
-      $(this).addClass("highlighted");
+    this.$results.on('mouseenter', '.option', function (evt) {
+      self.$results.find('.option.highlighted').removeClass('highlighted');
+      $(this).addClass('highlighted');
     });
 
-    this.$results.on("mouseleave", ".option", function (evt) {
-      $(this).removeClass("highlighted");
+    this.$results.on('mouseleave', '.option', function (evt) {
+      $(this).removeClass('highlighted');
     });
   };
 
   return Results;
-})
+});