Commit 9868f953 authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2872090 by borisson_: Update javascript coding standards

parent c8e1d683
......@@ -5,7 +5,7 @@
(function ($) {
"use strict";
'use strict';
Drupal.facets = Drupal.facets || {};
Drupal.behaviors.facetsCheckboxWidget = {
......@@ -22,7 +22,7 @@
var $links = $('.js-facets-checkbox-links .facet-item a');
$links.once('facets-checkbox-transform').each(Drupal.facets.makeCheckbox);
// Set indeterminate value on parents having an active trail.
$('.facet-item--expanded.facet-item--active-trail > input').prop("indeterminate", true);
$('.facet-item--expanded.facet-item--active-trail > input').prop('indeterminate', true);
};
/**
......@@ -57,6 +57,9 @@
/**
* Disable all facet checkboxes in the facet and apply a 'disabled' class.
*
* @param {object} $facet
* jQuery object of the facet.
*/
Drupal.facets.disableFacet = function ($facet) {
$facet.addClass('facets-disabled');
......@@ -66,9 +69,12 @@
/**
* Event listener for easy prevention of event propagation.
*
* @param {object} e
* Event.
*/
Drupal.facets.preventDefault = function (e) {
e.preventDefault();
}
};
})(jQuery);
......@@ -16,6 +16,11 @@
/**
* Turns all facet links into a dropdown with options for every link.
*
* @param {object} context
* Context.
* @param {object} settings
* Settings.
*/
Drupal.facets.makeDropdown = function (context, settings) {
// Find all dropdown facet links and turn them into an option.
......
......@@ -5,7 +5,7 @@
(function ($) {
"use strict";
'use strict';
Drupal.behaviors.facetsEditForm = {
attach: function (context, settings) {
......@@ -16,7 +16,7 @@
$('#edit-name').val(default_name);
setTimeout(function () { $('#edit-name').trigger('change'); }, 100);
})
});
}
};
......
......@@ -5,7 +5,7 @@
(function ($) {
"use strict";
'use strict';
Drupal.behaviors.facetsIndexFormatter = {
attach: function (context, settings) {
......
......@@ -5,14 +5,14 @@
(function ($) {
"use strict";
'use strict';
Drupal.behaviors.facetSoftLimit = {
attach: function (context, settings) {
if (settings.facets.softLimit != undefined) {
if (settings.facets.softLimit !== undefined) {
$.each(settings.facets.softLimit, function (facet, limit) {
Drupal.facets.applySoftLimit(facet, limit);
})
});
}
}
};
......@@ -21,6 +21,11 @@
/**
* Applies the soft limit UI feature to a specific facets list.
*
* @param {string} facet
* The facet id.
* @param {string} limit
* The maximum amount of items to show.
*/
Drupal.facets.applySoftLimit = function (facet, limit) {
var zero_based_limit = limit - 1;
......
......@@ -4,23 +4,23 @@
*/
(function ($) {
"use strict";
'use strict';
Drupal.facets = Drupal.facets || {};
Drupal.behaviors.facet_slider = {
attach: function (context, settings) {
if (settings.facets != undefined && settings.facets.sliders != undefined) {
if (settings.facets !== undefined && settings.facets.sliders !== undefined) {
$.each(settings.facets.sliders, function (facet, settings) {
Drupal.facets.addSlider(facet, settings);
})
});
}
}
};
Drupal.facets.addSlider = function (facet, settings) {
var defaults = {
stop: function(event, ui) {
stop: function (event, ui) {
if (settings.range) {
window.location.href = settings.url.replace('__range_slider_min__', ui.values[0]).replace('__range_slider_max__', ui.values[1]);
}
......@@ -32,16 +32,16 @@
$.extend(defaults, settings);
$("#" + facet).slider(defaults)
.slider("pips", {
$('#' + facet).slider(defaults)
.slider('pips', {
prefix: settings.prefix,
suffix: settings.suffix
})
.slider("float", {
.slider('float', {
prefix: settings.prefix,
suffix: settings.suffix,
labels: settings.labels
})
}
});
};
})(jQuery);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment