From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../emberjs/app/components/todo-item.js | 49 ++++++++++++++++++++++ .../emberjs/app/components/todo-list.js | 28 +++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-item.js create mode 100644 third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-list.js (limited to 'third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components') diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-item.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-item.js new file mode 100644 index 0000000000..0de7fbf116 --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-item.js @@ -0,0 +1,49 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + repo: Ember.inject.service(), + tagName: 'li', + editing: false, + classNameBindings: ['todo.completed', 'editing'], + + actions: { + startEditing() { + this.get('onStartEdit')(); + this.set('editing', true); + Ember.run.scheduleOnce('afterRender', this, 'focusInput'); + }, + + doneEditing(todoTitle) { + if (!this.get('editing')) { return; } + if (Ember.isBlank(todoTitle)) { + this.send('removeTodo'); + } else { + this.set('todo.title', todoTitle.trim()); + this.set('editing', false); + this.get('onEndEdit')(); + } + }, + + handleKeydown(e) { + if (e.keyCode === 13) { + e.target.blur(); + } else if (e.keyCode === 27) { + this.set('editing', false); + } + }, + + toggleCompleted(e) { + let todo = this.get('todo'); + Ember.set(todo, 'completed', e.target.checked); + this.get('repo').persist(); + }, + + removeTodo() { + this.get('repo').delete(this.get('todo')); + } + }, + + focusInput() { + this.element.querySelector('input.edit').focus(); + } +}); diff --git a/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-list.js b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-list.js new file mode 100644 index 0000000000..cd8183cfac --- /dev/null +++ b/third_party/webkit/PerformanceTests/Speedometer/resources/todomvc/architecture-examples/emberjs/app/components/todo-list.js @@ -0,0 +1,28 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + repo: Ember.inject.service(), + tagName: 'section', + elementId: 'main', + classNames: ['main'], + canToggle: true, + allCompleted: Ember.computed('todos.@each.completed', function () { + return this.get('todos').isEvery('completed'); + }), + + actions: { + enableToggle() { + this.set('canToggle', true); + }, + + disableToggle() { + this.set('canToggle', false); + }, + + toggleAll() { + let allCompleted = this.get('allCompleted'); + this.get('todos').forEach(todo => Ember.set(todo, 'completed', !allCompleted)); + this.get('repo').persist(); + } + } +}); -- cgit v1.2.3