Skip to content

Commit

Permalink
encode/decode images directives
Browse files Browse the repository at this point in the history
  • Loading branch information
empiricompany authored and fballiano committed Jul 21, 2023
1 parent 1f98220 commit 1069158
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 358 deletions.
46 changes: 44 additions & 2 deletions js/mage/adminhtml/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com)
* @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
// from http://www.someelement.com/2007/03/eventpublisher-custom-events-la-pubsub.html
varienEvents = Class.create();

varienEvents.prototype = {
Expand Down Expand Up @@ -120,7 +119,50 @@ varienEvents.prototype = {
}
}
return results;
}
},

/**
* Collect and modify value of arg synchronously in succession and return its new value.
* In order to use, call attachEventHandler and add function handlers with eventName.
* Then call fireEventReducer with eventName and any argument to have its value accumulatively modified.
* Event handlers will be applied to argument in order of first attached to last attached.
* @param {String} eventName
* @param {*} arg
*/
fireEventReducer: function (eventName, arg) {
var evtName = eventName + this.eventPrefix,
result = arg,
len,
i;

if (!this.arrEvents[evtName]) {
return result;
}

len = this.arrEvents[evtName].length; //optimization

for (i = 0; i < len; i++) {
/* eslint-disable max-depth */
try {
result = this.arrEvents[evtName][i].method(result);
} catch (e) {
if (this.id) {
alert({
content: 'error: error in ' + this.id + '.fireEventReducer():\n\nevent name: ' +
eventName + '\n\nerror message: ' + e.message
});
} else {
alert({
content: 'error: error in [unknown object].fireEventReducer():\n\nevent name: ' +
eventName + '\n\nerror message: ' + e.message
});
}
}
/* eslint-disable max-depth */
}

return result;
},
};

varienGlobalEvents = new varienEvents();
Expand Down
Loading

0 comments on commit 1069158

Please sign in to comment.