Commit 628b3f4e authored by Alexander Alekseev's avatar Alexander Alekseev Committed by Commit Bot

ui/login/screen.js : Remove unused methods.

Remove unused:
* declareButton
* declareUserAction

Remove support for HTMLelement attributes:
* <div alias="myDiv"> - remove support for alias=
* <button action="cancel"> - remove support for generating UserAction events
  for buttons having action= attribute.

Bug: 926638
Change-Id: I2c33a7eb375e03deb9bf7f70e176c970de9bf8da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1519447
Commit-Queue: Alexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#650566}
parent 24cf5a0f
......@@ -59,56 +59,6 @@ cr.define('login', function() {
return this.sendImpl_.apply(this, arguments);
},
/**
* Creates and returns new button element with given identifier
* and on-click event listener, which sends notification about
* user action to the C++ side.
*
* @param {string} id Identifier of a button.
* @param {string} opt_action_id Identifier of user action.
* @final
*/
declareButton: function(id, opt_action_id) {
var button = this.ownerDocument.createElement('button');
button.id = id;
this.declareUserAction(button,
{ action_id: opt_action_id,
event: 'click'
});
return button;
},
/**
* Adds event listener to an element which sends notification
* about event to the C++ side.
*
* @param {Element} element An DOM element
* @param {Object} options A dictionary of optional arguments:
* {string} event: name of event that will be listened,
* default: 'click'.
* {string} action_id: name of an action which will be sent to
* the C++ side.
* {function} condition: a one-argument function which takes
* event as an argument, notification is sent to the
* C++ side iff condition is true, default: constant
* true function.
* @final
*/
declareUserAction: function(element, options) {
var self = this;
options = options || {};
var event = options.event || 'click';
var action_id = options.action_id || element.id;
var condition = options.condition || alwaysTruePredicate;
element.addEventListener(event, function(e) {
if (condition(e))
self.sendImpl_(CALLBACK_USER_ACTED, action_id);
e.stopPropagation();
});
},
/**
* @override
* @final
......@@ -118,34 +68,10 @@ cr.define('login', function() {
},
/**
* Does the following things:
* * Looks for elements having "alias" property and adds them as the
* proprties of the screen with name equal to value of "alias", i.e. HTML
* element <div alias="myDiv"></div> will be stored in this.myDiv.
* * Looks for buttons having "action" properties and adds click handlers
* to them. These handlers send |CALLBACK_USER_ACTED| messages to
* C++ with "action" property's value as payload.
* @private
*/
initializeImpl_: function() {
this.decorate();
this.querySelectorAllImpl_('[alias]').forEach(function(element) {
var alias = element.getAttribute('alias');
if (alias in this)
throw Error('Alias "' + alias + '" of "' + this.name() + '" screen ' +
'shadows or redefines property that is already defined.');
this[alias] = element;
this[element.getAttribute('alias')] = element;
}, this);
var self = this;
this.querySelectorAllImpl_('button[action]').forEach(function(button) {
button.addEventListener('click', function(e) {
var action = this.getAttribute('action');
self.send(CALLBACK_USER_ACTED, action);
e.stopPropagation();
});
});
},
/**
......
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