$(document).trigger('drupalEditorFeatureModified', feature);
},
featureIsAllowedByFilters: function featureIsAllowedByFilters(feature) {
+ function emptyProperties(section) {
+ return section.attributes.length === 0 && section.classes.length === 0 && section.styles.length === 0;
+ }
+
function generateUniverseFromFeatureRequirements(feature) {
var properties = ['attributes', 'styles', 'classes'];
var universe = {};
return universe;
}
- function emptyProperties(section) {
- return section.attributes.length === 0 && section.classes.length === 0 && section.styles.length === 0;
- }
-
- function findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing) {
- if (tag === '*') {
- return findPropertyValuesOnAllTags(universe, property, propertyValues, allowing);
- }
-
- var atLeastOneFound = false;
- _.each(propertyValues, function (propertyValue) {
- if (findPropertyValueOnTag(universe, tag, property, propertyValue, allowing)) {
- atLeastOneFound = true;
- }
- });
- return atLeastOneFound;
- }
-
- function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) {
- var atLeastOneFound = false;
- _.each(_.keys(universe), function (tag) {
- if (findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing)) {
- atLeastOneFound = true;
- }
- });
- return atLeastOneFound;
- }
-
function findPropertyValueOnTag(universe, tag, property, propertyValue, allowing) {
if (!_.has(universe, tag)) {
return false;
return atLeastOneFound;
}
- function deleteFromUniverseIfAllowed(universe, tag) {
+ function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) {
+ var atLeastOneFound = false;
+ _.each(_.keys(universe), function (tag) {
+ if (findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing)) {
+ atLeastOneFound = true;
+ }
+ });
+ return atLeastOneFound;
+ }
+
+ function findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing) {
if (tag === '*') {
- return deleteAllTagsFromUniverseIfAllowed(universe);
- }
- if (_.has(universe, tag) && _.every(_.omit(universe[tag], 'touchedByAllowedPropertyRule'))) {
- delete universe[tag];
- return true;
+ return findPropertyValuesOnAllTags(universe, property, propertyValues, allowing);
}
- return false;
+
+ var atLeastOneFound = false;
+ _.each(propertyValues, function (propertyValue) {
+ if (findPropertyValueOnTag(universe, tag, property, propertyValue, allowing)) {
+ atLeastOneFound = true;
+ }
+ });
+ return atLeastOneFound;
}
function deleteAllTagsFromUniverseIfAllowed(universe) {
return atLeastOneDeleted;
}
+ function deleteFromUniverseIfAllowed(universe, tag) {
+ if (tag === '*') {
+ return deleteAllTagsFromUniverseIfAllowed(universe);
+ }
+ if (_.has(universe, tag) && _.every(_.omit(universe[tag], 'touchedByAllowedPropertyRule'))) {
+ delete universe[tag];
+ return true;
+ }
+ return false;
+ }
+
function anyForbiddenFilterRuleMatches(universe, filterStatus) {
var properties = ['attributes', 'styles', 'classes'];
}
Drupal.filterConfiguration.update();
-
- for (var filterID in Drupal.filterConfiguration.statuses) {
- if (Drupal.filterConfiguration.statuses.hasOwnProperty(filterID)) {
- var filterStatus = Drupal.filterConfiguration.statuses[filterID];
- if (!filterStatusAllowsFeature(filterStatus, feature)) {
- return false;
- }
- }
- }
-
- return true;
+ return Object.keys(Drupal.filterConfiguration.statuses).every(function (filterID) {
+ return filterStatusAllowsFeature(Drupal.filterConfiguration.statuses[filterID], feature);
+ });
}
};
Drupal.EditorFeatureHTMLRule = function () {
- this.required = { tags: [], attributes: [], styles: [], classes: [] };
+ this.required = {
+ tags: [],
+ attributes: [],
+ styles: [],
+ classes: []
+ };
- this.allowed = { tags: [], attributes: [], styles: [], classes: [] };
+ this.allowed = {
+ tags: [],
+ attributes: [],
+ styles: [],
+ classes: []
+ };
this.raw = null;
};