OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be found | |
3 // in the LICENSE file. | |
4 | |
5 /** | |
6 * @fileoverview This file contains the JavaScript required for the WebGTT | |
7 * application, specifically, the implementation of the ColoringButton class. | |
8 * This implementation provides functions for manipulating a coloring button, | |
9 * and adding/managing event handlers for a coloring button. | |
10 * | |
11 * @author ragad@google.com (Raga Gopalakrishnan) | |
12 */ | |
13 | |
14 /** | |
15 * This constant holds the default text for the coloring button. | |
16 * @type {string} | |
17 * @const | |
18 */ | |
19 BUTTON_TEXT = 'Get a valid coloring'; | |
20 | |
21 /** | |
22 * This class is used to represent a coloring button. | |
23 * | |
24 * @param {object} coloringButton Handle to the DOM object representing the | |
25 * button. | |
26 * @param {object} graph1 Reference to the graph associated with the button. | |
27 * @constructor | |
28 */ | |
29 ColoringButton = function (coloringButton, graph1) { | |
30 this.coloringButton = coloringButton; | |
31 this.graph1 = graph1; | |
32 | |
33 this.coloringButton.disabled = true; | |
34 this.setText('Please wait...'); | |
35 }; | |
36 | |
37 /** | |
38 * This function disables/enables the coloring button. | |
39 * | |
40 * @param {boolean} disabled The value to be assigned to | |
41 * coloringButton.disabled. | |
42 */ | |
43 ColoringButton.prototype.setDisabled = function (isDisabled) { | |
44 this.coloringButton.disabled = isDisabled; | |
45 }; | |
46 | |
47 /** | |
48 * This function sets the text on the coloring button. | |
49 * | |
50 * @param {string} buttonText The text to be displayed on the coloring button. | |
51 */ | |
52 ColoringButton.prototype.setText = function (buttonText) { | |
53 this.coloringButton.innerHTML = buttonText; | |
54 }; | |
55 | |
56 /** | |
57 * This function handles the click event on the coloring button. Note that the | |
58 * event object passed to this function is of no use here. | |
59 * | |
60 * @param {object} e The Event object containing information about the click | |
61 * event. | |
62 */ | |
63 ColoringButton.prototype.handleColoringButtonClick = function (e) { | |
64 canvas1.setEditMode(false); | |
65 this.setDisabled(true); | |
66 this.setText('Please wait...'); | |
67 naclModule1.postMessage( | |
68 '::' + | |
69 this.graph1.getAdjacencyMatrix().toString() + | |
70 '::' + | |
71 '0' + | |
72 '::'); | |
73 }; | |
OLD | NEW |