Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: chrome/browser/resources/options2/settings_dialog.js

Issue 10809005: Options: Rename chrome/browser/resources/options2 -> chrome/browser/resources/options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6 * @fileoverview Base class for dialogs that require saving preferences on
7 * confirm and resetting preference inputs on cancel.
8 */
9
10 cr.define('options', function() {
11 /** @const */ var OptionsPage = options.OptionsPage;
12
13 /**
14 * Base class for settings dialogs.
15 * @constructor
16 * @param {string} name See OptionsPage constructor.
17 * @param {string} title See OptionsPage constructor.
18 * @param {string} pageDivName See OptionsPage constructor.
19 * @param {HTMLInputElement} okButton The confirmation button element.
20 * @param {HTMLInputElement} cancelButton The cancellation button element.
21 * @extends {OptionsPage}
22 */
23 function SettingsDialog(name, title, pageDivName, okButton, cancelButton) {
24 OptionsPage.call(this, name, title, pageDivName);
25 this.okButton = okButton;
26 this.cancelButton = cancelButton;
27 }
28
29 SettingsDialog.prototype = {
30 __proto__: OptionsPage.prototype,
31
32 /**
33 * @inheritDoc
34 */
35 initializePage: function() {
36 this.okButton.onclick = this.handleConfirm.bind(this);
37 this.cancelButton.onclick = this.handleCancel.bind(this);
38 },
39
40 /**
41 * Handles the confirm button by saving the dialog preferences.
42 */
43 handleConfirm: function() {
44 OptionsPage.closeOverlay();
45
46 var els = this.pageDiv.querySelectorAll('[dialog-pref]');
47 for (var i = 0; i < els.length; i++) {
48 if (els[i].savePrefState)
49 els[i].savePrefState();
50 }
51 },
52
53 /**
54 * Handles the cancel button by closing the overlay.
55 */
56 handleCancel: function() {
57 OptionsPage.closeOverlay();
58
59 var els = this.pageDiv.querySelectorAll('[dialog-pref]');
60 for (var i = 0; i < els.length; i++) {
61 if (els[i].resetPrefState)
62 els[i].resetPrefState();
63 }
64 },
65 };
66
67 return {
68 SettingsDialog: SettingsDialog
69 };
70 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/search_page.js ('k') | chrome/browser/resources/options2/spelling_confirm_overlay.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698