PluginProbe
CSS & JavaScript Toolbox / 6.1.2
CSS & JavaScript Toolbox v6.1.2
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / js / installer / installer.js

installer.js in CSS & JavaScript Toolbox 6.1.2, at framework/js/installer/installer.js

151 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 *
3 */
4
5 /**
6 * put your comment there...
7 *
8 * @param operations
9 */
10 var CJTInstaller;
11
12 /**
13 *
14 */
15 (function ($) {
16
17 /**
18 * put your comment there...
19 *
20 * @param operations
21 */
22 CJTInstaller = function(operations) {
23
24 /**
25 *
26 */
27 this.action = 'install';
28
29 /**
30 *
31 */
32 this.ajax = CJTServer;
33
34 /**
35 *
36 */
37 this.cancelled;
38
39 /**
40 *
41 */
42 this.controller = 'installer';
43
44 /**
45 * put your comment there...
46 *
47 */
48 this.operationId;
49
50 /**
51 *
52 */
53 this.promise;
54
55 /**
56 *
57 */
58 this.cancel = function() {
59 this.cancelled = true;
60 return this;
61 }
62
63 /**
64 *
65 *
66 * @param callback
67 * @returns
68 */
69 var each = function(callback) {
70 var promise = this.ajax.getDeferredObject();
71 // Call installation callback!
72 if (isValid.call(this)) {
73 var operation = getCurrentOperation.call(this);
74 callback(promise.promise(), this.operationId, operation);
75 if (!this.cancelled) {
76 // Install operation!
77 this.ajax.send(this.controller, this.action, {operation : operation})
78 .success($.proxy( // Single operation installation success.
79 function(irs /*Install Response Structure! */) {
80 // Notify single operation installation successed!
81 promise.resolveWith(irs);
82 // continue loop!
83 this.operationId++; // Increase operation pointer by one!
84 each.call(this, callback);
85 }, this)
86 ).error($.proxy( // Single operation installation error.
87 function(irs /*Install Response Structure! */) {
88 // Notify single operation installation failure!
89 promise.rejectWith(irs);
90 // Notify all failures!
91 this.promise.rejectWith(irs, this.operationId, operation, callback);
92 }, this)
93 );
94 } // End if
95 } // End if
96 else { // All operations are done!
97 if (1) { // @TODO Success condition
98 this.promise.resolve();
99 }
100 else { // @TODO Failure condition
101 this.promise.reject();
102 }
103 }
104 }
105
106 /**
107 *
108 */
109 var getCurrentOperation = function() {
110 if (operations[this.operationId] === undefined) {
111 $.error('Invalid operation pointer.');
112 }
113 return operations[this.operationId];
114 }
115
116 /**
117 *
118 *
119 * @param callback
120 * @returns
121 */
122 this.install = function(callback) {
123 // Reset operations iterator.
124 reset.call(this);
125 // Start client-server-iteration (csi).
126 each.call(this, callback);
127 // Overall promising!
128 return this.promise.promise();
129 }
130
131 /**
132 *
133 */
134 var isValid = function() {
135 var operationsCount = operations.length;
136 return ((operationsCount > 0) && (this.operationId != operations.length));
137 }
138
139 /**
140 *
141 */
142 var reset = function() {
143 // Reset our loop!
144 this.promise = this.ajax.getDeferredObject();
145 this.operationId = 0;
146 this.cancelled = false;
147 }
148
149 } // End CJTInstaller class.
150
151 }(jQuery));