author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2012-03-17 21:18:52 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2012-03-17 21:18:52 (UTC) |
commit | 288b8df03a499a2e68ebaad48e687d1eac9df0ff (patch) (unidiff) | |
tree | 1fcaefffee8366b548465a05a6c4cba0c31e131d /frontend/gamma/js | |
parent | 6f7ead0446aae6dd9f40b183e402b059a33d0517 (diff) | |
parent | 25029b943781850c76fbf43827af0204f35a98bf (diff) | |
download | clipperz-288b8df03a499a2e68ebaad48e687d1eac9df0ff.zip clipperz-288b8df03a499a2e68ebaad48e687d1eac9df0ff.tar.gz clipperz-288b8df03a499a2e68ebaad48e687d1eac9df0ff.tar.bz2 |
Merge pull request #34 from gcsolaroli/master
Fixed some resources
26 files changed, 616 insertions, 531 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js index 9817eac..190bffd 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy.js | |||
@@ -141,9 +141,9 @@ Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { | |||
141 | 141 | ||
142 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { | 142 | 'processMessage': function (aFunctionName, someParameters, aRequestType) { |
143 | vardeferredResult; | 143 | vardeferredResult; |
144 | 144 | ||
145 | deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true}); | 145 | deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false}); |
146 | deferredResult.addMethod(this, 'payToll', aRequestType); | 146 | deferredResult.addMethod(this, 'payToll', aRequestType); |
147 | deferredResult.addMethod(this, 'sendMessage', aFunctionName); | 147 | deferredResult.addMethod(this, 'sendMessage', aFunctionName); |
148 | deferredResult.addMethod(this, 'setTollCallback'); | 148 | deferredResult.addMethod(this, 'setTollCallback'); |
149 | deferredResult.callback(someParameters); | 149 | deferredResult.callback(someParameters); |
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js index 095e8ed..8df7e0e 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Components/Tooltip.js | |||
@@ -101,10 +101,10 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Co | |||
101 | this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ | 101 | this.append(MochiKit.DOM.getElement('Clipperz_PM_UI_Common_Components_Tooltip_wrapperNode'), {tag:'div', id:this.getId('tooltip'), cls:'tooltip ' + this.position(), children:[ |
102 | {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ | 102 | {tag:'div', id:this.getId('body'), cls:'tooltip_body', children:[ |
103 | {tag:'div', cls:'tooltip_text', children:[ | 103 | {tag:'div', cls:'tooltip_text', children:[ |
104 | {tag:'span', html:this.text()} | 104 | {tag:'span', html:this.text()} |
105 | ]}, | 105 | ]}//, |
106 | {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} | 106 | // {tag:'div', id:this.getId('footer'), cls:'tooltip_footer'} |
107 | ]}, | 107 | ]}, |
108 | {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} | 108 | {tag:'div', id:this.getId('arrow'), cls:'tooltip_arrow'} |
109 | ]}); | 109 | ]}); |
110 | 110 | ||
@@ -145,47 +145,48 @@ Clipperz.Base.extend(Clipperz.PM.UI.Common.Components.Tooltip, Clipperz.PM.UI.Co | |||
145 | //console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); | 145 | //console.log("BOX DIMENSIONS", Clipperz.Base.serializeJSON(this.boxDimensions())); |
146 | switch (this.position()) { | 146 | switch (this.position()) { |
147 | case 'ABOVE': | 147 | case 'ABOVE': |
148 | //console.log("ABOVE"); | 148 | //console.log("ABOVE"); |
149 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); | 149 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); |
150 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); | 150 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); |
151 | bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; | 151 | bodyPosition.y = elementSizeAndPosition.position.y - this.boxDimensions().h - 13; |
152 | 152 | ||
153 | arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); | 153 | // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); |
154 | arrowPosition.y = elementSizeAndPosition.position.y - 13; | 154 | // arrowPosition.y = elementSizeAndPosition.position.y - 13; |
155 | break; | 155 | break; |
156 | case 'BELOW': | 156 | case 'BELOW': |
157 | //console.log("BELOW"); | 157 | //console.log("BELOW"); |
158 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); | 158 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:36, h:13}, 'px'); |
159 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); | 159 | bodyPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - this.boxDimensions().w/2); |
160 | bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; | 160 | bodyPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h + 13; |
161 | 161 | ||
162 | arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); | 162 | // arrowPosition.x = elementSizeAndPosition.position.x + (elementSizeAndPosition.dimensions.w/2 - 36/2); |
163 | arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; | 163 | // arrowPosition.y = elementSizeAndPosition.position.y + elementSizeAndPosition.dimensions.h; |
164 | break; | 164 | break; |
165 | case 'LEFT': | 165 | case 'LEFT': |
166 | //console.log("LEFT"); | 166 | //console.log("LEFT"); |
167 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); | 167 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); |
168 | bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; | 168 | bodyPosition.x = elementSizeAndPosition.position.x - this.boxDimensions().w - 13; |
169 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); | 169 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); |
170 | 170 | ||
171 | arrowPosition.x = elementSizeAndPosition.position.x -13; | 171 | // arrowPosition.x = elementSizeAndPosition.position.x -13; |
172 | arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); | 172 | // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); |
173 | break; | 173 | break; |
174 | case 'RIGHT': | 174 | case 'RIGHT': |
175 | //console.log("RIGHT"); | 175 | //console.log("RIGHT"); |
176 | MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); | 176 | // MochiKit.Style.setElementDimensions(this.getId('arrow'), {w:13, h:36}, 'px'); |
177 | bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; | 177 | bodyPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w + 13; |
178 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); | 178 | bodyPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - this.boxDimensions().h/2); |
179 | 179 | ||
180 | arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; | 180 | // arrowPosition.x = elementSizeAndPosition.position.x + elementSizeAndPosition.dimensions.w; |
181 | arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); | 181 | // arrowPosition.y = elementSizeAndPosition.position.y + (elementSizeAndPosition.dimensions.h/2 - 36/2); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | //console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); | 184 | //console.log("X: " + bodyPosition.x + ", Y: " + bodyPosition.y); |
185 | 185 | ||
186 | MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); | 186 | MochiKit.Style.setElementPosition(this.getId('tooltip'), bodyPosition); |
187 | MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); | 187 | // MochiKit.Style.setElementPosition(this.getId('body'), bodyPosition); |
188 | // MochiKit.Style.setElementPosition(this.getId('arrow'), arrowPosition); | ||
188 | MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); | 189 | MochiKit.Visual.appear(this.displayElement(), {duration:0.4}); |
189 | } | 190 | } |
190 | }, | 191 | }, |
191 | 192 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js index 389d876..a10ba4f 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Components/LoginForm.js | |||
@@ -64,26 +64,11 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Com | |||
64 | {tag:'h4', html:'Login'}, | 64 | {tag:'h4', html:'Login'}, |
65 | // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ | 65 | // {tag:'form', cls:'loginForm', autocomplete:this.autocomplete(), children:[ |
66 | {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ | 66 | {tag:'form', id:this.getId('form'), cls:'loginForm', children:[ |
67 | {tag:'label', html:'username', 'for':this.getId('usernameField')}, | 67 | {tag:'label', html:'username', 'for':this.getId('usernameField')}, |
68 | {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'/*, value:'joe'*/}, | 68 | {tag:'input', id:this.getId('usernameField'), type:'text', cls:'username'}, |
69 | {tag:'ul', id:this.getId('passwordOptions'), children:[ | ||
70 | {tag:'li', id:this.getId('passphraseOption'), children:[ | ||
71 | {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, | 69 | {tag:'label', html:'passphrase / OTP', 'for':this.getId('passphraseField')}, |
72 | {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'/*, value:'clipperz'*/} | 70 | {tag:'input', id:this.getId('passphraseField'), type:'password', cls:'password'}, |
73 | ]} //, | ||
74 | /* | ||
75 | {tag:'li', id:this.getId('otpOption'), children:[ | ||
76 | {tag:'label', html:'one-time password', 'for':this.getId('otpField_1')}, | ||
77 | {tag:'input', id:this.getId('otpField_1'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
78 | {tag:'input', id:this.getId('otpField_2'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
79 | {tag:'input', id:this.getId('otpField_3'), type:'text', cls:'otp', value:'abcd-efgh'}, | ||
80 | {tag:'input', id:this.getId('otpField_4'), type:'text', cls:'otp', value:'abcd-efgh'} | ||
81 | ]} | ||
82 | */ | ||
83 | ]}, | ||
84 | // {tag:'input', id:this.getId('otpCheckbox'), type:'checkbox', cls:'checkbox'}, | ||
85 | // {tag:'label', html:'use a one-time passphrase', 'for':this.getId('otpCheckbox'), cls:'checkbox'}, | ||
86 | 71 | ||
87 | {tag:'div', cls:'translations', children:[ | 72 | {tag:'div', cls:'translations', children:[ |
88 | {tag:'h4', html:'choose your language'}, | 73 | {tag:'h4', html:'choose your language'}, |
89 | {tag:'ul', children:[ | 74 | {tag:'ul', children:[ |
@@ -160,31 +145,24 @@ Clipperz.Base.extend(Clipperz.PM.UI.Web.Components.LoginForm, Clipperz.PM.UI.Com | |||
160 | */ | 145 | */ |
161 | //------------------------------------------------------------------------- | 146 | //------------------------------------------------------------------------- |
162 | 147 | ||
163 | 'loginEventHandler': function(anEvent) { | 148 | 'loginEventHandler': function(anEvent) { |
164 | varusername; | 149 | // varusername; |
165 | var passphrase; | 150 | // var passphrase; |
166 | // var shouldUseOTP; | ||
167 | // var otp; | ||
168 | var signalArguments; | 151 | var signalArguments; |
169 | 152 | ||
170 | anEvent.preventDefault(); | 153 | anEvent.preventDefault(); |
171 | 154 | ||
172 | username = this.getElement('usernameField').value; | 155 | // username = this.getElement('usernameField').value; |
173 | passphrase = this.getElement('passphraseField').value; | 156 | // passphrase = this.getElement('passphraseField').value; |
174 | // otp =this.getElement('otpField_1').value + | 157 | |
175 | // this.getElement('otpField_2').value + | 158 | // signalArguments = {username:username}; |
176 | // this.getElement('otpField_3').value + | 159 | // signalArguments.passphrase = passphrase; |
177 | // this.getElement('otpField_4').value; | 160 | |
178 | // shouldUseOTP = this.getElement('otpCheckbox').checked; | 161 | signalArguments = { |
179 | 162 | 'username': this.getElement('usernameField').value, | |
180 | signalArguments = {username:username}; | 163 | 'passphrase':this.getElement('passphraseField').value |
181 | 164 | }; | |
182 | // if (shouldUseOTP) { | ||
183 | // signalArguments.otp = otp; | ||
184 | // } else { | ||
185 | signalArguments.passphrase = passphrase; | ||
186 | // } | ||
187 | 165 | ||
188 | MochiKit.Signal.signal(this, 'doLogin', signalArguments); | 166 | MochiKit.Signal.signal(this, 'doLogin', signalArguments); |
189 | }, | 167 | }, |
190 | 168 | ||
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js index d0b378c..a57152d 100644 --- a/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js +++ b/frontend/gamma/js/Clipperz/PM/UI/Web/Controllers/LoginController.js | |||
@@ -80,15 +80,13 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, { | |||
80 | 80 | ||
81 | 'doLogin': function(aLoginForm, anEvent) { | 81 | 'doLogin': function(aLoginForm, anEvent) { |
82 | var deferredResult; | 82 | var deferredResult; |
83 | varparameters; | 83 | varparameters; |
84 | // varshouldUseOTP; | ||
85 | var loginProgress; | 84 | var loginProgress; |
86 | varuser; | 85 | varuser; |
87 | var getPassphraseDelegate; | 86 | var getPassphraseDelegate; |
88 | 87 | ||
89 | parameters = anEvent; | 88 | parameters = anEvent; |
90 | // shouldUseOTP = (typeof(parameters.passphrase) == 'undefined'); | ||
91 | 89 | ||
92 | getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); | 90 | getPassphraseDelegate = MochiKit.Base.partial(MochiKit.Async.succeed, parameters.passphrase); |
93 | user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')}); | 91 | user = new Clipperz.PM.DataModel.User({'username':parameters.username, 'getPassphraseFunction':MochiKit.Base.method(Clipperz.PM.RunTime.mainController, 'getPassphrase')}); |
94 | 92 | ||
@@ -98,13 +96,9 @@ MochiKit.Base.update(Clipperz.PM.UI.Web.Controllers.LoginController.prototype, { | |||
98 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); | 96 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'initProgress', {'steps':4}); |
99 | deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate); | 97 | deferredResult.addMethod(Clipperz.PM.RunTime.mainController, 'setPassphraseDelegate', getPassphraseDelegate); |
100 | deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()}); | 98 | deferredResult.addMethod(loginProgress, 'deferredShowModal', {deferredObject:deferredResult, openFromElement:aLoginForm.submitButtonElement()}); |
101 | deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); | 99 | deferredResult.addMethod(Clipperz.Crypto.PRNG.defaultRandomGenerator(), 'deferredEntropyCollection'); |
102 | // if (shouldUseOTP == false) { | ||
103 | deferredResult.addMethod(user, 'login'); | 100 | deferredResult.addMethod(user, 'login'); |
104 | // } else { | ||
105 | // deferredResult.addMethod(user, 'loginUsingOTP', parameters.username, parameters.otp); | ||
106 | // } | ||
107 | deferredResult.addCallback(function(aLoginProgress, res) { | 101 | deferredResult.addCallback(function(aLoginProgress, res) { |
108 | aLoginProgress.disableCancel(); | 102 | aLoginProgress.disableCancel(); |
109 | return res; | 103 | return res; |
110 | }, loginProgress); | 104 | }, loginProgress); |
diff --git a/frontend/gamma/js/MochiKit/Async.js b/frontend/gamma/js/MochiKit/Async.js index c7408e7..cc43835 100644 --- a/frontend/gamma/js/MochiKit/Async.js +++ b/frontend/gamma/js/MochiKit/Async.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Async', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'Async', '1.5', ['Base']); |
12 | 12 | ||
13 | /** @id MochiKit.Async.Deferred */ | 13 | /** @id MochiKit.Async.Deferred */ |
14 | MochiKit.Async.Deferred = function (/* optional */ canceller) { | 14 | MochiKit.Async.Deferred = function (/* optional */ canceller) { |
15 | this.chain = []; | 15 | this.chain = []; |
@@ -19,42 +19,51 @@ MochiKit.Async.Deferred = function (/* optional */ canceller) { | |||
19 | this.results = [null, null]; | 19 | this.results = [null, null]; |
20 | this.canceller = canceller; | 20 | this.canceller = canceller; |
21 | this.silentlyCancelled = false; | 21 | this.silentlyCancelled = false; |
22 | this.chained = false; | 22 | this.chained = false; |
23 | this.finalized = false; | ||
23 | }; | 24 | }; |
24 | 25 | ||
25 | MochiKit.Async.Deferred.prototype = { | 26 | MochiKit.Async.Deferred.prototype = { |
26 | /** @id MochiKit.Async.Deferred.prototype.repr */ | 27 | /** @id MochiKit.Async.Deferred.prototype.repr */ |
27 | repr: function () { | 28 | repr: function () { |
28 | var state; | 29 | return 'Deferred(' + this.id + ', ' + this.state() + ')'; |
29 | if (this.fired == -1) { | ||
30 | state = 'unfired'; | ||
31 | } else if (this.fired === 0) { | ||
32 | state = 'success'; | ||
33 | } else { | ||
34 | state = 'error'; | ||
35 | } | ||
36 | return 'Deferred(' + this.id + ', ' + state + ')'; | ||
37 | }, | 30 | }, |
38 | 31 | ||
39 | toString: MochiKit.Base.forwardCall("repr"), | 32 | toString: MochiKit.Base.forwardCall("repr"), |
40 | 33 | ||
41 | _nextId: MochiKit.Base.counter(), | 34 | _nextId: MochiKit.Base.counter(), |
42 | 35 | ||
36 | /** @id MochiKit.Async.Deferred.prototype.state */ | ||
37 | state: function () { | ||
38 | if (this.fired == -1) { | ||
39 | return 'unfired'; | ||
40 | } else if (this.fired === 0) { | ||
41 | return 'success'; | ||
42 | } else { | ||
43 | return 'error'; | ||
44 | } | ||
45 | }, | ||
46 | |||
43 | /** @id MochiKit.Async.Deferred.prototype.cancel */ | 47 | /** @id MochiKit.Async.Deferred.prototype.cancel */ |
44 | cancel: function () { | 48 | cancel: function (e) { |
45 | var self = MochiKit.Async; | 49 | var self = MochiKit.Async; |
46 | if (this.fired == -1) { | 50 | if (this.fired == -1) { |
47 | if (this.canceller) { | 51 | if (this.canceller) { |
48 | this.canceller(this); | 52 | this.canceller(this); |
49 | } else { | 53 | } else { |
50 | this.silentlyCancelled = true; | 54 | this.silentlyCancelled = true; |
51 | } | 55 | } |
52 | if (this.fired == -1) { | 56 | if (this.fired == -1) { |
53 | this.errback(new self.CancelledError(this)); | 57 | if (typeof(e) === 'string') { |
58 | e = new self.GenericError(e); | ||
59 | } else if (!(e instanceof Error)) { | ||
60 | e = new self.CancelledError(this); | ||
61 | } | ||
62 | this.errback(e); | ||
54 | } | 63 | } |
55 | } else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) { | 64 | } else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) { |
56 | this.results[0].cancel(); | 65 | this.results[0].cancel(e); |
57 | } | 66 | } |
58 | }, | 67 | }, |
59 | 68 | ||
60 | _resback: function (res) { | 69 | _resback: function (res) { |
@@ -64,9 +73,11 @@ MochiKit.Async.Deferred.prototype = { | |||
64 | 73 | ||
65 | ***/ | 74 | ***/ |
66 | this.fired = ((res instanceof Error) ? 1 : 0); | 75 | this.fired = ((res instanceof Error) ? 1 : 0); |
67 | this.results[this.fired] = res; | 76 | this.results[this.fired] = res; |
77 | if (this.paused === 0) { | ||
68 | this._fire(); | 78 | this._fire(); |
79 | } | ||
69 | }, | 80 | }, |
70 | 81 | ||
71 | _check: function () { | 82 | _check: function () { |
72 | if (this.fired != -1) { | 83 | if (this.fired != -1) { |
@@ -128,15 +139,36 @@ MochiKit.Async.Deferred.prototype = { | |||
128 | addCallbacks: function (cb, eb) { | 139 | addCallbacks: function (cb, eb) { |
129 | if (this.chained) { | 140 | if (this.chained) { |
130 | throw new Error("Chained Deferreds can not be re-used"); | 141 | throw new Error("Chained Deferreds can not be re-used"); |
131 | } | 142 | } |
143 | if (this.finalized) { | ||
144 | throw new Error("Finalized Deferreds can not be re-used"); | ||
145 | } | ||
132 | this.chain.push([cb, eb]); | 146 | this.chain.push([cb, eb]); |
133 | if (this.fired >= 0) { | 147 | if (this.fired >= 0) { |
134 | this._fire(); | 148 | this._fire(); |
135 | } | 149 | } |
136 | return this; | 150 | return this; |
137 | }, | 151 | }, |
138 | 152 | ||
153 | /** @id MochiKit.Async.Deferred.prototype.setFinalizer */ | ||
154 | setFinalizer: function (fn) { | ||
155 | if (this.chained) { | ||
156 | throw new Error("Chained Deferreds can not be re-used"); | ||
157 | } | ||
158 | if (this.finalized) { | ||
159 | throw new Error("Finalized Deferreds can not be re-used"); | ||
160 | } | ||
161 | if (arguments.length > 1) { | ||
162 | fn = MochiKit.Base.partial.apply(null, arguments); | ||
163 | } | ||
164 | this._finalizer = fn; | ||
165 | if (this.fired >= 0) { | ||
166 | this._fire(); | ||
167 | } | ||
168 | return this; | ||
169 | }, | ||
170 | |||
139 | _fire: function () { | 171 | _fire: function () { |
140 | /*** | 172 | /*** |
141 | 173 | ||
142 | Used internally to exhaust the callback sequence when a result | 174 | Used internally to exhaust the callback sequence when a result |
@@ -159,13 +191,10 @@ MochiKit.Async.Deferred.prototype = { | |||
159 | res = f(res); | 191 | res = f(res); |
160 | fired = ((res instanceof Error) ? 1 : 0); | 192 | fired = ((res instanceof Error) ? 1 : 0); |
161 | if (res instanceof MochiKit.Async.Deferred) { | 193 | if (res instanceof MochiKit.Async.Deferred) { |
162 | cb = function (res) { | 194 | cb = function (res) { |
163 | self._resback(res); | ||
164 | self.paused--; | 195 | self.paused--; |
165 | if ((self.paused === 0) && (self.fired >= 0)) { | 196 | self._resback(res); |
166 | self._fire(); | ||
167 | } | ||
168 | }; | 197 | }; |
169 | this.paused++; | 198 | this.paused++; |
170 | } | 199 | } |
171 | } catch (err) { | 200 | } catch (err) { |
@@ -177,8 +206,12 @@ MochiKit.Async.Deferred.prototype = { | |||
177 | } | 206 | } |
178 | } | 207 | } |
179 | this.fired = fired; | 208 | this.fired = fired; |
180 | this.results[fired] = res; | 209 | this.results[fired] = res; |
210 | if (this.chain.length == 0 && this.paused === 0 && this._finalizer) { | ||
211 | this.finalized = true; | ||
212 | this._finalizer(res); | ||
213 | } | ||
181 | if (cb && this.paused) { | 214 | if (cb && this.paused) { |
182 | // this is for "tail recursion" in case the dependent deferred | 215 | // this is for "tail recursion" in case the dependent deferred |
183 | // is already fired | 216 | // is already fired |
184 | res.addBoth(cb); | 217 | res.addBoth(cb); |
@@ -248,9 +281,9 @@ MochiKit.Base.update(MochiKit.Async, { | |||
248 | } | 281 | } |
249 | var status = null; | 282 | var status = null; |
250 | try { | 283 | try { |
251 | status = this.status; | 284 | status = this.status; |
252 | if (!status && m.isNotEmpty(this.responseText)) { | 285 | if (!status && (this.response || m.isNotEmpty(this.responseText))) { |
253 | // 0 or undefined seems to mean cached or local | 286 | // 0 or undefined seems to mean cached or local |
254 | status = 304; | 287 | status = 304; |
255 | } | 288 | } |
256 | } catch (e) { | 289 | } catch (e) { |
@@ -336,9 +369,10 @@ MochiKit.Base.update(MochiKit.Async, { | |||
336 | queryString: undefined, | 369 | queryString: undefined, |
337 | username: undefined, | 370 | username: undefined, |
338 | password: undefined, | 371 | password: undefined, |
339 | headers: undefined, | 372 | headers: undefined, |
340 | mimeType: undefined | 373 | mimeType: undefined, |
374 | responseType: undefined | ||
341 | */ | 375 | */ |
342 | }, opts); | 376 | }, opts); |
343 | var self = MochiKit.Async; | 377 | var self = MochiKit.Async; |
344 | var req = self.getXMLHttpRequest(); | 378 | var req = self.getXMLHttpRequest(); |
@@ -370,8 +404,11 @@ MochiKit.Base.update(MochiKit.Async, { | |||
370 | var value = header[1]; | 404 | var value = header[1]; |
371 | req.setRequestHeader(name, value); | 405 | req.setRequestHeader(name, value); |
372 | } | 406 | } |
373 | } | 407 | } |
408 | if ("responseType" in opts && "responseType" in req) { | ||
409 | req.responseType = opts.responseType; | ||
410 | } | ||
374 | return self.sendXMLHttpRequest(req, opts.sendContent); | 411 | return self.sendXMLHttpRequest(req, opts.sendContent); |
375 | }, | 412 | }, |
376 | 413 | ||
377 | _buildURL: function (url/*, ...*/) { | 414 | _buildURL: function (url/*, ...*/) { |
@@ -403,18 +440,46 @@ MochiKit.Base.update(MochiKit.Async, { | |||
403 | d = d.addCallback(self.evalJSONRequest); | 440 | d = d.addCallback(self.evalJSONRequest); |
404 | return d; | 441 | return d; |
405 | }, | 442 | }, |
406 | 443 | ||
444 | /** @id MochiKit.Async.loadScript */ | ||
445 | loadScript: function (url) { | ||
446 | var d = new MochiKit.Async.Deferred(); | ||
447 | var script = document.createElement("script"); | ||
448 | script.type = "text/javascript"; | ||
449 | script.src = url; | ||
450 | script.onload = function () { | ||
451 | script.onload = null; | ||
452 | script.onerror = null; | ||
453 | script.onreadystatechange = null; | ||
454 | script = null; | ||
455 | d.callback(); | ||
456 | }; | ||
457 | script.onerror = function (msg) { | ||
458 | script.onload = null; | ||
459 | script.onerror = null; | ||
460 | script.onreadystatechange = null; | ||
461 | script = null; | ||
462 | msg = "Failed to load script at " + url + ": " + msg; | ||
463 | d.errback(new URIError(msg, url)); | ||
464 | } | ||
465 | script.onreadystatechange = function () { | ||
466 | if (script.readyState == "loaded" || script.readyState == "complete") { | ||
467 | script.onload(); | ||
468 | } else { | ||
469 | // IE doesn't bother to report errors... | ||
470 | MochiKit.Async.callLater(10, script.onerror, "Script loading timed out") | ||
471 | } | ||
472 | }; | ||
473 | document.getElementsByTagName("head")[0].appendChild(script); | ||
474 | return d; | ||
475 | }, | ||
476 | |||
407 | /** @id MochiKit.Async.wait */ | 477 | /** @id MochiKit.Async.wait */ |
408 | wait: function (seconds, /* optional */value) { | 478 | wait: function (seconds, /* optional */value) { |
409 | var d = new MochiKit.Async.Deferred(); | 479 | var d = new MochiKit.Async.Deferred(); |
410 | var m = MochiKit.Base; | 480 | var cb = MochiKit.Base.bind("callback", d, value); |
411 | if (typeof(value) != 'undefined') { | 481 | var timeout = setTimeout(cb, Math.floor(seconds * 1000)); |
412 | d.addCallback(function () { return value; }); | ||
413 | } | ||
414 | var timeout = setTimeout( | ||
415 | m.bind("callback", d), | ||
416 | Math.floor(seconds * 1000)); | ||
417 | d.canceller = function () { | 482 | d.canceller = function () { |
418 | try { | 483 | try { |
419 | clearTimeout(timeout); | 484 | clearTimeout(timeout); |
420 | } catch (e) { | 485 | } catch (e) { |
@@ -509,8 +574,9 @@ MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, f | |||
509 | 574 | ||
510 | }; | 575 | }; |
511 | 576 | ||
512 | MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred(); | 577 | MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred(); |
578 | MochiKit.Async.DeferredList.prototype.constructor = MochiKit.Async.DeferredList; | ||
513 | 579 | ||
514 | MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) { | 580 | MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) { |
515 | this.resultList[index] = [succeeded, result]; | 581 | this.resultList[index] = [succeeded, result]; |
516 | this.finishedCount += 1; | 582 | this.finishedCount += 1; |
diff --git a/frontend/gamma/js/MochiKit/Base.js b/frontend/gamma/js/MochiKit/Base.js index d33c269..ca1734c 100644 --- a/frontend/gamma/js/MochiKit/Base.js +++ b/frontend/gamma/js/MochiKit/Base.js | |||
@@ -7,50 +7,61 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | if (typeof(MochiKit) == 'undefined') { | 11 | |
12 | MochiKit = {}; | 12 | // MochiKit module (namespace) |
13 | } | 13 | var MochiKit = MochiKit || {}; |
14 | if (typeof(MochiKit.__export__) == "undefined") { | 14 | if (typeof(MochiKit.__export__) == "undefined") { |
15 | MochiKit.__export__ = true; | 15 | MochiKit.__export__ = true; |
16 | } | 16 | } |
17 | if (typeof(MochiKit.Base) == 'undefined') { | 17 | MochiKit.NAME = "MochiKit"; |
18 | MochiKit.Base = {}; | 18 | MochiKit.VERSION = "1.5"; |
19 | } | 19 | MochiKit.__repr__ = function () { |
20 | return "[" + this.NAME + " " + this.VERSION + "]"; | ||
21 | }; | ||
22 | MochiKit.toString = function () { | ||
23 | return this.__repr__(); | ||
24 | }; | ||
25 | |||
26 | |||
27 | // MochiKit.Base module | ||
28 | MochiKit.Base = MochiKit.Base || {}; | ||
20 | 29 | ||
21 | /** | 30 | /** |
22 | * Registers a new MochiKit module. This function will insert a new | 31 | * Creates a new module in a parent namespace. This function will |
23 | * property into the "MochiKit" object, making sure that all | 32 | * create a new empty module object with "NAME", "VERSION", |
24 | * dependency modules have already been inserted. It will also make | 33 | * "toString" and "__repr__" properties. This object will be inserted into the parent object |
25 | * sure that the appropriate properties and default module functions | 34 | * using the specified name (i.e. parent[name] = module). It will |
26 | * are defined. | 35 | * also verify that all the dependency modules are defined in the |
36 | * parent, or an error will be thrown. | ||
27 | * | 37 | * |
38 | * @param {Object} parent the parent module (use "this" or "window" for | ||
39 | * a global module) | ||
28 | * @param {String} name the module name, e.g. "Base" | 40 | * @param {String} name the module name, e.g. "Base" |
29 | * @param {String} version the module version, e.g. "1.5" | 41 | * @param {String} version the module version, e.g. "1.5" |
30 | * @param {Array} deps the array of module dependencies (as strings) | 42 | * @param {Array} [deps] the array of module dependencies (as strings) |
31 | */ | 43 | */ |
32 | MochiKit.Base._module = function (name, version, deps) { | 44 | MochiKit.Base.module = function (parent, name, version, deps) { |
33 | if (!(name in MochiKit)) { | 45 | var module = parent[name] = parent[name] || {}; |
34 | MochiKit[name] = {}; | 46 | var prefix = (parent.NAME ? parent.NAME + "." : ""); |
35 | } | 47 | module.NAME = prefix + name; |
36 | var module = MochiKit[name]; | ||
37 | module.NAME = "MochiKit." + name; | ||
38 | module.VERSION = version; | 48 | module.VERSION = version; |
39 | module.__repr__ = function () { | 49 | module.__repr__ = function () { |
40 | return "[" + this.NAME + " " + this.VERSION + "]"; | 50 | return "[" + this.NAME + " " + this.VERSION + "]"; |
41 | }; | 51 | }; |
42 | module.toString = function () { | 52 | module.toString = function () { |
43 | return this.__repr__(); | 53 | return this.__repr__(); |
44 | }; | 54 | }; |
45 | for (var i = 0; i < deps.length; i++) { | 55 | for (var i = 0; deps != null && i < deps.length; i++) { |
46 | if (!(deps[i] in MochiKit)) { | 56 | if (!(deps[i] in parent)) { |
47 | throw 'MochiKit.' + name + ' depends on MochiKit.' + deps[i] + '!'; | 57 | throw module.NAME + ' depends on ' + prefix + deps[i] + '!'; |
48 | } | ||
49 | } | 58 | } |
50 | } | 59 | } |
60 | return module; | ||
61 | }; | ||
51 | 62 | ||
52 | MochiKit.Base._module("Base", "1.5", []); | 63 | MochiKit.Base.module(MochiKit, "Base", "1.5", []); |
53 | 64 | ||
54 | /** @id MochiKit.Base.update */ | 65 | /** @id MochiKit.Base.update */ |
55 | MochiKit.Base.update = function (self, obj/*, ... */) { | 66 | MochiKit.Base.update = function (self, obj/*, ... */) { |
56 | if (self === null || self === undefined) { | 67 | if (self === null || self === undefined) { |
@@ -239,8 +250,9 @@ MochiKit.Base.update(MochiKit.Base, { | |||
239 | 250 | ||
240 | 251 | ||
241 | _newNamedError: function (module, name, func) { | 252 | _newNamedError: function (module, name, func) { |
242 | func.prototype = new MochiKit.Base.NamedError(module.NAME + "." + name); | 253 | func.prototype = new MochiKit.Base.NamedError(module.NAME + "." + name); |
254 | func.prototype.constructor = func; | ||
243 | module[name] = func; | 255 | module[name] = func; |
244 | }, | 256 | }, |
245 | 257 | ||
246 | 258 | ||
@@ -350,9 +362,9 @@ MochiKit.Base.update(MochiKit.Base, { | |||
350 | value != "undefined" && value != "0"; | 362 | value != "undefined" && value != "0"; |
351 | } else if (typeof(value) === "number" || value instanceof Number) { | 363 | } else if (typeof(value) === "number" || value instanceof Number) { |
352 | return !isNaN(value) && value != 0; | 364 | return !isNaN(value) && value != 0; |
353 | } else if (value != null && typeof(value.length) === "number") { | 365 | } else if (value != null && typeof(value.length) === "number") { |
354 | return value.length !== 0 | 366 | return value.length !== 0; |
355 | } else { | 367 | } else { |
356 | return value != null; | 368 | return value != null; |
357 | } | 369 | } |
358 | }, | 370 | }, |
@@ -674,8 +686,11 @@ MochiKit.Base.update(MochiKit.Base, { | |||
674 | }; | 686 | }; |
675 | newfunc.im_self = im_self; | 687 | newfunc.im_self = im_self; |
676 | newfunc.im_func = im_func; | 688 | newfunc.im_func = im_func; |
677 | newfunc.im_preargs = im_preargs; | 689 | newfunc.im_preargs = im_preargs; |
690 | if (typeof(im_func.NAME) == 'string') { | ||
691 | newfunc.NAME = "bind(" + im_func.NAME + ",...)"; | ||
692 | } | ||
678 | return newfunc; | 693 | return newfunc; |
679 | }, | 694 | }, |
680 | 695 | ||
681 | /** @id MochiKit.Base.bindLate */ | 696 | /** @id MochiKit.Base.bindLate */ |
@@ -787,14 +802,17 @@ MochiKit.Base.update(MochiKit.Base, { | |||
787 | return o.repr(); | 802 | return o.repr(); |
788 | } | 803 | } |
789 | return MochiKit.Base.reprRegistry.match(o); | 804 | return MochiKit.Base.reprRegistry.match(o); |
790 | } catch (e) { | 805 | } catch (e) { |
806 | try { | ||
791 | if (typeof(o.NAME) == 'string' && ( | 807 | if (typeof(o.NAME) == 'string' && ( |
792 | o.toString == Function.prototype.toString || | 808 | o.toString == Function.prototype.toString || |
793 | o.toString == Object.prototype.toString | 809 | o.toString == Object.prototype.toString |
794 | )) { | 810 | )) { |
795 | return o.NAME; | 811 | return o.NAME; |
796 | } | 812 | } |
813 | } catch (ignore) { | ||
814 | } | ||
797 | } | 815 | } |
798 | try { | 816 | try { |
799 | var ostring = (o + ""); | 817 | var ostring = (o + ""); |
800 | } catch (e) { | 818 | } catch (e) { |
@@ -839,18 +857,15 @@ MochiKit.Base.update(MochiKit.Base, { | |||
839 | }, | 857 | }, |
840 | 858 | ||
841 | 859 | ||
842 | /** @id MochiKit.Base.evalJSON */ | 860 | /** @id MochiKit.Base.evalJSON */ |
843 | evalJSON: function () { | 861 | evalJSON: function (jsonText) { |
844 | return eval("(" + MochiKit.Base._filterJSON(arguments[0]) + ")"); | 862 | return eval("(" + MochiKit.Base._filterJSON(jsonText) + ")"); |
845 | }, | 863 | }, |
846 | 864 | ||
847 | _filterJSON: function (s) { | 865 | _filterJSON: function (s) { |
848 | var m = s.match(/^\s*\/\*(.*)\*\/\s*$/); | 866 | var m = s.match(/^\s*\/\*(.*)\*\/\s*$/); |
849 | if (m) { | 867 | return (m) ? m[1] : s; |
850 | return m[1]; | ||
851 | } | ||
852 | return s; | ||
853 | }, | 868 | }, |
854 | 869 | ||
855 | /** @id MochiKit.Base.serializeJSON */ | 870 | /** @id MochiKit.Base.serializeJSON */ |
856 | serializeJSON: function (o) { | 871 | serializeJSON: function (o) { |
@@ -893,8 +908,14 @@ MochiKit.Base.update(MochiKit.Base, { | |||
893 | var me = arguments.callee; | 908 | var me = arguments.callee; |
894 | // short-circuit for objects that support "json" serialization | 909 | // short-circuit for objects that support "json" serialization |
895 | // if they return "self" then just pass-through... | 910 | // if they return "self" then just pass-through... |
896 | var newObj; | 911 | var newObj; |
912 | if (typeof(o.toJSON) == "function") { | ||
913 | newObj = o.toJSON(); | ||
914 | if (o !== newObj) { | ||
915 | return me(newObj); | ||
916 | } | ||
917 | } | ||
897 | if (typeof(o.__json__) == "function") { | 918 | if (typeof(o.__json__) == "function") { |
898 | newObj = o.__json__(); | 919 | newObj = o.__json__(); |
899 | if (o !== newObj) { | 920 | if (o !== newObj) { |
900 | return me(newObj); | 921 | return me(newObj); |
@@ -1099,9 +1120,9 @@ MochiKit.Base.update(MochiKit.Base, { | |||
1099 | var data = MochiKit.Base.flattenArguments(arguments); | 1120 | var data = MochiKit.Base.flattenArguments(arguments); |
1100 | if (data.length === 0) { | 1121 | if (data.length === 0) { |
1101 | throw new TypeError('median() requires at least one argument'); | 1122 | throw new TypeError('median() requires at least one argument'); |
1102 | } | 1123 | } |
1103 | data.sort(compare); | 1124 | data.sort(MochiKit.Base.compare); |
1104 | if (data.length % 2 == 0) { | 1125 | if (data.length % 2 == 0) { |
1105 | var upper = data.length / 2; | 1126 | var upper = data.length / 2; |
1106 | return (data[upper] + data[upper - 1]) / 2; | 1127 | return (data[upper] + data[upper - 1]) / 2; |
1107 | } else { | 1128 | } else { |
@@ -1289,21 +1310,47 @@ MochiKit.Base.AdapterRegistry.prototype = { | |||
1289 | return false; | 1310 | return false; |
1290 | } | 1311 | } |
1291 | }; | 1312 | }; |
1292 | 1313 | ||
1293 | MochiKit.Base._exportSymbols = function (globals, module) { | 1314 | /** |
1294 | if (MochiKit.__export__ === false || module.__export__ === false) { | 1315 | * Exports all symbols from one or more modules into the specified |
1295 | return; | 1316 | * namespace (or scope). This is similar to MochiKit.Base.update(), |
1296 | } | 1317 | * except for special handling of the "__export__" flag, contained |
1318 | * sub-modules (exported recursively), and names starting with "_". | ||
1319 | * | ||
1320 | * @param {Object} namespace the object or scope to modify | ||
1321 | * @param {Object} module the module to export | ||
1322 | */ | ||
1323 | MochiKit.Base.moduleExport = function (namespace, module/*, ...*/) { | ||
1324 | var SKIP = { toString: true, NAME: true, VERSION: true }; | ||
1325 | var mods = MochiKit.Base.extend([], arguments, 1); | ||
1326 | while ((module = mods.shift()) != null) { | ||
1297 | for (var k in module) { | 1327 | for (var k in module) { |
1298 | var v = module[k]; | 1328 | var v = module[k]; |
1299 | if (v != null) { | 1329 | if (v != null) { |
1300 | var okName = (k[0] !== "_" && k !== "toString"); | 1330 | var flagSet = (typeof(v.__export__) == 'boolean'); |
1301 | if (v.__export__ === true || (v.__export__ !== false && okName)) { | 1331 | var nameValid = (k[0] !== "_" && !SKIP[k]); |
1302 | globals[k] = module[k]; | 1332 | if (flagSet ? v.__export__ : nameValid) { |
1333 | if (typeof(v) == 'object' && v.NAME && v.VERSION) { | ||
1334 | mods.push(v); | ||
1335 | } else { | ||
1336 | namespace[k] = module[k]; | ||
1337 | } | ||
1338 | } | ||
1303 | } | 1339 | } |
1304 | } | 1340 | } |
1305 | } | 1341 | } |
1342 | return namespace; | ||
1343 | }; | ||
1344 | |||
1345 | /** | ||
1346 | * Identical to moduleExport, but also considers the global and | ||
1347 | * module-specific "__export__" flag. | ||
1348 | */ | ||
1349 | MochiKit.Base._exportSymbols = function (namespace, module) { | ||
1350 | if (MochiKit.__export__ !== false && module.__export__ !== false) { | ||
1351 | MochiKit.Base.moduleExport(namespace, module); | ||
1352 | } | ||
1306 | }; | 1353 | }; |
1307 | 1354 | ||
1308 | /** | 1355 | /** |
1309 | * Creates a deprecated function alias in the specified module. The | 1356 | * Creates a deprecated function alias in the specified module. The |
@@ -1320,9 +1367,9 @@ MochiKit.Base._exportSymbols = function (globals, module) { | |||
1320 | * function (e.g. 'MochiKit.Style.getStyle') | 1367 | * function (e.g. 'MochiKit.Style.getStyle') |
1321 | * @param {String} version the first version when the source function | 1368 | * @param {String} version the first version when the source function |
1322 | * was deprecated (e.g. '1.4') | 1369 | * was deprecated (e.g. '1.4') |
1323 | * @param {Boolean} [exportable] the exportable function flag, | 1370 | * @param {Boolean} [exportable] the exportable function flag, |
1324 | * defaults to true | 1371 | * defaults to false |
1325 | */ | 1372 | */ |
1326 | MochiKit.Base._deprecated = function (module, name, target, version, exportable) { | 1373 | MochiKit.Base._deprecated = function (module, name, target, version, exportable) { |
1327 | if (typeof(module) === 'string') { | 1374 | if (typeof(module) === 'string') { |
1328 | if (module.indexOf('MochiKit.') === 0) { | 1375 | if (module.indexOf('MochiKit.') === 0) { |
@@ -1348,23 +1395,21 @@ MochiKit.Base._deprecated = function (module, name, target, version, exportable) | |||
1348 | throw new Error(msg); | 1395 | throw new Error(msg); |
1349 | } | 1396 | } |
1350 | return MochiKit[targetModule][targetName].apply(this, arguments); | 1397 | return MochiKit[targetModule][targetName].apply(this, arguments); |
1351 | }; | 1398 | }; |
1352 | if (exportable === false) { | 1399 | func.__export__ = (exportable === true); |
1353 | func.__export__ = false; | ||
1354 | } | ||
1355 | module[name] = func; | 1400 | module[name] = func; |
1356 | } | 1401 | }; |
1357 | 1402 | ||
1358 | MochiKit.Base.__new__ = function () { | 1403 | MochiKit.Base.__new__ = function () { |
1359 | var m = this; | 1404 | var m = this; |
1360 | 1405 | ||
1361 | /** @id MochiKit.Base.noop */ | 1406 | /** @id MochiKit.Base.noop */ |
1362 | m.noop = m.operator.identity; | 1407 | m.noop = m.operator.identity; |
1363 | 1408 | ||
1364 | // Backwards compat | 1409 | // Backwards compat |
1365 | m._deprecated(m, 'forward', 'MochiKit.Base.forwardCall', '1.3', false); | 1410 | m._deprecated(m, 'forward', 'MochiKit.Base.forwardCall', '1.3'); |
1366 | m._deprecated(m, 'find', 'MochiKit.Base.findValue', '1.3', false); | 1411 | m._deprecated(m, 'find', 'MochiKit.Base.findValue', '1.3'); |
1367 | 1412 | ||
1368 | if (typeof(encodeURIComponent) != "undefined") { | 1413 | if (typeof(encodeURIComponent) != "undefined") { |
1369 | /** @id MochiKit.Base.urlEncode */ | 1414 | /** @id MochiKit.Base.urlEncode */ |
1370 | m.urlEncode = function (unencoded) { | 1415 | m.urlEncode = function (unencoded) { |
@@ -1374,9 +1419,9 @@ MochiKit.Base.__new__ = function () { | |||
1374 | m.urlEncode = function (unencoded) { | 1419 | m.urlEncode = function (unencoded) { |
1375 | return escape(unencoded | 1420 | return escape(unencoded |
1376 | ).replace(/\+/g, '%2B' | 1421 | ).replace(/\+/g, '%2B' |
1377 | ).replace(/\"/g,'%22' | 1422 | ).replace(/\"/g,'%22' |
1378 | ).rval.replace(/\'/g, '%27'); | 1423 | ).replace(/\'/g, '%27'); |
1379 | }; | 1424 | }; |
1380 | } | 1425 | } |
1381 | 1426 | ||
1382 | /** @id MochiKit.Base.NamedError */ | 1427 | /** @id MochiKit.Base.NamedError */ |
@@ -1384,8 +1429,9 @@ MochiKit.Base.__new__ = function () { | |||
1384 | this.message = name; | 1429 | this.message = name; |
1385 | this.name = name; | 1430 | this.name = name; |
1386 | }; | 1431 | }; |
1387 | m.NamedError.prototype = new Error(); | 1432 | m.NamedError.prototype = new Error(); |
1433 | m.NamedError.prototype.constructor = m.NamedError; | ||
1388 | m.update(m.NamedError.prototype, { | 1434 | m.update(m.NamedError.prototype, { |
1389 | repr: function () { | 1435 | repr: function () { |
1390 | if (this.message && this.message != this.name) { | 1436 | if (this.message && this.message != this.name) { |
1391 | return this.name + "(" + m.repr(this.message) + ")"; | 1437 | return this.name + "(" + m.repr(this.message) + ")"; |
@@ -1408,8 +1454,10 @@ MochiKit.Base.__new__ = function () { | |||
1408 | /** @id MochiKit.Base.isCallable */ | 1454 | /** @id MochiKit.Base.isCallable */ |
1409 | m.isCallable = m.typeMatcher('function'); | 1455 | m.isCallable = m.typeMatcher('function'); |
1410 | /** @id MochiKit.Base.isUndefined */ | 1456 | /** @id MochiKit.Base.isUndefined */ |
1411 | m.isUndefined = m.typeMatcher('undefined'); | 1457 | m.isUndefined = m.typeMatcher('undefined'); |
1458 | /** @id MochiKit.Base.isValue */ | ||
1459 | m.isValue = m.typeMatcher('boolean', 'number', 'string'); | ||
1412 | 1460 | ||
1413 | /** @id MochiKit.Base.merge */ | 1461 | /** @id MochiKit.Base.merge */ |
1414 | m.merge = m.partial(m.update, null); | 1462 | m.merge = m.partial(m.update, null); |
1415 | /** @id MochiKit.Base.zip */ | 1463 | /** @id MochiKit.Base.zip */ |
diff --git a/frontend/gamma/js/MochiKit/Color.js b/frontend/gamma/js/MochiKit/Color.js index 27dc2d0..f2a0f67 100644 --- a/frontend/gamma/js/MochiKit/Color.js +++ b/frontend/gamma/js/MochiKit/Color.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito and others. All rights Reserved. | 7 | (c) 2005 Bob Ippolito and others. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Color', '1.5', ['Base', 'DOM', 'Style']); | 11 | MochiKit.Base.module(MochiKit, 'Color', '1.5', ['Base', 'DOM', 'Style']); |
12 | 12 | ||
13 | /** @id MochiKit.Color.Color */ | 13 | /** @id MochiKit.Color.Color */ |
14 | MochiKit.Color.Color = function (red, green, blue, alpha) { | 14 | MochiKit.Color.Color = function (red, green, blue, alpha) { |
15 | if (typeof(alpha) == 'undefined' || alpha === null) { | 15 | if (typeof(alpha) == 'undefined' || alpha === null) { |
@@ -111,9 +111,9 @@ MochiKit.Color.Color.prototype = { | |||
111 | }, | 111 | }, |
112 | 112 | ||
113 | /** @id MochiKit.Color.Color.prototype.isLight */ | 113 | /** @id MochiKit.Color.Color.prototype.isLight */ |
114 | isLight: function () { | 114 | isLight: function () { |
115 | return this.asHSL().b > 0.5; | 115 | return this.asHSL().l > 0.5; |
116 | }, | 116 | }, |
117 | 117 | ||
118 | /** @id MochiKit.Color.Color.prototype.isDark */ | 118 | /** @id MochiKit.Color.Color.prototype.isDark */ |
119 | isDark: function () { | 119 | isDark: function () { |
@@ -640,21 +640,12 @@ MochiKit.Base.update(MochiKit.Color, { | |||
640 | /** @id MochiKit.Color.yellowColor */ | 640 | /** @id MochiKit.Color.yellowColor */ |
641 | yellow: [1, 1, 0] | 641 | yellow: [1, 1, 0] |
642 | }; | 642 | }; |
643 | 643 | ||
644 | var makeColor = function (name, r, g, b, a) { | ||
645 | var rval = this.fromRGB(r, g, b, a); | ||
646 | this[name] = function () { return rval; }; | ||
647 | return rval; | ||
648 | }; | ||
649 | |||
650 | for (var k in colors) { | 644 | for (var k in colors) { |
651 | var name = k + "Color"; | 645 | var name = k + "Color"; |
652 | var bindArgs = m.concat( | 646 | var value = this.Color.fromRGB.apply(this.Color, colors[k]); |
653 | [makeColor, this.Color, name], | 647 | this.Color[name] = m.partial(m.operator.identity, value); |
654 | colors[k] | ||
655 | ); | ||
656 | this.Color[name] = m.bind.apply(null, bindArgs); | ||
657 | } | 648 | } |
658 | 649 | ||
659 | var isColor = function () { | 650 | var isColor = function () { |
660 | for (var i = 0; i < arguments.length; i++) { | 651 | for (var i = 0; i < arguments.length; i++) { |
diff --git a/frontend/gamma/js/MochiKit/DOM.js b/frontend/gamma/js/MochiKit/DOM.js index af5d46f..944ab78 100644 --- a/frontend/gamma/js/MochiKit/DOM.js +++ b/frontend/gamma/js/MochiKit/DOM.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('DOM', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'DOM', '1.5', ['Base']); |
12 | 12 | ||
13 | MochiKit.Base.update(MochiKit.DOM, { | 13 | MochiKit.Base.update(MochiKit.DOM, { |
14 | 14 | ||
15 | /** @id MochiKit.DOM.currentWindow */ | 15 | /** @id MochiKit.DOM.currentWindow */ |
@@ -296,22 +296,22 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
296 | /** @id MochiKit.DOM.updateNodeAttributes */ | 296 | /** @id MochiKit.DOM.updateNodeAttributes */ |
297 | updateNodeAttributes: function (node, attrs) { | 297 | updateNodeAttributes: function (node, attrs) { |
298 | var elem = node; | 298 | var elem = node; |
299 | var self = MochiKit.DOM; | 299 | var self = MochiKit.DOM; |
300 | var base = MochiKit.Base; | ||
300 | if (typeof(node) == 'string') { | 301 | if (typeof(node) == 'string') { |
301 | elem = self.getElement(node); | 302 | elem = self.getElement(node); |
302 | } | 303 | } |
303 | if (attrs) { | 304 | if (attrs) { |
304 | var updatetree = MochiKit.Base.updatetree; | ||
305 | if (self.attributeArray.compliant) { | 305 | if (self.attributeArray.compliant) { |
306 | // not IE, good. | 306 | // not IE, good. |
307 | for (var k in attrs) { | 307 | for (var k in attrs) { |
308 | var v = attrs[k]; | 308 | var v = attrs[k]; |
309 | if (typeof(v) == 'object' && typeof(elem[k]) == 'object') { | 309 | if (typeof(v) == 'object' && typeof(elem[k]) == 'object') { |
310 | if (k == "style" && MochiKit.Style) { | 310 | if (k == "style" && MochiKit.Style) { |
311 | MochiKit.Style.setStyle(elem, v); | 311 | MochiKit.Style.setStyle(elem, v); |
312 | } else { | 312 | } else { |
313 | updatetree(elem[k], v); | 313 | base.updatetree(elem[k], v); |
314 | } | 314 | } |
315 | } else if (k.substring(0, 2) == "on") { | 315 | } else if (k.substring(0, 2) == "on") { |
316 | if (typeof(v) == "string") { | 316 | if (typeof(v) == "string") { |
317 | v = new Function(v); | 317 | v = new Function(v); |
@@ -319,10 +319,10 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
319 | elem[k] = v; | 319 | elem[k] = v; |
320 | } else { | 320 | } else { |
321 | elem.setAttribute(k, v); | 321 | elem.setAttribute(k, v); |
322 | } | 322 | } |
323 | if (typeof(elem[k]) == "string" && elem[k] != v) { | 323 | if (base.isValue(elem[k]) && elem[k] != v) { |
324 | // Also set property for weird attributes (see #302) | 324 | // Also set property for weird attributes (see #302 & #335) |
325 | elem[k] = v; | 325 | elem[k] = v; |
326 | } | 326 | } |
327 | } | 327 | } |
328 | } else { | 328 | } else { |
@@ -339,9 +339,9 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
339 | && typeof(v) == 'object') { | 339 | && typeof(v) == 'object') { |
340 | if (k == "style" && MochiKit.Style) { | 340 | if (k == "style" && MochiKit.Style) { |
341 | MochiKit.Style.setStyle(elem, v); | 341 | MochiKit.Style.setStyle(elem, v); |
342 | } else { | 342 | } else { |
343 | updatetree(elem[k], v); | 343 | base.updatetree(elem[k], v); |
344 | } | 344 | } |
345 | } else if (k.substring(0, 2) == "on") { | 345 | } else if (k.substring(0, 2) == "on") { |
346 | if (typeof(v) == "string") { | 346 | if (typeof(v) == "string") { |
347 | v = new Function(v); | 347 | v = new Function(v); |
@@ -349,10 +349,10 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
349 | elem[k] = v; | 349 | elem[k] = v; |
350 | } else { | 350 | } else { |
351 | elem.setAttribute(k, v); | 351 | elem.setAttribute(k, v); |
352 | } | 352 | } |
353 | if (typeof(elem[k]) == "string" && elem[k] != v) { | 353 | if (base.isValue(elem[k]) && elem[k] != v) { |
354 | // Also set property for weird attributes (see #302) | 354 | // Also set property for weird attributes (see #302 & #335) |
355 | elem[k] = v; | 355 | elem[k] = v; |
356 | } | 356 | } |
357 | } | 357 | } |
358 | } | 358 | } |
@@ -989,8 +989,9 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
989 | "usemap": "useMap", | 989 | "usemap": "useMap", |
990 | "for": "htmlFor", | 990 | "for": "htmlFor", |
991 | "readonly": "readOnly", | 991 | "readonly": "readOnly", |
992 | "colspan": "colSpan", | 992 | "colspan": "colSpan", |
993 | "rowspan": "rowSpan", | ||
993 | "bgcolor": "bgColor", | 994 | "bgcolor": "bgColor", |
994 | "cellspacing": "cellSpacing", | 995 | "cellspacing": "cellSpacing", |
995 | "cellpadding": "cellPadding" | 996 | "cellpadding": "cellPadding" |
996 | }; | 997 | }; |
@@ -1006,9 +1007,9 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
1006 | this.attributeArray = attributeArray; | 1007 | this.attributeArray = attributeArray; |
1007 | 1008 | ||
1008 | // Backwards compatibility aliases | 1009 | // Backwards compatibility aliases |
1009 | /** @id MochiKit.DOM.computedStyle */ | 1010 | /** @id MochiKit.DOM.computedStyle */ |
1010 | m._deprecated(this, 'computedStyle', 'MochiKit.Style.getStyle', '1.4'); | 1011 | m._deprecated(this, 'computedStyle', 'MochiKit.Style.getStyle', '1.4', true); |
1011 | /** @id MochiKit.DOM.elementDimensions */ | 1012 | /** @id MochiKit.DOM.elementDimensions */ |
1012 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4'); | 1013 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4'); |
1013 | /** @id MochiKit.DOM.elementPosition */ | 1014 | /** @id MochiKit.DOM.elementPosition */ |
1014 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.4'); | 1015 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.4'); |
@@ -1040,50 +1041,40 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
1040 | m._deprecated(this, 'Dimensions', 'MochiKit.Style.Dimensions', '1.4'); | 1041 | m._deprecated(this, 'Dimensions', 'MochiKit.Style.Dimensions', '1.4'); |
1041 | 1042 | ||
1042 | // shorthand for createDOM syntax | 1043 | // shorthand for createDOM syntax |
1043 | var createDOMFunc = this.createDOMFunc; | 1044 | var createDOMFunc = this.createDOMFunc; |
1044 | /** @id MochiKit.DOM.UL */ | ||
1045 | this.UL = createDOMFunc("ul"); | ||
1046 | /** @id MochiKit.DOM.OL */ | ||
1047 | this.OL = createDOMFunc("ol"); | ||
1048 | /** @id MochiKit.DOM.LI */ | ||
1049 | this.LI = createDOMFunc("li"); | ||
1050 | /** @id MochiKit.DOM.DL */ | ||
1051 | this.DL = createDOMFunc("dl"); | ||
1052 | /** @id MochiKit.DOM.DT */ | ||
1053 | this.DT = createDOMFunc("dt"); | ||
1054 | /** @id MochiKit.DOM.DD */ | ||
1055 | this.DD = createDOMFunc("dd"); | ||
1056 | /** @id MochiKit.DOM.TD */ | ||
1057 | this.TD = createDOMFunc("td"); | ||
1058 | /** @id MochiKit.DOM.TR */ | ||
1059 | this.TR = createDOMFunc("tr"); | ||
1060 | /** @id MochiKit.DOM.TBODY */ | ||
1061 | this.TBODY = createDOMFunc("tbody"); | ||
1062 | /** @id MochiKit.DOM.THEAD */ | ||
1063 | this.THEAD = createDOMFunc("thead"); | ||
1064 | /** @id MochiKit.DOM.TFOOT */ | ||
1065 | this.TFOOT = createDOMFunc("tfoot"); | ||
1066 | /** @id MochiKit.DOM.TABLE */ | ||
1067 | this.TABLE = createDOMFunc("table"); | ||
1068 | /** @id MochiKit.DOM.TH */ | ||
1069 | this.TH = createDOMFunc("th"); | ||
1070 | /** @id MochiKit.DOM.INPUT */ | ||
1071 | this.INPUT = createDOMFunc("input"); | ||
1072 | /** @id MochiKit.DOM.SPAN */ | ||
1073 | this.SPAN = createDOMFunc("span"); | ||
1074 | /** @id MochiKit.DOM.A */ | 1045 | /** @id MochiKit.DOM.A */ |
1075 | this.A = createDOMFunc("a"); | 1046 | this.A = createDOMFunc("a"); |
1076 | /** @id MochiKit.DOM.DIV */ | 1047 | /** @id MochiKit.DOM.ARTICLE */ |
1077 | this.DIV = createDOMFunc("div"); | 1048 | this.ARTICLE = createDOMFunc("article"); |
1078 | /** @id MochiKit.DOM.IMG */ | 1049 | /** @id MochiKit.DOM.ASIDE */ |
1079 | this.IMG = createDOMFunc("img"); | 1050 | this.ASIDE = createDOMFunc("aside"); |
1051 | /** @id MochiKit.DOM.BR */ | ||
1052 | this.BR = createDOMFunc("br"); | ||
1080 | /** @id MochiKit.DOM.BUTTON */ | 1053 | /** @id MochiKit.DOM.BUTTON */ |
1081 | this.BUTTON = createDOMFunc("button"); | 1054 | this.BUTTON = createDOMFunc("button"); |
1082 | /** @id MochiKit.DOM.TT */ | 1055 | /** @id MochiKit.DOM.CANVAS */ |
1083 | this.TT = createDOMFunc("tt"); | 1056 | this.CANVAS = createDOMFunc("canvas"); |
1084 | /** @id MochiKit.DOM.PRE */ | 1057 | /** @id MochiKit.DOM.CAPTION */ |
1085 | this.PRE = createDOMFunc("pre"); | 1058 | this.CAPTION = createDOMFunc("caption"); |
1059 | /** @id MochiKit.DOM.DD */ | ||
1060 | this.DD = createDOMFunc("dd"); | ||
1061 | /** @id MochiKit.DOM.DIV */ | ||
1062 | this.DIV = createDOMFunc("div"); | ||
1063 | /** @id MochiKit.DOM.DL */ | ||
1064 | this.DL = createDOMFunc("dl"); | ||
1065 | /** @id MochiKit.DOM.DT */ | ||
1066 | this.DT = createDOMFunc("dt"); | ||
1067 | /** @id MochiKit.DOM.FIELDSET */ | ||
1068 | this.FIELDSET = createDOMFunc("fieldset"); | ||
1069 | /** @id MochiKit.DOM.FIGURE */ | ||
1070 | this.FIGURE = createDOMFunc("figure"); | ||
1071 | /** @id MochiKit.DOM.FIGCAPTION */ | ||
1072 | this.FIGCAPTION = createDOMFunc("figcaption"); | ||
1073 | /** @id MochiKit.DOM.FOOTER */ | ||
1074 | this.FOOTER = createDOMFunc("footer"); | ||
1075 | /** @id MochiKit.DOM.FORM */ | ||
1076 | this.FORM = createDOMFunc("form"); | ||
1086 | /** @id MochiKit.DOM.H1 */ | 1077 | /** @id MochiKit.DOM.H1 */ |
1087 | this.H1 = createDOMFunc("h1"); | 1078 | this.H1 = createDOMFunc("h1"); |
1088 | /** @id MochiKit.DOM.H2 */ | 1079 | /** @id MochiKit.DOM.H2 */ |
1089 | this.H2 = createDOMFunc("h2"); | 1080 | this.H2 = createDOMFunc("h2"); |
@@ -1094,40 +1085,84 @@ MochiKit.Base.update(MochiKit.DOM, { | |||
1094 | /** @id MochiKit.DOM.H5 */ | 1085 | /** @id MochiKit.DOM.H5 */ |
1095 | this.H5 = createDOMFunc("h5"); | 1086 | this.H5 = createDOMFunc("h5"); |
1096 | /** @id MochiKit.DOM.H6 */ | 1087 | /** @id MochiKit.DOM.H6 */ |
1097 | this.H6 = createDOMFunc("h6"); | 1088 | this.H6 = createDOMFunc("h6"); |
1098 | /** @id MochiKit.DOM.BR */ | 1089 | /** @id MochiKit.DOM.HEADER */ |
1099 | this.BR = createDOMFunc("br"); | 1090 | this.HEADER = createDOMFunc("header"); |
1091 | /** @id MochiKit.DOM.HGROUP */ | ||
1092 | this.HGROUP = createDOMFunc("hgroup"); | ||
1100 | /** @id MochiKit.DOM.HR */ | 1093 | /** @id MochiKit.DOM.HR */ |
1101 | this.HR = createDOMFunc("hr"); | 1094 | this.HR = createDOMFunc("hr"); |
1095 | /** @id MochiKit.DOM.IFRAME */ | ||
1096 | this.IFRAME = createDOMFunc("iframe"); | ||
1097 | /** @id MochiKit.DOM.IMG */ | ||
1098 | this.IMG = createDOMFunc("img"); | ||
1099 | /** @id MochiKit.DOM.INPUT */ | ||
1100 | this.INPUT = createDOMFunc("input"); | ||
1102 | /** @id MochiKit.DOM.LABEL */ | 1101 | /** @id MochiKit.DOM.LABEL */ |
1103 | this.LABEL = createDOMFunc("label"); | 1102 | this.LABEL = createDOMFunc("label"); |
1104 | /** @id MochiKit.DOM.TEXTAREA */ | 1103 | /** @id MochiKit.DOM.LEGEND */ |
1105 | this.TEXTAREA = createDOMFunc("textarea"); | 1104 | this.LEGEND = createDOMFunc("legend"); |
1106 | /** @id MochiKit.DOM.FORM */ | 1105 | /** @id MochiKit.DOM.LI */ |
1107 | this.FORM = createDOMFunc("form"); | 1106 | this.LI = createDOMFunc("li"); |
1107 | /** @id MochiKit.DOM.LINK */ | ||
1108 | this.LINK = createDOMFunc("link"); | ||
1109 | /** @id MochiKit.DOM.MARK */ | ||
1110 | this.MARK = createDOMFunc("mark"); | ||
1111 | /** @id MochiKit.DOM.METER */ | ||
1112 | this.METER = createDOMFunc("meter"); | ||
1113 | /** @id MochiKit.DOM.NAV */ | ||
1114 | this.NAV = createDOMFunc("nav"); | ||
1115 | /** @id MochiKit.DOM.OL */ | ||
1116 | this.OL = createDOMFunc("ol"); | ||
1117 | /** @id MochiKit.DOM.OPTGROUP */ | ||
1118 | this.OPTGROUP = createDOMFunc("optgroup"); | ||
1119 | /** @id MochiKit.DOM.OPTION */ | ||
1120 | this.OPTION = createDOMFunc("option"); | ||
1108 | /** @id MochiKit.DOM.P */ | 1121 | /** @id MochiKit.DOM.P */ |
1109 | this.P = createDOMFunc("p"); | 1122 | this.P = createDOMFunc("p"); |
1123 | /** @id MochiKit.DOM.PRE */ | ||
1124 | this.PRE = createDOMFunc("pre"); | ||
1125 | /** @id MochiKit.DOM.PROGRESS */ | ||
1126 | this.PROGRESS = createDOMFunc("progress"); | ||
1127 | /** @id MochiKit.DOM.SCRIPT */ | ||
1128 | this.SCRIPT = createDOMFunc("script"); | ||
1129 | /** @id MochiKit.DOM.SECTION */ | ||
1130 | this.SECTION = createDOMFunc("section"); | ||
1110 | /** @id MochiKit.DOM.SELECT */ | 1131 | /** @id MochiKit.DOM.SELECT */ |
1111 | this.SELECT = createDOMFunc("select"); | 1132 | this.SELECT = createDOMFunc("select"); |
1112 | /** @id MochiKit.DOM.OPTION */ | 1133 | /** @id MochiKit.DOM.SPAN */ |
1113 | this.OPTION = createDOMFunc("option"); | 1134 | this.SPAN = createDOMFunc("span"); |
1114 | /** @id MochiKit.DOM.OPTGROUP */ | ||
1115 | this.OPTGROUP = createDOMFunc("optgroup"); | ||
1116 | /** @id MochiKit.DOM.LEGEND */ | ||
1117 | this.LEGEND = createDOMFunc("legend"); | ||
1118 | /** @id MochiKit.DOM.FIELDSET */ | ||
1119 | this.FIELDSET = createDOMFunc("fieldset"); | ||
1120 | /** @id MochiKit.DOM.STRONG */ | 1135 | /** @id MochiKit.DOM.STRONG */ |
1121 | this.STRONG = createDOMFunc("strong"); | 1136 | this.STRONG = createDOMFunc("strong"); |
1122 | /** @id MochiKit.DOM.CANVAS */ | 1137 | /** @id MochiKit.DOM.STYLE */ |
1123 | this.CANVAS = createDOMFunc("canvas"); | 1138 | this.STYLE = createDOMFunc("style"); |
1124 | 1139 | /** @id MochiKit.DOM.TABLE */ | |
1140 | this.TABLE = createDOMFunc("table"); | ||
1141 | /** @id MochiKit.DOM.TBODY */ | ||
1142 | this.TBODY = createDOMFunc("tbody"); | ||
1143 | /** @id MochiKit.DOM.TD */ | ||
1144 | this.TD = createDOMFunc("td"); | ||
1145 | /** @id MochiKit.DOM.TEXTAREA */ | ||
1146 | this.TEXTAREA = createDOMFunc("textarea"); | ||
1147 | /** @id MochiKit.DOM.TFOOT */ | ||
1148 | this.TFOOT = createDOMFunc("tfoot"); | ||
1149 | /** @id MochiKit.DOM.TH */ | ||
1150 | this.TH = createDOMFunc("th"); | ||
1151 | /** @id MochiKit.DOM.THEAD */ | ||
1152 | this.THEAD = createDOMFunc("thead"); | ||
1153 | /** @id MochiKit.DOM.TR */ | ||
1154 | this.TR = createDOMFunc("tr"); | ||
1155 | /** @id MochiKit.DOM.TT */ | ||
1156 | this.TT = createDOMFunc("tt"); | ||
1157 | /** @id MochiKit.DOM.UL */ | ||
1158 | this.UL = createDOMFunc("ul"); | ||
1159 | /** @id MochiKit.DOM.NBSP */ | ||
1160 | this.NBSP = "\u00a0"; | ||
1125 | /** @id MochiKit.DOM.$ */ | 1161 | /** @id MochiKit.DOM.$ */ |
1126 | this.$ = this.getElement; | 1162 | this.$ = this.getElement; |
1127 | 1163 | ||
1128 | m.nameFunctions(this); | 1164 | m.nameFunctions(this); |
1129 | |||
1130 | } | 1165 | } |
1131 | }); | 1166 | }); |
1132 | 1167 | ||
1133 | 1168 | ||
diff --git a/frontend/gamma/js/MochiKit/DateTime.js b/frontend/gamma/js/MochiKit/DateTime.js index c7b2d25..658084c 100644 --- a/frontend/gamma/js/MochiKit/DateTime.js +++ b/frontend/gamma/js/MochiKit/DateTime.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('DateTime', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'DateTime', '1.5', ['Base']); |
12 | 12 | ||
13 | /** @id MochiKit.DateTime.isoDate */ | 13 | /** @id MochiKit.DateTime.isoDate */ |
14 | MochiKit.DateTime.isoDate = function (str) { | 14 | MochiKit.DateTime.isoDate = function (str) { |
15 | str = str + ""; | 15 | str = str + ""; |
@@ -19,9 +19,9 @@ MochiKit.DateTime.isoDate = function (str) { | |||
19 | var iso = str.split('-'); | 19 | var iso = str.split('-'); |
20 | if (iso.length === 0) { | 20 | if (iso.length === 0) { |
21 | return null; | 21 | return null; |
22 | } | 22 | } |
23 | var date = new Date(iso[0], iso[1] - 1, iso[2]); | 23 | var date = new Date(parseInt(iso[0], 10), parseInt(iso[1], 10) - 1, parseInt(iso[2], 10)); |
24 | date.setFullYear(iso[0]); | 24 | date.setFullYear(iso[0]); |
25 | date.setMonth(iso[1] - 1); | 25 | date.setMonth(iso[1] - 1); |
26 | date.setDate(iso[2]); | 26 | date.setDate(iso[2]); |
27 | return date; | 27 | return date; |
@@ -79,30 +79,33 @@ MochiKit.DateTime.isoTimestamp = function (str) { | |||
79 | MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { | 79 | MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { |
80 | if (typeof(date) == "undefined" || date === null) { | 80 | if (typeof(date) == "undefined" || date === null) { |
81 | return null; | 81 | return null; |
82 | } | 82 | } |
83 | var hh = date.getHours(); | 83 | var _padTwo = MochiKit.DateTime._padTwo; |
84 | var mm = date.getMinutes(); | 84 | if (realISO) { |
85 | var ss = date.getSeconds(); | 85 | // adjust date for UTC timezone |
86 | date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); | ||
87 | } | ||
86 | var lst = [ | 88 | var lst = [ |
87 | ((realISO && (hh < 10)) ? "0" + hh : hh), | 89 | (realISO ? _padTwo(date.getHours()) : date.getHours()), |
88 | ((mm < 10) ? "0" + mm : mm), | 90 | _padTwo(date.getMinutes()), |
89 | ((ss < 10) ? "0" + ss : ss) | 91 | _padTwo(date.getSeconds()) |
90 | ]; | 92 | ]; |
91 | return lst.join(":"); | 93 | return lst.join(":") + (realISO ? "Z" : ""); |
92 | }; | 94 | }; |
93 | 95 | ||
94 | /** @id MochiKit.DateTime.toISOTimeStamp */ | 96 | /** @id MochiKit.DateTime.toISOTimeStamp */ |
95 | MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { | 97 | MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { |
96 | if (typeof(date) == "undefined" || date === null) { | 98 | if (typeof(date) == "undefined" || date === null) { |
97 | return null; | 99 | return null; |
98 | } | 100 | } |
101 | var time = MochiKit.DateTime.toISOTime(date, realISO); | ||
99 | var sep = realISO ? "T" : " "; | 102 | var sep = realISO ? "T" : " "; |
100 | var foot = realISO ? "Z" : ""; | ||
101 | if (realISO) { | 103 | if (realISO) { |
104 | // adjust date for UTC timezone | ||
102 | date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); | 105 | date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); |
103 | } | 106 | } |
104 | return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot; | 107 | return MochiKit.DateTime.toISODate(date) + sep + time; |
105 | }; | 108 | }; |
106 | 109 | ||
107 | /** @id MochiKit.DateTime.toISODate */ | 110 | /** @id MochiKit.DateTime.toISODate */ |
108 | MochiKit.DateTime.toISODate = function (date) { | 111 | MochiKit.DateTime.toISODate = function (date) { |
diff --git a/frontend/gamma/js/MochiKit/DragAndDrop.js b/frontend/gamma/js/MochiKit/DragAndDrop.js index 62777c5..cf84f77 100644 --- a/frontend/gamma/js/MochiKit/DragAndDrop.js +++ b/frontend/gamma/js/MochiKit/DragAndDrop.js | |||
@@ -7,9 +7,9 @@ Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |||
7 | Mochi-ized By Thomas Herve (_firstname_@nimail.org) | 7 | Mochi-ized By Thomas Herve (_firstname_@nimail.org) |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); | 11 | MochiKit.Base.module(MochiKit, 'DragAndDrop', '1.5', ['Base', 'Iter', 'DOM', 'Signal', 'Visual', 'Position']); |
12 | 12 | ||
13 | MochiKit.DragAndDrop.Droppables = { | 13 | MochiKit.DragAndDrop.Droppables = { |
14 | /*** | 14 | /*** |
15 | 15 | ||
@@ -305,10 +305,11 @@ MochiKit.DragAndDrop.Draggables = { | |||
305 | } | 305 | } |
306 | var pointer = event.mouse(); | 306 | var pointer = event.mouse(); |
307 | // Mozilla-based browsers fire successive mousemove events with | 307 | // Mozilla-based browsers fire successive mousemove events with |
308 | // the same coordinates, prevent needless redrawing (moz bug?) | 308 | // the same coordinates, prevent needless redrawing (moz bug?) |
309 | if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) == | 309 | if (this._lastPointer && |
310 | MochiKit.Base.repr(pointer.page))) { | 310 | this._lastPointer.page.x == pointer.page.x && |
311 | this._lastPointer.page.y == pointer.page.y) { | ||
311 | return; | 312 | return; |
312 | } | 313 | } |
313 | this._lastPointer = pointer; | 314 | this._lastPointer = pointer; |
314 | this.activeDraggable.updateDrag(event, pointer); | 315 | this.activeDraggable.updateDrag(event, pointer); |
@@ -441,10 +442,10 @@ MochiKit.DragAndDrop.Draggable.prototype = { | |||
441 | /** @id MochiKit.DragAndDrop.currentDelta */ | 442 | /** @id MochiKit.DragAndDrop.currentDelta */ |
442 | currentDelta: function () { | 443 | currentDelta: function () { |
443 | var s = MochiKit.Style.getStyle; | 444 | var s = MochiKit.Style.getStyle; |
444 | return [ | 445 | return [ |
445 | parseInt(s(this.element, 'left') || '0'), | 446 | parseInt(s(this.element, 'left') || '0', 10), |
446 | parseInt(s(this.element, 'top') || '0')]; | 447 | parseInt(s(this.element, 'top') || '0', 10)]; |
447 | }, | 448 | }, |
448 | 449 | ||
449 | /** @id MochiKit.DragAndDrop.initDrag */ | 450 | /** @id MochiKit.DragAndDrop.initDrag */ |
450 | initDrag: function (event) { | 451 | initDrag: function (event) { |
@@ -480,10 +481,9 @@ MochiKit.DragAndDrop.Draggable.prototype = { | |||
480 | MochiKit.DOM.addElementClass(this.element, | 481 | MochiKit.DOM.addElementClass(this.element, |
481 | this.options.selectclass); | 482 | this.options.selectclass); |
482 | } | 483 | } |
483 | if (this.options.zindex) { | 484 | if (this.options.zindex) { |
484 | this.originalZ = parseInt(MochiKit.Style.getStyle(this.element, | 485 | this.originalZ = MochiKit.Style.getStyle(this.element, 'z-index'); |
485 | 'z-index') || '0'); | ||
486 | this.element.style.zIndex = this.options.zindex; | 486 | this.element.style.zIndex = this.options.zindex; |
487 | } | 487 | } |
488 | 488 | ||
489 | if (this.options.ghosting) { | 489 | if (this.options.ghosting) { |
diff --git a/frontend/gamma/js/MochiKit/Format.js b/frontend/gamma/js/MochiKit/Format.js index 122845e..58877e7 100644 --- a/frontend/gamma/js/MochiKit/Format.js +++ b/frontend/gamma/js/MochiKit/Format.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Format', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'Format', '1.5', ['Base']); |
12 | 12 | ||
13 | MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) { | 13 | MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) { |
14 | return function (num) { | 14 | return function (num) { |
15 | num = parseFloat(num); | 15 | num = parseFloat(num); |
@@ -103,9 +103,9 @@ MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, loca | |||
103 | rval.repr = function () { | 103 | rval.repr = function () { |
104 | return [ | 104 | return [ |
105 | self.NAME, | 105 | self.NAME, |
106 | "(", | 106 | "(", |
107 | map(m.repr, args).join(", "), | 107 | m.map(m.repr, args).join(", "), |
108 | ")" | 108 | ")" |
109 | ].join(""); | 109 | ].join(""); |
110 | }; | 110 | }; |
111 | } | 111 | } |
@@ -141,9 +141,9 @@ MochiKit.Format.twoDigitAverage = function (numerator, denominator) { | |||
141 | }; | 141 | }; |
142 | 142 | ||
143 | /** @id MochiKit.Format.twoDigitFloat */ | 143 | /** @id MochiKit.Format.twoDigitFloat */ |
144 | MochiKit.Format.twoDigitFloat = function (aNumber) { | 144 | MochiKit.Format.twoDigitFloat = function (aNumber) { |
145 | var res = roundToFixed(aNumber, 2); | 145 | var res = MochiKit.Format.roundToFixed(aNumber, 2); |
146 | if (res.indexOf(".00") > 0) { | 146 | if (res.indexOf(".00") > 0) { |
147 | return res.substring(0, res.length - 3); | 147 | return res.substring(0, res.length - 3); |
148 | } else if (res.charAt(res.length - 1) == "0") { | 148 | } else if (res.charAt(res.length - 1) == "0") { |
149 | return res.substring(0, res.length - 1); | 149 | return res.substring(0, res.length - 1); |
@@ -192,9 +192,9 @@ MochiKit.Format.truncToFixed = function (aNumber, precision) { | |||
192 | fixed = fixed.substring(0, fracPos + precision + 1); | 192 | fixed = fixed.substring(0, fracPos + precision + 1); |
193 | fixed = MochiKit.Format._shiftNumber(fixed, 0); | 193 | fixed = MochiKit.Format._shiftNumber(fixed, 0); |
194 | } | 194 | } |
195 | return fixed; | 195 | return fixed; |
196 | } | 196 | }; |
197 | 197 | ||
198 | /** @id MochiKit.Format.roundToFixed */ | 198 | /** @id MochiKit.Format.roundToFixed */ |
199 | MochiKit.Format.roundToFixed = function (aNumber, precision) { | 199 | MochiKit.Format.roundToFixed = function (aNumber, precision) { |
200 | var fixed = MochiKit.Format._numberToFixed(aNumber, precision); | 200 | var fixed = MochiKit.Format._numberToFixed(aNumber, precision); |
@@ -204,9 +204,9 @@ MochiKit.Format.roundToFixed = function (aNumber, precision) { | |||
204 | str = MochiKit.Format._numberToFixed(Math.round(parseFloat(str)), 0); | 204 | str = MochiKit.Format._numberToFixed(Math.round(parseFloat(str)), 0); |
205 | fixed = MochiKit.Format._shiftNumber(str, -precision); | 205 | fixed = MochiKit.Format._shiftNumber(str, -precision); |
206 | } | 206 | } |
207 | return fixed; | 207 | return fixed; |
208 | } | 208 | }; |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * Converts a number to a fixed format string. This function handles | 211 | * Converts a number to a fixed format string. This function handles |
212 | * conversion of exponents by shifting the decimal point to the left | 212 | * conversion of exponents by shifting the decimal point to the left |
@@ -220,9 +220,9 @@ MochiKit.Format.roundToFixed = function (aNumber, precision) { | |||
220 | */ | 220 | */ |
221 | MochiKit.Format._numberToFixed = function (aNumber, precision) { | 221 | MochiKit.Format._numberToFixed = function (aNumber, precision) { |
222 | var str = aNumber.toString(); | 222 | var str = aNumber.toString(); |
223 | var parts = str.split(/[eE]/); | 223 | var parts = str.split(/[eE]/); |
224 | var exp = (parts.length === 1) ? 0 : parseInt(parts[1]) || 0; | 224 | var exp = (parts.length === 1) ? 0 : parseInt(parts[1], 10) || 0; |
225 | var fixed = MochiKit.Format._shiftNumber(parts[0], exp); | 225 | var fixed = MochiKit.Format._shiftNumber(parts[0], exp); |
226 | parts = fixed.split(/\./); | 226 | parts = fixed.split(/\./); |
227 | var whole = parts[0]; | 227 | var whole = parts[0]; |
228 | var frac = (parts.length === 1) ? "" : parts[1]; | 228 | var frac = (parts.length === 1) ? "" : parts[1]; |
@@ -233,9 +233,9 @@ MochiKit.Format._numberToFixed = function (aNumber, precision) { | |||
233 | return whole + "." + frac; | 233 | return whole + "." + frac; |
234 | } else { | 234 | } else { |
235 | return whole; | 235 | return whole; |
236 | } | 236 | } |
237 | } | 237 | }; |
238 | 238 | ||
239 | /** | 239 | /** |
240 | * Shifts the decimal dot location in a fixed format number string. | 240 | * Shifts the decimal dot location in a fixed format number string. |
241 | * This function handles negative values and will add and remove | 241 | * This function handles negative values and will add and remove |
@@ -274,9 +274,9 @@ MochiKit.Format._shiftNumber = function (num, exp) { | |||
274 | while (/^-0[^.]/.test(num)) { | 274 | while (/^-0[^.]/.test(num)) { |
275 | num = "-" + num.substring(2); | 275 | num = "-" + num.substring(2); |
276 | } | 276 | } |
277 | return num; | 277 | return num; |
278 | } | 278 | }; |
279 | 279 | ||
280 | /** @id MochiKit.Format.percentFormat */ | 280 | /** @id MochiKit.Format.percentFormat */ |
281 | MochiKit.Format.percentFormat = function (aNumber) { | 281 | MochiKit.Format.percentFormat = function (aNumber) { |
282 | return MochiKit.Format.twoDigitFloat(100 * aNumber) + '%'; | 282 | return MochiKit.Format.twoDigitFloat(100 * aNumber) + '%'; |
diff --git a/frontend/gamma/js/MochiKit/Iter.js b/frontend/gamma/js/MochiKit/Iter.js index 524b2bc..77623bc 100644 --- a/frontend/gamma/js/MochiKit/Iter.js +++ b/frontend/gamma/js/MochiKit/Iter.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Iter', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'Iter', '1.5', ['Base']); |
12 | 12 | ||
13 | MochiKit.Base.update(MochiKit.Iter, { | 13 | MochiKit.Base.update(MochiKit.Iter, { |
14 | /** @id MochiKit.Iter.registerIteratorFactory */ | 14 | /** @id MochiKit.Iter.registerIteratorFactory */ |
15 | registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) { | 15 | registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) { |
@@ -221,16 +221,17 @@ MochiKit.Base.update(MochiKit.Iter, { | |||
221 | return "islice(" + ["...", start, stop, step].join(", ") + ")"; | 221 | return "islice(" + ["...", start, stop, step].join(", ") + ")"; |
222 | }, | 222 | }, |
223 | toString: m.forwardCall("repr"), | 223 | toString: m.forwardCall("repr"), |
224 | next: function () { | 224 | next: function () { |
225 | if (start >= stop) { | ||
226 | throw self.StopIteration; | ||
227 | } | ||
228 | |||
225 | var rval; | 229 | var rval; |
226 | while (i < start) { | 230 | while (i < start) { |
227 | rval = seq.next(); | 231 | rval = seq.next(); |
228 | i++; | 232 | i++; |
229 | } | 233 | } |
230 | if (start >= stop) { | ||
231 | throw self.StopIteration; | ||
232 | } | ||
233 | start += step; | 234 | start += step; |
234 | return rval; | 235 | return rval; |
235 | } | 236 | } |
236 | }; | 237 | }; |
@@ -279,17 +280,14 @@ MochiKit.Base.update(MochiKit.Iter, { | |||
279 | toString: m.forwardCall("repr"), | 280 | toString: m.forwardCall("repr"), |
280 | next: function () { | 281 | next: function () { |
281 | while (argiter.length > 1) { | 282 | while (argiter.length > 1) { |
282 | try { | 283 | try { |
283 | var result = argiter[0].next(); | 284 | return argiter[0].next(); |
284 | return result; | ||
285 | } catch (e) { | 285 | } catch (e) { |
286 | if (e != self.StopIteration) { | 286 | if (e != self.StopIteration) { |
287 | throw e; | 287 | throw e; |
288 | } | 288 | } |
289 | argiter.shift(); | 289 | argiter.shift(); |
290 | var result = argiter[0].next(); | ||
291 | return result; | ||
292 | } | 290 | } |
293 | } | 291 | } |
294 | if (argiter.length == 1) { | 292 | if (argiter.length == 1) { |
295 | // optimize last element | 293 | // optimize last element |
@@ -412,9 +410,9 @@ MochiKit.Base.update(MochiKit.Iter, { | |||
412 | } | 410 | } |
413 | 411 | ||
414 | var self = MochiKit.Iter; | 412 | var self = MochiKit.Iter; |
415 | iterable = self.iter(iterable); | 413 | iterable = self.iter(iterable); |
416 | var rval = []; | 414 | rval = []; |
417 | var a_val; | 415 | var a_val; |
418 | try { | 416 | try { |
419 | while (true) { | 417 | while (true) { |
420 | a_val = iterable.next(); | 418 | a_val = iterable.next(); |
diff --git a/frontend/gamma/js/MochiKit/Logging.js b/frontend/gamma/js/MochiKit/Logging.js index f00996b..8b06e0b 100644 --- a/frontend/gamma/js/MochiKit/Logging.js +++ b/frontend/gamma/js/MochiKit/Logging.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Logging', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'Logging', '1.5', ['Base']); |
12 | 12 | ||
13 | /** @id MochiKit.Logging.LogMessage */ | 13 | /** @id MochiKit.Logging.LogMessage */ |
14 | MochiKit.Logging.LogMessage = function (num, level, info) { | 14 | MochiKit.Logging.LogMessage = function (num, level, info) { |
15 | this.num = num; | 15 | this.num = num; |
@@ -186,9 +186,9 @@ MochiKit.Logging.Logger.prototype = { | |||
186 | howMany = 30; | 186 | howMany = 30; |
187 | } | 187 | } |
188 | var messages = this.getMessages(howMany); | 188 | var messages = this.getMessages(howMany); |
189 | if (messages.length) { | 189 | if (messages.length) { |
190 | var lst = map(function (m) { | 190 | var lst = MochiKit.Base.map(function (m) { |
191 | return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' '); | 191 | return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' '); |
192 | }, messages); | 192 | }, messages); |
193 | lst.unshift('LAST ' + messages.length + ' MESSAGES:'); | 193 | lst.unshift('LAST ' + messages.length + ' MESSAGES:'); |
194 | return lst.join(''); | 194 | return lst.join(''); |
diff --git a/frontend/gamma/js/MochiKit/LoggingPane.js b/frontend/gamma/js/MochiKit/LoggingPane.js index c960c21..b7ea120 100644 --- a/frontend/gamma/js/MochiKit/LoggingPane.js +++ b/frontend/gamma/js/MochiKit/LoggingPane.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('LoggingPane', '1.5', ['Base', 'Logging']); | 11 | MochiKit.Base.module(MochiKit, 'LoggingPane', '1.5', ['Base', 'Logging']); |
12 | 12 | ||
13 | /** @id MochiKit.LoggingPane.createLoggingPane */ | 13 | /** @id MochiKit.LoggingPane.createLoggingPane */ |
14 | MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) { | 14 | MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) { |
15 | var m = MochiKit.LoggingPane; | 15 | var m = MochiKit.LoggingPane; |
@@ -23,9 +23,12 @@ MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) { | |||
23 | } | 23 | } |
24 | return m._loggingPane; | 24 | return m._loggingPane; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | /** @id MochiKit.LoggingPane.LoggingPane */ | 27 | /** |
28 | * @id MochiKit.LoggingPane.LoggingPane | ||
29 | * @constructor | ||
30 | */ | ||
28 | MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) { | 31 | MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) { |
29 | 32 | ||
30 | /* Use a div if inline, pop up a window if not */ | 33 | /* Use a div if inline, pop up a window if not */ |
31 | /* Create the elements */ | 34 | /* Create the elements */ |
@@ -145,9 +148,9 @@ MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = Moc | |||
145 | levelre = new RegExp(levelFilterField.value); | 148 | levelre = new RegExp(levelFilterField.value); |
146 | infore = new RegExp(infoFilterField.value); | 149 | infore = new RegExp(infoFilterField.value); |
147 | } catch(e) { | 150 | } catch(e) { |
148 | /* If there was an error with the regexes, do no filtering */ | 151 | /* If there was an error with the regexes, do no filtering */ |
149 | logDebug("Error in filter regex: " + e.message); | 152 | MochiKit.Logging.logDebug("Error in filter regex: " + e.message); |
150 | return null; | 153 | return null; |
151 | } | 154 | } |
152 | 155 | ||
153 | return function (msg) { | 156 | return function (msg) { |
@@ -183,9 +186,9 @@ MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = Moc | |||
183 | this.logger.removeListener(listenerId); | 186 | this.logger.removeListener(listenerId); |
184 | try { | 187 | try { |
185 | try { | 188 | try { |
186 | debugPane.loggingPane = null; | 189 | debugPane.loggingPane = null; |
187 | } catch(e) { logFatal("Bookmarklet was closed incorrectly."); } | 190 | } catch(e) { MochiKit.Logging.logFatal("Bookmarklet was closed incorrectly."); } |
188 | if (inline) { | 191 | if (inline) { |
189 | debugPane.parentNode.removeChild(debugPane); | 192 | debugPane.parentNode.removeChild(debugPane); |
190 | } else { | 193 | } else { |
191 | this.win.close(); | 194 | this.win.close(); |
@@ -223,9 +226,9 @@ MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = Moc | |||
223 | 226 | ||
224 | /** @id MochiKit.LoggingPane.filterOnEnter */ | 227 | /** @id MochiKit.LoggingPane.filterOnEnter */ |
225 | var filterOnEnter = bind(function (event) { | 228 | var filterOnEnter = bind(function (event) { |
226 | event = event || window.event; | 229 | event = event || window.event; |
227 | key = event.which || event.keyCode; | 230 | var key = event.which || event.keyCode; |
228 | if (key == 13) { | 231 | if (key == 13) { |
229 | this.buildAndApplyFilter(); | 232 | this.buildAndApplyFilter(); |
230 | } | 233 | } |
231 | }, this); | 234 | }, this); |
diff --git a/frontend/gamma/js/MochiKit/MochiKit.js b/frontend/gamma/js/MochiKit/MochiKit.js index 8e5be68..511e075 100644 --- a/frontend/gamma/js/MochiKit/MochiKit.js +++ b/frontend/gamma/js/MochiKit/MochiKit.js | |||
@@ -7,19 +7,16 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | if (typeof(MochiKit) == 'undefined') { | 11 | var MochiKit = MochiKit || {}; |
12 | MochiKit = {}; | ||
13 | } | ||
14 | 12 | ||
15 | if (typeof(MochiKit.MochiKit) == 'undefined') { | ||
16 | /** @id MochiKit.MochiKit */ | 13 | /** @id MochiKit.MochiKit */ |
17 | MochiKit.MochiKit = {}; | 14 | MochiKit.MochiKit = MochiKit.MochiKit || {}; |
18 | } | ||
19 | 15 | ||
20 | MochiKit.MochiKit.NAME = "MochiKit.MochiKit"; | 16 | MochiKit.MochiKit.NAME = "MochiKit.MochiKit"; |
21 | MochiKit.MochiKit.VERSION = "1.5"; | 17 | MochiKit.MochiKit.VERSION = "1.5"; |
18 | MochiKit.MochiKit.__export__ = false; | ||
22 | MochiKit.MochiKit.__repr__ = function () { | 19 | MochiKit.MochiKit.__repr__ = function () { |
23 | return "[" + this.NAME + " " + this.VERSION + "]"; | 20 | return "[" + this.NAME + " " + this.VERSION + "]"; |
24 | }; | 21 | }; |
25 | 22 | ||
diff --git a/frontend/gamma/js/MochiKit/MockDOM.js b/frontend/gamma/js/MochiKit/MockDOM.js index abdb54a..7e6d60b 100644 --- a/frontend/gamma/js/MochiKit/MockDOM.js +++ b/frontend/gamma/js/MochiKit/MockDOM.js | |||
@@ -7,18 +7,15 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | if (typeof(MochiKit) == "undefined") { | 11 | var MochiKit = MochiKit || {}; |
12 | MochiKit = {}; | ||
13 | } | ||
14 | 12 | ||
15 | if (typeof(MochiKit.MockDOM) == "undefined") { | 13 | MochiKit.MockDOM = MochiKit.MockDOM || {}; |
16 | MochiKit.MockDOM = {}; | ||
17 | } | ||
18 | 14 | ||
19 | MochiKit.MockDOM.NAME = "MochiKit.MockDOM"; | 15 | MochiKit.MockDOM.NAME = "MochiKit.MockDOM"; |
20 | MochiKit.MockDOM.VERSION = "1.5"; | 16 | MochiKit.MockDOM.VERSION = "1.5"; |
17 | MochiKit.MockDOM.__export__ = false; | ||
21 | 18 | ||
22 | MochiKit.MockDOM.__repr__ = function () { | 19 | MochiKit.MockDOM.__repr__ = function () { |
23 | return "[" + this.NAME + " " + this.VERSION + "]"; | 20 | return "[" + this.NAME + " " + this.VERSION + "]"; |
24 | }; | 21 | }; |
diff --git a/frontend/gamma/js/MochiKit/Position.js b/frontend/gamma/js/MochiKit/Position.js index 6bc5b39..2680507 100644 --- a/frontend/gamma/js/MochiKit/Position.js +++ b/frontend/gamma/js/MochiKit/Position.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005-2006 Bob Ippolito and others. All rights Reserved. | 7 | (c) 2005-2006 Bob Ippolito and others. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Position', '1.5', ['Base', 'DOM', 'Style']); | 11 | MochiKit.Base.module(MochiKit, 'Position', '1.5', ['Base', 'DOM', 'Style']); |
12 | 12 | ||
13 | MochiKit.Base.update(MochiKit.Position, { | 13 | MochiKit.Base.update(MochiKit.Position, { |
14 | // Don't export from this module | 14 | // Don't export from this module |
15 | __export__: false, | 15 | __export__: false, |
diff --git a/frontend/gamma/js/MochiKit/Selector.js b/frontend/gamma/js/MochiKit/Selector.js index 6aec892..3187fe9 100644 --- a/frontend/gamma/js/MochiKit/Selector.js +++ b/frontend/gamma/js/MochiKit/Selector.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito and others. All rights Reserved. | 7 | (c) 2005 Bob Ippolito and others. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Selector', '1.5', ['Base', 'DOM', 'Iter']); | 11 | MochiKit.Base.module(MochiKit, 'Selector', '1.5', ['Base', 'DOM', 'Iter']); |
12 | 12 | ||
13 | MochiKit.Selector.Selector = function (expression) { | 13 | MochiKit.Selector.Selector = function (expression) { |
14 | this.params = {classNames: [], pseudoClassNames: []}; | 14 | this.params = {classNames: [], pseudoClassNames: []}; |
15 | this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); | 15 | this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); |
@@ -126,10 +126,10 @@ MochiKit.Selector.Selector.prototype = { | |||
126 | } else if (match[0] == 'even') { | 126 | } else if (match[0] == 'even') { |
127 | a = 2; | 127 | a = 2; |
128 | b = 0; | 128 | b = 0; |
129 | } else { | 129 | } else { |
130 | a = match[2] && parseInt(match) || null; | 130 | a = match[2] && parseInt(match, 10) || null; |
131 | b = parseInt(match[3]); | 131 | b = parseInt(match[3], 10); |
132 | } | 132 | } |
133 | conditions.push('this.nthChild(element,' + a + ',' + b | 133 | conditions.push('this.nthChild(element,' + a + ',' + b |
134 | + ',' + !!pseudoClass.match('^nth-last') // Reverse | 134 | + ',' + !!pseudoClass.match('^nth-last') // Reverse |
135 | + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName | 135 | + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName |
@@ -166,9 +166,9 @@ MochiKit.Selector.Selector.prototype = { | |||
166 | conditions.push('(this.isUIElement(element) && element.checked === true)'); | 166 | conditions.push('(this.isUIElement(element) && element.checked === true)'); |
167 | break; | 167 | break; |
168 | case 'not': | 168 | case 'not': |
169 | var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); | 169 | var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); |
170 | conditions.push('!( ' + subselector.buildMatchExpression() + ')') | 170 | conditions.push('!( ' + subselector.buildMatchExpression() + ')'); |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -176,9 +176,9 @@ MochiKit.Selector.Selector.prototype = { | |||
176 | MochiKit.Base.map(function (attribute) { | 176 | MochiKit.Base.map(function (attribute) { |
177 | var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; | 177 | var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; |
178 | var splitValueBy = function (delimiter) { | 178 | var splitValueBy = function (delimiter) { |
179 | return value + '.split(' + repr(delimiter) + ')'; | 179 | return value + '.split(' + repr(delimiter) + ')'; |
180 | } | 180 | }; |
181 | conditions.push(value + ' != null'); | 181 | conditions.push(value + ' != null'); |
182 | switch (attribute.operator) { | 182 | switch (attribute.operator) { |
183 | case '=': | 183 | case '=': |
184 | conditions.push(value + ' == ' + repr(attribute.value)); | 184 | conditions.push(value + ' == ' + repr(attribute.value)); |
@@ -351,8 +351,14 @@ MochiKit.Base.update(MochiKit.Selector, { | |||
351 | } | 351 | } |
352 | return res; | 352 | return res; |
353 | }; | 353 | }; |
354 | return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { | 354 | return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { |
355 | try { | ||
356 | var res = element.querySelectorAll(expression); | ||
357 | return Array.prototype.slice.call(res, 0); | ||
358 | } catch (ignore) { | ||
359 | // No querySelectorAll or extended expression syntax used | ||
360 | } | ||
355 | var nextScope = ""; | 361 | var nextScope = ""; |
356 | var reducer = function (results, expr) { | 362 | var reducer = function (results, expr) { |
357 | var match = expr.match(/^[>+~]$/); | 363 | var match = expr.match(/^[>+~]$/); |
358 | if (match) { | 364 | if (match) { |
diff --git a/frontend/gamma/js/MochiKit/Signal.js b/frontend/gamma/js/MochiKit/Signal.js index 7df5619..11590c1 100644 --- a/frontend/gamma/js/MochiKit/Signal.js +++ b/frontend/gamma/js/MochiKit/Signal.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved. | 7 | (c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Signal', '1.5', ['Base', 'DOM', 'Style']); | 11 | MochiKit.Base.module(MochiKit, 'Signal', '1.5', ['Base', 'DOM']); |
12 | 12 | ||
13 | MochiKit.Signal._observers = []; | 13 | MochiKit.Signal._observers = []; |
14 | 14 | ||
15 | /** @id MochiKit.Signal.Event */ | 15 | /** @id MochiKit.Signal.Event */ |
@@ -265,18 +265,19 @@ MochiKit.Base.update(MochiKit.Signal.Event.prototype, { | |||
265 | var e = this._event; | 265 | var e = this._event; |
266 | 266 | ||
267 | if (this.type() && ( | 267 | if (this.type() && ( |
268 | this.type().indexOf('mouse') === 0 || | 268 | this.type().indexOf('mouse') === 0 || |
269 | this.type().indexOf('drag') === 0 || | ||
269 | this.type().indexOf('click') != -1 || | 270 | this.type().indexOf('click') != -1 || |
270 | this.type() == 'contextmenu')) { | 271 | this.type() == 'contextmenu')) { |
271 | 272 | ||
272 | m.client = new MochiKit.Style.Coordinates(0, 0); | 273 | m.client = { x: 0, y: 0 }; |
273 | if (e.clientX || e.clientY) { | 274 | if (e.clientX || e.clientY) { |
274 | m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX; | 275 | m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX; |
275 | m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY; | 276 | m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY; |
276 | } | 277 | } |
277 | 278 | ||
278 | m.page = new MochiKit.Style.Coordinates(0, 0); | 279 | m.page = { x: 0, y: 0 }; |
279 | if (e.pageX || e.pageY) { | 280 | if (e.pageX || e.pageY) { |
280 | m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX; | 281 | m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX; |
281 | m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY; | 282 | m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY; |
282 | } else { | 283 | } else { |
@@ -336,9 +337,9 @@ MochiKit.Base.update(MochiKit.Signal.Event.prototype, { | |||
336 | m.button.middle = !!(e.button & 4); | 337 | m.button.middle = !!(e.button & 4); |
337 | } | 338 | } |
338 | } | 339 | } |
339 | if (this.type() == 'mousewheel') { | 340 | if (this.type() == 'mousewheel') { |
340 | m.wheel = new MochiKit.Style.Coordinates(0, 0); | 341 | m.wheel = { x: 0, y: 0 }; |
341 | if (e.wheelDeltaX || e.wheelDeltaY) { | 342 | if (e.wheelDeltaX || e.wheelDeltaY) { |
342 | m.wheel.x = e.wheelDeltaX / -40 || 0; | 343 | m.wheel.x = e.wheelDeltaX / -40 || 0; |
343 | m.wheel.y = e.wheelDeltaY / -40 || 0; | 344 | m.wheel.y = e.wheelDeltaY / -40 || 0; |
344 | } else if (e.wheelDelta) { | 345 | } else if (e.wheelDelta) { |
@@ -671,8 +672,20 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
671 | 672 | ||
672 | return ident; | 673 | return ident; |
673 | }, | 674 | }, |
674 | 675 | ||
676 | /** @id MochiKit.Signal.connectOnce */ | ||
677 | connectOnce: function (src, sig, objOrFunc/* optional */, funcOrStr) { | ||
678 | var self = MochiKit.Signal; | ||
679 | var ident1 = self.connect(src, sig, objOrFunc, funcOrStr); | ||
680 | var ident2; | ||
681 | ident2 = self.connect(src, sig, function() { | ||
682 | self.disconnect(ident1); | ||
683 | self.disconnect(ident2); | ||
684 | }); | ||
685 | return ident1; | ||
686 | }, | ||
687 | |||
675 | _disconnect: function (ident) { | 688 | _disconnect: function (ident) { |
676 | // already disconnected | 689 | // already disconnected |
677 | if (!ident.connected) { | 690 | if (!ident.connected) { |
678 | return; | 691 | return; |
@@ -714,9 +727,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
714 | for (var i = observers.length - 1; i >= 0; i--) { | 727 | for (var i = observers.length - 1; i >= 0; i--) { |
715 | var o = observers[i]; | 728 | var o = observers[i]; |
716 | if (o.source === src && o.signal === sig && o.objOrFunc === obj && o.funcOrStr === func) { | 729 | if (o.source === src && o.signal === sig && o.objOrFunc === obj && o.funcOrStr === func) { |
717 | self._disconnect(o); | 730 | self._disconnect(o); |
718 | if (!self._lock) { | 731 | if (self._lock === 0) { |
719 | observers.splice(i, 1); | 732 | observers.splice(i, 1); |
720 | } else { | 733 | } else { |
721 | self._dirty = true; | 734 | self._dirty = true; |
722 | } | 735 | } |
@@ -726,9 +739,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
726 | } else { | 739 | } else { |
727 | var idx = m.findIdentical(observers, ident); | 740 | var idx = m.findIdentical(observers, ident); |
728 | if (idx >= 0) { | 741 | if (idx >= 0) { |
729 | self._disconnect(ident); | 742 | self._disconnect(ident); |
730 | if (!self._lock) { | 743 | if (self._lock === 0) { |
731 | observers.splice(idx, 1); | 744 | observers.splice(idx, 1); |
732 | } else { | 745 | } else { |
733 | self._dirty = true; | 746 | self._dirty = true; |
734 | } | 747 | } |
@@ -742,9 +755,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
742 | disconnectAllTo: function (objOrFunc, /* optional */funcOrStr) { | 755 | disconnectAllTo: function (objOrFunc, /* optional */funcOrStr) { |
743 | var self = MochiKit.Signal; | 756 | var self = MochiKit.Signal; |
744 | var observers = self._observers; | 757 | var observers = self._observers; |
745 | var disconnect = self._disconnect; | 758 | var disconnect = self._disconnect; |
746 | var locked = self._lock; | 759 | var lock = self._lock; |
747 | var dirty = self._dirty; | 760 | var dirty = self._dirty; |
748 | if (typeof(funcOrStr) === 'undefined') { | 761 | if (typeof(funcOrStr) === 'undefined') { |
749 | funcOrStr = null; | 762 | funcOrStr = null; |
750 | } | 763 | } |
@@ -752,12 +765,12 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
752 | var ident = observers[i]; | 765 | var ident = observers[i]; |
753 | if (ident.objOrFunc === objOrFunc && | 766 | if (ident.objOrFunc === objOrFunc && |
754 | (funcOrStr === null || ident.funcOrStr === funcOrStr)) { | 767 | (funcOrStr === null || ident.funcOrStr === funcOrStr)) { |
755 | disconnect(ident); | 768 | disconnect(ident); |
756 | if (locked) { | 769 | if (lock === 0) { |
757 | dirty = true; | ||
758 | } else { | ||
759 | observers.splice(i, 1); | 770 | observers.splice(i, 1); |
771 | } else { | ||
772 | dirty = true; | ||
760 | } | 773 | } |
761 | } | 774 | } |
762 | } | 775 | } |
763 | self._dirty = dirty; | 776 | self._dirty = dirty; |
@@ -773,17 +786,17 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
773 | var self = MochiKit.Signal; | 786 | var self = MochiKit.Signal; |
774 | var disconnect = self._disconnect; | 787 | var disconnect = self._disconnect; |
775 | var observers = self._observers; | 788 | var observers = self._observers; |
776 | var i, ident; | 789 | var i, ident; |
777 | var locked = self._lock; | 790 | var lock = self._lock; |
778 | var dirty = self._dirty; | 791 | var dirty = self._dirty; |
779 | if (signals.length === 0) { | 792 | if (signals.length === 0) { |
780 | // disconnect all | 793 | // disconnect all |
781 | for (i = observers.length - 1; i >= 0; i--) { | 794 | for (i = observers.length - 1; i >= 0; i--) { |
782 | ident = observers[i]; | 795 | ident = observers[i]; |
783 | if (ident.source === src) { | 796 | if (ident.source === src) { |
784 | disconnect(ident); | 797 | disconnect(ident); |
785 | if (!locked) { | 798 | if (lock === 0) { |
786 | observers.splice(i, 1); | 799 | observers.splice(i, 1); |
787 | } else { | 800 | } else { |
788 | dirty = true; | 801 | dirty = true; |
789 | } | 802 | } |
@@ -797,9 +810,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
797 | for (i = observers.length - 1; i >= 0; i--) { | 810 | for (i = observers.length - 1; i >= 0; i--) { |
798 | ident = observers[i]; | 811 | ident = observers[i]; |
799 | if (ident.source === src && ident.signal in sigs) { | 812 | if (ident.source === src && ident.signal in sigs) { |
800 | disconnect(ident); | 813 | disconnect(ident); |
801 | if (!locked) { | 814 | if (lock === 0) { |
802 | observers.splice(i, 1); | 815 | observers.splice(i, 1); |
803 | } else { | 816 | } else { |
804 | dirty = true; | 817 | dirty = true; |
805 | } | 818 | } |
@@ -817,9 +830,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
817 | src = MochiKit.DOM.getElement(src); | 830 | src = MochiKit.DOM.getElement(src); |
818 | } | 831 | } |
819 | var args = MochiKit.Base.extend(null, arguments, 2); | 832 | var args = MochiKit.Base.extend(null, arguments, 2); |
820 | var errors = []; | 833 | var errors = []; |
821 | self._lock = true; | 834 | self._lock++; |
822 | for (var i = 0; i < observers.length; i++) { | 835 | for (var i = 0; i < observers.length; i++) { |
823 | var ident = observers[i]; | 836 | var ident = observers[i]; |
824 | if (ident.source === src && ident.signal === sig && | 837 | if (ident.source === src && ident.signal === sig && |
825 | ident.connected) { | 838 | ident.connected) { |
@@ -836,10 +849,10 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
836 | errors.push(e); | 849 | errors.push(e); |
837 | } | 850 | } |
838 | } | 851 | } |
839 | } | 852 | } |
840 | self._lock = false; | 853 | self._lock--; |
841 | if (self._dirty) { | 854 | if (self._lock === 0 && self._dirty) { |
842 | self._dirty = false; | 855 | self._dirty = false; |
843 | for (var i = observers.length - 1; i >= 0; i--) { | 856 | for (var i = observers.length - 1; i >= 0; i--) { |
844 | if (!observers[i].connected) { | 857 | if (!observers[i].connected) { |
845 | observers.splice(i, 1); | 858 | observers.splice(i, 1); |
@@ -860,9 +873,9 @@ MochiKit.Base.update(MochiKit.Signal, { | |||
860 | MochiKit.Signal.__new__ = function (win) { | 873 | MochiKit.Signal.__new__ = function (win) { |
861 | var m = MochiKit.Base; | 874 | var m = MochiKit.Base; |
862 | this._document = document; | 875 | this._document = document; |
863 | this._window = win; | 876 | this._window = win; |
864 | this._lock = false; | 877 | this._lock = 0; |
865 | this._dirty = false; | 878 | this._dirty = false; |
866 | 879 | ||
867 | try { | 880 | try { |
868 | this.connect(window, 'onunload', this._unloadCache); | 881 | this.connect(window, 'onunload', this._unloadCache); |
diff --git a/frontend/gamma/js/MochiKit/Sortable.js b/frontend/gamma/js/MochiKit/Sortable.js index 863b506..ca9db21 100644 --- a/frontend/gamma/js/MochiKit/Sortable.js +++ b/frontend/gamma/js/MochiKit/Sortable.js | |||
@@ -5,9 +5,9 @@ Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |||
5 | See scriptaculous.js for full license. | 5 | See scriptaculous.js for full license. |
6 | 6 | ||
7 | ***/ | 7 | ***/ |
8 | 8 | ||
9 | MochiKit.Base._module('Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']); | 9 | MochiKit.Base.module(MochiKit, 'Sortable', '1.5', ['Base', 'Iter', 'DOM', 'Position', 'DragAndDrop']); |
10 | 10 | ||
11 | MochiKit.Base.update(MochiKit.Sortable, { | 11 | MochiKit.Base.update(MochiKit.Sortable, { |
12 | __export__: false, | 12 | __export__: false, |
13 | 13 | ||
@@ -178,17 +178,17 @@ MochiKit.Base.update(MochiKit.Sortable, { | |||
178 | hoverclass: options.hoverclass, | 178 | hoverclass: options.hoverclass, |
179 | onhover: self.onHover, | 179 | onhover: self.onHover, |
180 | tree: options.tree, | 180 | tree: options.tree, |
181 | accept: options.accept | 181 | accept: options.accept |
182 | } | 182 | }; |
183 | 183 | ||
184 | var options_for_tree = { | 184 | var options_for_tree = { |
185 | onhover: self.onEmptyHover, | 185 | onhover: self.onEmptyHover, |
186 | overlap: options.overlap, | 186 | overlap: options.overlap, |
187 | containment: options.containment, | 187 | containment: options.containment, |
188 | hoverclass: options.hoverclass, | 188 | hoverclass: options.hoverclass, |
189 | accept: options.accept | 189 | accept: options.accept |
190 | } | 190 | }; |
191 | 191 | ||
192 | // fix for gecko engine | 192 | // fix for gecko engine |
193 | MochiKit.DOM.removeEmptyTextNodes(element); | 193 | MochiKit.DOM.removeEmptyTextNodes(element); |
194 | 194 | ||
@@ -429,13 +429,13 @@ MochiKit.Base.update(MochiKit.Sortable, { | |||
429 | parent: parent, | 429 | parent: parent, |
430 | children: [], | 430 | children: [], |
431 | position: parent.children.length, | 431 | position: parent.children.length, |
432 | container: self._findChildrenElement(children[i], options.treeTag.toUpperCase()) | 432 | container: self._findChildrenElement(children[i], options.treeTag.toUpperCase()) |
433 | } | 433 | }; |
434 | 434 | ||
435 | /* Get the element containing the children and recurse over it */ | 435 | /* Get the element containing the children and recurse over it */ |
436 | if (child.container) { | 436 | if (child.container) { |
437 | self._tree(child.container, options, child) | 437 | self._tree(child.container, options, child); |
438 | } | 438 | } |
439 | 439 | ||
440 | parent.children.push (child); | 440 | parent.children.push (child); |
441 | } | 441 | } |
@@ -474,9 +474,9 @@ MochiKit.Base.update(MochiKit.Sortable, { | |||
474 | parent: null, | 474 | parent: null, |
475 | children: new Array, | 475 | children: new Array, |
476 | container: element, | 476 | container: element, |
477 | position: 0 | 477 | position: 0 |
478 | } | 478 | }; |
479 | 479 | ||
480 | return MochiKit.Sortable._tree(element, options, root); | 480 | return MochiKit.Sortable._tree(element, options, root); |
481 | }, | 481 | }, |
482 | 482 | ||
diff --git a/frontend/gamma/js/MochiKit/Style.js b/frontend/gamma/js/MochiKit/Style.js index 7f10117..740fd2f 100644 --- a/frontend/gamma/js/MochiKit/Style.js +++ b/frontend/gamma/js/MochiKit/Style.js | |||
@@ -5,11 +5,14 @@ MochiKit.Style 1.5 | |||
5 | See <http://mochikit.com/> for documentation, downloads, license, etc. | 5 | See <http://mochikit.com/> for documentation, downloads, license, etc. |
6 | 6 | ||
7 | (c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. | 7 | (c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. |
8 | 8 | ||
9 | The MochiKit.Style.getElementPosition function is adapted from | ||
10 | YAHOO.util.Dom.getXY v0.9.0. which is copyrighted by Yahoo! Inc. | ||
11 | |||
9 | ***/ | 12 | ***/ |
10 | 13 | ||
11 | MochiKit.Base._module('Style', '1.5', ['Base', 'DOM']); | 14 | MochiKit.Base.module(MochiKit, 'Style', '1.5', ['Base', 'DOM']); |
12 | 15 | ||
13 | 16 | ||
14 | /** @id MochiKit.Style.Dimensions */ | 17 | /** @id MochiKit.Style.Dimensions */ |
15 | MochiKit.Style.Dimensions = function (w, h) { | 18 | MochiKit.Style.Dimensions = function (w, h) { |
@@ -178,9 +181,9 @@ MochiKit.Base.update(MochiKit.Style, { | |||
178 | return o != null && | 181 | return o != null && |
179 | o.nodeType == null && | 182 | o.nodeType == null && |
180 | typeof(o.x) == "number" && | 183 | typeof(o.x) == "number" && |
181 | typeof(o.y) == "number"; | 184 | typeof(o.y) == "number"; |
182 | } | 185 | }; |
183 | 186 | ||
184 | if (typeof(elem) == "string") { | 187 | if (typeof(elem) == "string") { |
185 | elem = dom.getElement(elem); | 188 | elem = dom.getElement(elem); |
186 | } | 189 | } |
@@ -196,9 +199,9 @@ MochiKit.Base.update(MochiKit.Style, { | |||
196 | var d = MochiKit.DOM._document; | 199 | var d = MochiKit.DOM._document; |
197 | var de = d.documentElement; | 200 | var de = d.documentElement; |
198 | var b = d.body; | 201 | var b = d.body; |
199 | 202 | ||
200 | if (!elem.parentNode && elem.x && elem.y) { | 203 | if (isCoordinates(elem)) { |
201 | /* it's just a MochiKit.Style.Coordinates object */ | 204 | /* it's just a MochiKit.Style.Coordinates object */ |
202 | c.x += elem.x || 0; | 205 | c.x += elem.x || 0; |
203 | c.y += elem.y || 0; | 206 | c.y += elem.y || 0; |
204 | } else if (elem.getBoundingClientRect) { // IE shortcut | 207 | } else if (elem.getBoundingClientRect) { // IE shortcut |
@@ -227,10 +230,10 @@ MochiKit.Base.update(MochiKit.Style, { | |||
227 | parent = elem.offsetParent; | 230 | parent = elem.offsetParent; |
228 | 231 | ||
229 | if (parent != elem) { | 232 | if (parent != elem) { |
230 | while (parent) { | 233 | while (parent) { |
231 | c.x += parseInt(parent.style.borderLeftWidth) || 0; | 234 | c.x += parseInt(parent.style.borderLeftWidth, 10) || 0; |
232 | c.y += parseInt(parent.style.borderTopWidth) || 0; | 235 | c.y += parseInt(parent.style.borderTopWidth, 10) || 0; |
233 | c.x += parent.offsetLeft; | 236 | c.x += parent.offsetLeft; |
234 | c.y += parent.offsetTop; | 237 | c.y += parent.offsetTop; |
235 | parent = parent.offsetParent; | 238 | parent = parent.offsetParent; |
236 | } | 239 | } |
@@ -389,9 +392,9 @@ MochiKit.Base.update(MochiKit.Style, { | |||
389 | } | 392 | } |
390 | if (contentSize) { | 393 | if (contentSize) { |
391 | var tableCell = 'colSpan' in elem && 'rowSpan' in elem; | 394 | var tableCell = 'colSpan' in elem && 'rowSpan' in elem; |
392 | var collapse = (tableCell && elem.parentNode && self.getStyle( | 395 | var collapse = (tableCell && elem.parentNode && self.getStyle( |
393 | elem.parentNode, 'borderCollapse') == 'collapse') | 396 | elem.parentNode, 'borderCollapse') == 'collapse'); |
394 | if (collapse) { | 397 | if (collapse) { |
395 | if (/MSIE/.test(navigator.userAgent)) { | 398 | if (/MSIE/.test(navigator.userAgent)) { |
396 | var borderLeftQuota = elem.previousSibling? 0.5 : 1; | 399 | var borderLeftQuota = elem.previousSibling? 0.5 : 1; |
397 | var borderRightQuota = elem.nextSibling? 0.5 : 1; | 400 | var borderRightQuota = elem.nextSibling? 0.5 : 1; |
@@ -542,10 +545,10 @@ MochiKit.Base.update(MochiKit.Style, { | |||
542 | this._defaultDisplay[inlines[i]] = 'inline'; | 545 | this._defaultDisplay[inlines[i]] = 'inline'; |
543 | } | 546 | } |
544 | 547 | ||
545 | // Backwards compatibility aliases | 548 | // Backwards compatibility aliases |
546 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3'); | 549 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3', true); |
547 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3'); | 550 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3', true); |
548 | 551 | ||
549 | this.hideElement = m.partial(this.setDisplayForElement, 'none'); | 552 | this.hideElement = m.partial(this.setDisplayForElement, 'none'); |
550 | // TODO: showElement could be improved by using getDefaultDisplay. | 553 | // TODO: showElement could be improved by using getDefaultDisplay. |
551 | this.showElement = m.partial(this.setDisplayForElement, 'block'); | 554 | this.showElement = m.partial(this.setDisplayForElement, 'block'); |
diff --git a/frontend/gamma/js/MochiKit/Test.js b/frontend/gamma/js/MochiKit/Test.js index 9520ab2..f29670f 100644 --- a/frontend/gamma/js/MochiKit/Test.js +++ b/frontend/gamma/js/MochiKit/Test.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito. All rights Reserved. | 7 | (c) 2005 Bob Ippolito. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Test', '1.5', ['Base']); | 11 | MochiKit.Base.module(MochiKit, 'Test', '1.5', ['Base']); |
12 | 12 | ||
13 | MochiKit.Test.runTests = function (obj) { | 13 | MochiKit.Test.runTests = function (obj) { |
14 | if (typeof(obj) == "string") { | 14 | if (typeof(obj) == "string") { |
15 | // TODO: Remove this temporary API change advertisement | 15 | // TODO: Remove this temporary API change advertisement |
diff --git a/frontend/gamma/js/MochiKit/Text.js b/frontend/gamma/js/MochiKit/Text.js index a44f7e4..ff6366d 100644 --- a/frontend/gamma/js/MochiKit/Text.js +++ b/frontend/gamma/js/MochiKit/Text.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2008 Per Cederberg. All rights Reserved. | 7 | (c) 2008 Per Cederberg. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Text', '1.5', ['Base', 'Format']); | 11 | MochiKit.Base.module(MochiKit, 'Text', '1.5', ['Base', 'Format']); |
12 | 12 | ||
13 | /** | 13 | /** |
14 | * Checks if a text string starts with the specified substring. If | 14 | * Checks if a text string starts with the specified substring. If |
15 | * either of the two strings is null, false will be returned. | 15 | * either of the two strings is null, false will be returned. |
@@ -21,9 +21,9 @@ MochiKit.Base._module('Text', '1.5', ['Base', 'Format']); | |||
21 | * false otherwise | 21 | * false otherwise |
22 | */ | 22 | */ |
23 | MochiKit.Text.startsWith = function (substr, str) { | 23 | MochiKit.Text.startsWith = function (substr, str) { |
24 | return str != null && substr != null && str.indexOf(substr) == 0; | 24 | return str != null && substr != null && str.indexOf(substr) == 0; |
25 | } | 25 | }; |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * Checks if a text string ends with the specified substring. If | 28 | * Checks if a text string ends with the specified substring. If |
29 | * either of the two strings is null, false will be returned. | 29 | * either of the two strings is null, false will be returned. |
@@ -36,9 +36,9 @@ MochiKit.Text.startsWith = function (substr, str) { | |||
36 | */ | 36 | */ |
37 | MochiKit.Text.endsWith = function (substr, str) { | 37 | MochiKit.Text.endsWith = function (substr, str) { |
38 | return str != null && substr != null && | 38 | return str != null && substr != null && |
39 | str.lastIndexOf(substr) == Math.max(str.length - substr.length, 0); | 39 | str.lastIndexOf(substr) == Math.max(str.length - substr.length, 0); |
40 | } | 40 | }; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Checks if a text string contains the specified substring. If | 43 | * Checks if a text string contains the specified substring. If |
44 | * either of the two strings is null, false will be returned. | 44 | * either of the two strings is null, false will be returned. |
@@ -50,9 +50,9 @@ MochiKit.Text.endsWith = function (substr, str) { | |||
50 | * false otherwise | 50 | * false otherwise |
51 | */ | 51 | */ |
52 | MochiKit.Text.contains = function (substr, str) { | 52 | MochiKit.Text.contains = function (substr, str) { |
53 | return str != null && substr != null && str.indexOf(substr) >= 0; | 53 | return str != null && substr != null && str.indexOf(substr) >= 0; |
54 | } | 54 | }; |
55 | 55 | ||
56 | /** | 56 | /** |
57 | * Adds a character to the left-hand side of a string until it | 57 | * Adds a character to the left-hand side of a string until it |
58 | * reaches the specified minimum length. | 58 | * reaches the specified minimum length. |
@@ -70,9 +70,9 @@ MochiKit.Text.padLeft = function (str, minLength, fillChar) { | |||
70 | while (str.length < minLength) { | 70 | while (str.length < minLength) { |
71 | str = fillChar + str; | 71 | str = fillChar + str; |
72 | } | 72 | } |
73 | return str; | 73 | return str; |
74 | } | 74 | }; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Adds a character to the right-hand side of a string until it | 77 | * Adds a character to the right-hand side of a string until it |
78 | * reaches the specified minimum length. | 78 | * reaches the specified minimum length. |
@@ -90,9 +90,9 @@ MochiKit.Text.padRight = function (str, minLength, fillChar) { | |||
90 | while (str.length < minLength) { | 90 | while (str.length < minLength) { |
91 | str += fillChar; | 91 | str += fillChar; |
92 | } | 92 | } |
93 | return str; | 93 | return str; |
94 | } | 94 | }; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * Returns a truncated copy of a string. If the string is shorter | 97 | * Returns a truncated copy of a string. If the string is shorter |
98 | * than the specified maximum length, the object will be returned | 98 | * than the specified maximum length, the object will be returned |
@@ -118,31 +118,57 @@ MochiKit.Text.truncate = function (str, maxLength, tail) { | |||
118 | } | 118 | } |
119 | } else { | 119 | } else { |
120 | return str.slice(0, maxLength); | 120 | return str.slice(0, maxLength); |
121 | } | 121 | } |
122 | } | 122 | }; |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Splits a text string, applies a function and joins the results | 125 | * Splits a text string using separator as the split point |
126 | * back together again. This is a convenience function for calling | 126 | * If max is given, at most max splits are done, giving at most |
127 | * split(), map() and join() separately. It can be used to easily | 127 | * max + 1 elements in the returned list. |
128 | * trim each line in a text string (using the strip function), or to | ||
129 | * translate a text word-by-word. | ||
130 | * | 128 | * |
131 | * @param {Function} func the function to apply | ||
132 | * @param {String} str the string to split | 129 | * @param {String} str the string to split |
133 | * @param {String} [separator] the separator character to use, | 130 | * @param {String/RegExp} [separator] the separator char or regexp to use, |
134 | * defaults to newline | 131 | * defaults to newline |
132 | * @param {Number} [max] the maximum number of parts to return | ||
133 | * @return {Array} an array of parts of the string | ||
134 | */ | ||
135 | MochiKit.Text.split = function (str, separator, max) { | ||
136 | if (str == null) { | ||
137 | return str; | ||
138 | } | ||
139 | separator = separator || '\n'; | ||
140 | var bits = str.split(separator); | ||
141 | if ((typeof(max) == "undefined") || max >= bits.length - 1) { | ||
142 | return bits; | ||
143 | } | ||
144 | bits.splice(max, bits.length, bits.slice(max, bits.length).join(separator)); | ||
145 | return bits; | ||
146 | }; | ||
147 | |||
148 | /** | ||
149 | * Splits a text string using separator as the split point | ||
150 | * If max is given, at most max splits are done, | ||
151 | * using splits from the right | ||
135 | * | 152 | * |
136 | * @return {String} a string with the joined up results | 153 | * @param {String} str the string to split |
154 | * @param {String/RegExp} [separator] the separator char or regexp to use, | ||
155 | * defaults to newline | ||
156 | * @param {Number} [max] the maximum number of parts to return | ||
157 | * @return {Array} an array of parts of the string | ||
137 | */ | 158 | */ |
138 | MochiKit.Text.splitJoin = function (func, str, separator) { | 159 | MochiKit.Text.rsplit = function (str, separator, max) { |
139 | if (str == null || str.length == 0) { | 160 | if (str == null) { |
140 | return str; | 161 | return str; |
141 | } | 162 | } |
142 | separator = separator || '\n' | 163 | separator = separator || '\n'; |
143 | return MochiKit.Base.map(func, str.split(separator)).join(separator); | 164 | var bits = str.split(separator); |
165 | if ((typeof(max) == "undefined") || max >= bits.length - 1){ | ||
166 | return bits; | ||
144 | } | 167 | } |
168 | bits.splice(0, bits.length-max, bits.slice(0, bits.length-max).join(separator)); | ||
169 | return bits; | ||
170 | }; | ||
145 | 171 | ||
146 | /** | 172 | /** |
147 | * Creates a formatter function for the specified formatter pattern | 173 | * Creates a formatter function for the specified formatter pattern |
148 | * and locale. The returned function takes as many arguments as the | 174 | * and locale. The returned function takes as many arguments as the |
@@ -157,9 +183,9 @@ MochiKit.Text.splitJoin = function (func, str, separator) { | |||
157 | * | 183 | * |
158 | * @throws FormatPatternError if the format pattern was invalid | 184 | * @throws FormatPatternError if the format pattern was invalid |
159 | */ | 185 | */ |
160 | MochiKit.Text.formatter = function (pattern, locale) { | 186 | MochiKit.Text.formatter = function (pattern, locale) { |
161 | if (typeof(locale) == "undefined") { | 187 | if (locale == null) { |
162 | locale = MochiKit.Format.formatLocale(); | 188 | locale = MochiKit.Format.formatLocale(); |
163 | } else if (typeof(locale) == "string") { | 189 | } else if (typeof(locale) == "string") { |
164 | locale = MochiKit.Format.formatLocale(locale); | 190 | locale = MochiKit.Format.formatLocale(locale); |
165 | } | 191 | } |
@@ -174,10 +200,10 @@ MochiKit.Text.formatter = function (pattern, locale) { | |||
174 | res.push(MochiKit.Text.formatValue(parts[i], values, locale)); | 200 | res.push(MochiKit.Text.formatValue(parts[i], values, locale)); |
175 | } | 201 | } |
176 | } | 202 | } |
177 | return res.join(""); | 203 | return res.join(""); |
178 | } | 204 | }; |
179 | } | 205 | }; |
180 | 206 | ||
181 | /** | 207 | /** |
182 | * Formats the specified arguments according to a formatter pattern. | 208 | * Formats the specified arguments according to a formatter pattern. |
183 | * See separate documentation for information about the formatter | 209 | * See separate documentation for information about the formatter |
@@ -192,9 +218,9 @@ MochiKit.Text.formatter = function (pattern, locale) { | |||
192 | */ | 218 | */ |
193 | MochiKit.Text.format = function (pattern/*, ...*/) { | 219 | MochiKit.Text.format = function (pattern/*, ...*/) { |
194 | var func = MochiKit.Text.formatter(pattern); | 220 | var func = MochiKit.Text.formatter(pattern); |
195 | return func.apply(this, MochiKit.Base.extend([], arguments, 1)); | 221 | return func.apply(this, MochiKit.Base.extend([], arguments, 1)); |
196 | } | 222 | }; |
197 | 223 | ||
198 | /** | 224 | /** |
199 | * Format a value with the specified format specifier. | 225 | * Format a value with the specified format specifier. |
200 | * | 226 | * |
@@ -204,35 +230,39 @@ MochiKit.Text.format = function (pattern/*, ...*/) { | |||
204 | * @param {Object} [locale] the locale to use, defaults to | 230 | * @param {Object} [locale] the locale to use, defaults to |
205 | * LOCALE.en_US | 231 | * LOCALE.en_US |
206 | * | 232 | * |
207 | * @return {String} the formatted output string | 233 | * @return {String} the formatted output string |
234 | * | ||
235 | * @throws FormatPatternError if the format specifier was invalid | ||
208 | */ | 236 | */ |
209 | MochiKit.Text.formatValue = function (spec, value, locale) { | 237 | MochiKit.Text.formatValue = function (spec, value, locale) { |
210 | var self = MochiKit.Text; | 238 | var self = MochiKit.Text; |
211 | if (typeof(spec) === "string") { | 239 | if (typeof(spec) === "string") { |
212 | spec = self._parseFormatFlags(spec, 0, spec.length - 1); | 240 | spec = self._parseFormatFlags(spec, 0, spec.length); |
213 | } | 241 | } |
214 | for (var i = 0; spec.path != null && i < spec.path.length; i++) { | 242 | for (var i = 0; spec.path != null && i < spec.path.length; i++) { |
215 | if (value != null) { | 243 | if (value != null) { |
216 | value = value[spec.path[i]]; | 244 | value = value[spec.path[i]]; |
217 | } | 245 | } |
218 | } | 246 | } |
219 | if (typeof(locale) == "undefined") { | 247 | if (locale == null) { |
220 | locale = MochiKit.Format.formatLocale(); | 248 | locale = MochiKit.Format.formatLocale(); |
221 | } else if (typeof(locale) == "string") { | 249 | } else if (typeof(locale) == "string") { |
222 | locale = MochiKit.Format.formatLocale(locale); | 250 | locale = MochiKit.Format.formatLocale(locale); |
223 | } | 251 | } |
224 | var str = ""; | 252 | var str = ""; |
225 | if (spec.numeric) { | 253 | if (spec.type == "number") { |
254 | if (value instanceof Number) { | ||
255 | value = value.valueOf(); | ||
256 | } | ||
226 | if (typeof(value) != "number" || isNaN(value)) { | 257 | if (typeof(value) != "number" || isNaN(value)) { |
227 | str = ""; | 258 | str = ""; |
228 | } else if (value === Number.POSITIVE_INFINITY) { | 259 | } else if (value === Number.POSITIVE_INFINITY) { |
229 | str = "\u221e"; | 260 | str = "\u221e"; |
230 | } else if (value === Number.NEGATIVE_INFINITY) { | 261 | } else if (value === Number.NEGATIVE_INFINITY) { |
231 | str = "-\u221e"; | 262 | str = "-\u221e"; |
232 | } else { | 263 | } else { |
233 | var sign = (spec.sign === "-") ? "" : spec.sign; | 264 | var sign = (value < 0) ? "-" : spec.sign; |
234 | sign = (value < 0) ? "-" : sign; | ||
235 | value = Math.abs(value); | 265 | value = Math.abs(value); |
236 | if (spec.format === "%") { | 266 | if (spec.format === "%") { |
237 | str = self._truncToPercent(value, spec.precision); | 267 | str = self._truncToPercent(value, spec.precision); |
238 | } else if (spec.format === "d") { | 268 | } else if (spec.format === "d") { |
@@ -253,9 +283,9 @@ MochiKit.Text.formatValue = function (spec, value, locale) { | |||
253 | str = self.padLeft(str, spec.width - sign.length - 1, "0"); | 283 | str = self.padLeft(str, spec.width - sign.length - 1, "0"); |
254 | } else if (spec.padding == "0") { | 284 | } else if (spec.padding == "0") { |
255 | str = self.padLeft(str, spec.width - sign.length, "0"); | 285 | str = self.padLeft(str, spec.width - sign.length, "0"); |
256 | } | 286 | } |
257 | str = self._localizeNumber(str, locale, spec.grouping); | 287 | str = self._localizeNumber(str, locale, spec.group); |
258 | str = sign + str; | 288 | str = sign + str; |
259 | } | 289 | } |
260 | if (str !== "" && spec.format === "%") { | 290 | if (str !== "" && spec.format === "%") { |
261 | str = str + locale.percent; | 291 | str = str + locale.percent; |
@@ -263,9 +293,9 @@ MochiKit.Text.formatValue = function (spec, value, locale) { | |||
263 | } else { | 293 | } else { |
264 | if (spec.format == "r") { | 294 | if (spec.format == "r") { |
265 | str = MochiKit.Base.repr(value); | 295 | str = MochiKit.Base.repr(value); |
266 | } else { | 296 | } else { |
267 | str = (value == null) ? "null" : value.toString(); | 297 | str = (value == null) ? "" : value.toString(); |
268 | } | 298 | } |
269 | str = self.truncate(str, spec.precision); | 299 | str = self.truncate(str, spec.precision); |
270 | } | 300 | } |
271 | if (spec.align == "<") { | 301 | if (spec.align == "<") { |
@@ -273,9 +303,9 @@ MochiKit.Text.formatValue = function (spec, value, locale) { | |||
273 | } else { | 303 | } else { |
274 | str = self.padLeft(str, spec.width); | 304 | str = self.padLeft(str, spec.width); |
275 | } | 305 | } |
276 | return str; | 306 | return str; |
277 | } | 307 | }; |
278 | 308 | ||
279 | /** | 309 | /** |
280 | * Adjust an already formatted numeric string for locale-specific | 310 | * Adjust an already formatted numeric string for locale-specific |
281 | * grouping and decimal separators. The grouping is optional and | 311 | * grouping and decimal separators. The grouping is optional and |
@@ -283,34 +313,34 @@ MochiKit.Text.formatValue = function (spec, value, locale) { | |||
283 | * padded zeros (if possible). | 313 | * padded zeros (if possible). |
284 | * | 314 | * |
285 | * @param {String} num the formatted number string | 315 | * @param {String} num the formatted number string |
286 | * @param {Object} locale the formatting locale to use | 316 | * @param {Object} locale the formatting locale to use |
287 | * @param {Boolean} grouping the grouping flag | 317 | * @param {Boolean} group the grouping flag |
288 | * | 318 | * |
289 | * @return {String} the localized number string | 319 | * @return {String} the localized number string |
290 | */ | 320 | */ |
291 | MochiKit.Text._localizeNumber = function (num, locale, grouping) { | 321 | MochiKit.Text._localizeNumber = function (num, locale, group) { |
292 | var parts = num.split(/\./); | 322 | var parts = num.split(/\./); |
293 | var whole = parts[0]; | 323 | var whole = parts[0]; |
294 | var frac = (parts.length == 1) ? "" : parts[1]; | 324 | var frac = (parts.length == 1) ? "" : parts[1]; |
295 | var res = (frac.length > 0) ? locale.decimal : ""; | 325 | var res = (frac.length > 0) ? locale.decimal : ""; |
296 | while (grouping && frac.length > 3) { | 326 | while (group && frac.length > 3) { |
297 | res = res + frac.substring(0, 3) + locale.separator; | 327 | res = res + frac.substring(0, 3) + locale.separator; |
298 | frac = frac.substring(3); | 328 | frac = frac.substring(3); |
299 | if (whole.charAt(0) == "0") { | 329 | if (whole.charAt(0) == "0") { |
300 | whole = whole.substring(1); | 330 | whole = whole.substring(1); |
301 | } | 331 | } |
302 | } | 332 | } |
303 | if (frac.length > 0) { | 333 | if (frac.length > 0) { |
304 | res += frac; | 334 | res = res + frac; |
305 | } | 335 | } |
306 | while (grouping && whole.length > 3) { | 336 | while (group && whole.length > 3) { |
307 | var pos = whole.length - 3; | 337 | var pos = whole.length - 3; |
308 | res = locale.separator + whole.substring(pos) + res; | 338 | res = locale.separator + whole.substring(pos) + res; |
309 | whole = whole.substring((whole.charAt(0) == "0") ? 1 : 0, pos); | 339 | whole = whole.substring((whole.charAt(0) == "0") ? 1 : 0, pos); |
310 | } | 340 | } |
311 | return whole + res; | 341 | return whole + res; |
312 | } | 342 | }; |
313 | 343 | ||
314 | /** | 344 | /** |
315 | * Parses a format pattern and returns an array of constant strings | 345 | * Parses a format pattern and returns an array of constant strings |
316 | * and format info objects. | 346 | * and format info objects. |
@@ -323,46 +353,34 @@ MochiKit.Text._localizeNumber = function (num, locale, grouping) { | |||
323 | */ | 353 | */ |
324 | MochiKit.Text._parsePattern = function (pattern) { | 354 | MochiKit.Text._parsePattern = function (pattern) { |
325 | var self = MochiKit.Text; | 355 | var self = MochiKit.Text; |
326 | var parts = []; | 356 | var parts = []; |
327 | var start = 0; | 357 | var re = /{[^{}]*}|{{?|}}?/g; |
328 | var pos = 0; | 358 | var lastPos = re.lastIndex = 0; |
329 | for (pos = 0; pos < pattern.length; pos++) { | 359 | var m; |
330 | if (pattern.charAt(pos) == "{") { | 360 | while ((m = re.exec(pattern)) != null) { |
331 | if (pos + 1 >= pattern.length) { | 361 | if (lastPos < m.index) { |
362 | parts.push(pattern.substring(lastPos, m.index)) | ||
363 | } | ||
364 | var str = m[0]; | ||
365 | lastPos = m.index + str.length; | ||
366 | if (self.startsWith("{", str) && self.endsWith("}", str)) { | ||
367 | parts.push(self._parseFormat(pattern, m.index + 1, lastPos - 1)); | ||
368 | } else if (self.startsWith("{{", str) || self.startsWith("}}", str)) { | ||
369 | parts.push(str.substring(1)); | ||
370 | } else if (self.startsWith("{", str)) { | ||
332 | var msg = "unescaped { char, should be escaped as {{"; | 371 | var msg = "unescaped { char, should be escaped as {{"; |
333 | throw new self.FormatPatternError(pattern, pos, msg); | 372 | throw new self.FormatPatternError(pattern, m.index, msg); |
334 | } else if (pattern.charAt(pos + 1) == "{") { | 373 | } else if (self.startsWith("}", str)) { |
335 | parts.push(pattern.substring(start, pos + 1)); | ||
336 | start = pos + 2; | ||
337 | pos++; | ||
338 | } else { | ||
339 | if (start < pos) { | ||
340 | parts.push(pattern.substring(start, pos)); | ||
341 | } | ||
342 | start = pattern.indexOf("}", pos) + 1; | ||
343 | if (start <= 0) { | ||
344 | var msg = "unmatched { char, not followed by a } char"; | ||
345 | throw new self.FormatPatternError(pattern, pos, msg); | ||
346 | } | ||
347 | parts.push(self._parseFormat(pattern, pos + 1, start - 1)); | ||
348 | pos = start - 1; | ||
349 | } | ||
350 | } else if (pattern.charAt(pos) == "}") { | ||
351 | if (pos + 1 >= pattern.length || pattern.charAt(pos + 1) != "}") { | ||
352 | var msg = "unescaped } char, should be escaped as }}"; | 374 | var msg = "unescaped } char, should be escaped as }}"; |
353 | throw new self.FormatPatternError(pattern, pos, msg); | 375 | throw new self.FormatPatternError(pattern, m.index, msg); |
354 | } | ||
355 | parts.push(pattern.substring(start, pos + 1)); | ||
356 | start = pos + 2; | ||
357 | pos++; | ||
358 | } | 376 | } |
359 | } | 377 | } |
360 | if (start < pos) { | 378 | if (lastPos < pattern.length) { |
361 | parts.push(pattern.substring(start, pos)); | 379 | parts.push(pattern.substring(lastPos)); |
362 | } | 380 | } |
363 | return parts; | 381 | return parts; |
364 | } | 382 | }; |
365 | 383 | ||
366 | /** | 384 | /** |
367 | * Parses a format instruction and returns a format info object. | 385 | * Parses a format instruction and returns a format info object. |
368 | * | 386 | * |
@@ -376,42 +394,32 @@ MochiKit.Text._parsePattern = function (pattern) { | |||
376 | */ | 394 | */ |
377 | MochiKit.Text._parseFormat = function (pattern, startPos, endPos) { | 395 | MochiKit.Text._parseFormat = function (pattern, startPos, endPos) { |
378 | var self = MochiKit.Text; | 396 | var self = MochiKit.Text; |
379 | var text = pattern.substring(startPos, endPos); | 397 | var text = pattern.substring(startPos, endPos); |
380 | var info; | 398 | var parts = self.split(text, ":", 1); |
381 | var pos = text.indexOf(":"); | 399 | var path = parts[0]; |
382 | if (pos == 0) { | 400 | var flagsPos = startPos + path.length + ((parts.length == 1) ? 0 : 1); |
383 | info = self._parseFormatFlags(pattern, startPos + 1, endPos); | 401 | var info = self._parseFormatFlags(pattern, flagsPos, endPos); |
384 | info.path = [0]; | 402 | info.path = (path == "") ? [] : path.split("."); |
385 | } else if (pos > 0) { | ||
386 | info = self._parseFormatFlags(pattern, startPos + pos + 1, endPos); | ||
387 | info.path = text.substring(0, pos).split("."); | ||
388 | } else { | ||
389 | info = self._parseFormatFlags(pattern, endPos, endPos); | ||
390 | info.path = text.split("."); | ||
391 | } | ||
392 | var DIGITS = /^\d+$/; | ||
393 | for (var i = 0; i < info.path.length; i++) { | 403 | for (var i = 0; i < info.path.length; i++) { |
394 | var e = info.path[i]; | 404 | var v = info.path[i]; |
395 | if (typeof(e) == "string") { | ||
396 | // TODO: replace with MochiKit.Format.strip? | 405 | // TODO: replace with MochiKit.Format.strip? |
397 | e = e.replace(/^\s+/, "").replace(/\s+$/, ""); | 406 | v = v.replace(/^\s+/, "").replace(/\s+$/, ""); |
398 | if (e == "" && info.path.length == 1) { | 407 | if (v == "" && info.path.length == 1) { |
399 | e = 0; | 408 | v = 0; |
400 | } else if (e == "") { | 409 | } else if (v == "") { |
401 | var msg = "format value path contains blanks"; | 410 | var msg = "format value path contains blanks"; |
402 | throw new self.FormatPatternError(pattern, startPos, msg); | 411 | throw new self.FormatPatternError(pattern, startPos, msg); |
403 | } else if (DIGITS.test(e)) { | 412 | } else if (/^\d+$/.test(v)) { |
404 | e = parseInt(e); | 413 | v = parseInt(v, 10); |
405 | } | ||
406 | } | 414 | } |
407 | info.path[i] = e; | 415 | info.path[i] = v; |
408 | } | 416 | } |
409 | if (info.path.length < 0 || typeof(info.path[0]) != "number") { | 417 | if (info.path.length <= 0 || typeof(info.path[0]) != "number") { |
410 | info.path.unshift(0); | 418 | info.path.unshift(0); |
411 | } | 419 | } |
412 | return info; | 420 | return info; |
413 | } | 421 | }; |
414 | 422 | ||
415 | /** | 423 | /** |
416 | * Parses a string with format flags and returns a format info object. | 424 | * Parses a string with format flags and returns a format info object. |
417 | * | 425 | * |
@@ -423,83 +431,54 @@ MochiKit.Text._parseFormat = function (pattern, startPos, endPos) { | |||
423 | * | 431 | * |
424 | * @throws FormatPatternError if the format pattern was invalid | 432 | * @throws FormatPatternError if the format pattern was invalid |
425 | */ | 433 | */ |
426 | MochiKit.Text._parseFormatFlags = function (pattern, startPos, endPos) { | 434 | MochiKit.Text._parseFormatFlags = function (pattern, startPos, endPos) { |
427 | var self = MochiKit.Text; | 435 | var update = MochiKit.Base.update; |
428 | var info = { numeric: false, format: "s", width: 0, precision: -1, | 436 | var info = { type: "string", format: "s", width: 0, precision: -1, |
429 | align: ">", sign: "-", padding: " ", grouping: false }; | 437 | align: ">", sign: "", padding: " ", group: false }; |
430 | // TODO: replace with MochiKit.Format.rstrip? | 438 | // TODO: replace with MochiKit.Format.rstrip? |
431 | var flags = pattern.substring(startPos, endPos).replace(/\s+$/, ""); | 439 | var text = pattern.substring(startPos, endPos).replace(/\s+$/, ""); |
432 | while (flags.length > 0) { | 440 | var m = /^([<>+ 0,-]+)?(\d+)?(\.\d*)?([srbdoxXf%])?(.*)$/.exec(text); |
433 | switch (flags.charAt(0)) { | 441 | var flags = m[1]; |
434 | case ">": | 442 | var width = m[2]; |
435 | case "<": | 443 | var precision = m[3]; |
436 | info.align = flags.charAt(0); | 444 | var type = m[4]; |
437 | flags = flags.substring(1); | 445 | var unmatched = m[5]; |
438 | break; | 446 | for (var i = 0; flags && i < flags.length; i++) { |
439 | case "+": | 447 | var chr = flags.charAt(i); |
440 | case "-": | 448 | if (chr == "<" || chr == ">") { |
441 | case " ": | 449 | info.align = chr; |
442 | info.sign = flags.charAt(0); | 450 | } else if (chr == "+" || chr == "-" || chr == " ") { |
443 | flags = flags.substring(1); | 451 | info.sign = (chr == "-") ? "" : chr; |
444 | break; | 452 | } else if (chr == "0") { |
445 | case ",": | 453 | info.padding = chr; |
446 | info.grouping = true; | 454 | } else if (chr == ",") { |
447 | flags = flags.substring(1); | 455 | info.group = true; |
448 | break; | 456 | } |
449 | case ".": | 457 | } |
450 | var chars = /^\d*/.exec(flags.substring(1))[0]; | 458 | if (width) { |
451 | info.precision = parseInt(chars); | 459 | info.width = parseInt(width, 10); |
452 | flags = flags.substring(1 + chars.length); | 460 | } |
453 | break; | 461 | if (precision && precision.length > 1) { |
454 | case "0": | 462 | info.precision = parseInt(precision.substring(1), 10); |
455 | info.padding = flags.charAt(0); | 463 | } |
456 | flags = flags.substring(1); | 464 | if (type == "s" || type == "r") { |
457 | break; | 465 | info.format = type; |
458 | case "1": | 466 | } else if (type == "b") { |
459 | case "2": | 467 | update(info, { type: "number", format: type, radix: 2 }); |
460 | case "3": | 468 | } else if (type == "o") { |
461 | case "4": | 469 | update(info, { type: "number", format: type, radix: 8 }); |
462 | case "5": | 470 | } else if (type == "x" || type == "X") { |
463 | case "6": | 471 | update(info, { type: "number", format: type, radix: 16 }); |
464 | case "7": | 472 | } else if (type == "d" || type == "f" || type == "%") { |
465 | case "8": | 473 | update(info, { type: "number", format: type, radix: 10 }); |
466 | case "9": | 474 | } |
467 | var chars = /^\d*/.exec(flags)[0]; | 475 | if (unmatched) { |
468 | info.width = parseInt(chars); | 476 | var msg = "unsupported format flag: " + unmatched.charAt(0); |
469 | flags = flags.substring(chars.length); | 477 | throw new MochiKit.Text.FormatPatternError(pattern, startPos, msg); |
470 | break; | ||
471 | case "s": | ||
472 | case "r": | ||
473 | info.format = flags.charAt(0); | ||
474 | flags = flags.substring(1); | ||
475 | break; | ||
476 | case "b": | ||
477 | case "d": | ||
478 | case "o": | ||
479 | case "x": | ||
480 | case "X": | ||
481 | case "f": | ||
482 | case "%": | ||
483 | info.numeric = true; | ||
484 | info.format = flags.charAt(0); | ||
485 | info.radix = 10; | ||
486 | if (info.format === "b") { | ||
487 | info.radix = 2; | ||
488 | } else if (info.format === "o") { | ||
489 | info.radix = 8; | ||
490 | } else if (info.format === "x" || info.format === "X") { | ||
491 | info.radix = 16; | ||
492 | } | ||
493 | flags = flags.substring(1); | ||
494 | break; | ||
495 | default: | ||
496 | var msg = "unsupported format flag: " + flags.charAt(0); | ||
497 | throw new self.FormatPatternError(pattern, startPos, msg); | ||
498 | } | ||
499 | } | 478 | } |
500 | return info; | 479 | return info; |
501 | } | 480 | }; |
502 | 481 | ||
503 | /** | 482 | /** |
504 | * Formats a value as a percentage. This method avoids multiplication | 483 | * Formats a value as a percentage. This method avoids multiplication |
505 | * by 100 since it leads to weird numeric rounding errors. Instead it | 484 | * by 100 since it leads to weird numeric rounding errors. Instead it |
@@ -509,35 +488,25 @@ MochiKit.Text._parseFormatFlags = function (pattern, startPos, endPos) { | |||
509 | * @param {Number} value the value to format | 488 | * @param {Number} value the value to format |
510 | * @param {Number} precision the number of precision digits | 489 | * @param {Number} precision the number of precision digits |
511 | */ | 490 | */ |
512 | MochiKit.Text._truncToPercent = function (value, precision) { | 491 | MochiKit.Text._truncToPercent = function (value, precision) { |
513 | // TODO: This can be simplified by using the same helper function | 492 | // TODO: This can be simplified by using MochiKit.Format._shiftNumber |
514 | // as roundToFixed now does. | 493 | // as roundToFixed does. |
515 | var str; | 494 | var str; |
516 | if (precision >= 0) { | 495 | if (precision >= 0) { |
517 | str = MochiKit.Format.roundToFixed(value, precision + 2); | 496 | str = MochiKit.Format.roundToFixed(value, precision + 2); |
518 | } else { | 497 | } else { |
519 | str = (value == null) ? "0" : value.toString(); | 498 | str = (value == null) ? "0" : value.toString(); |
520 | } | 499 | } |
521 | var fracPos = str.indexOf("."); | 500 | var arr = MochiKit.Text.split(str, ".", 2); |
522 | if (fracPos < 0) { | 501 | var frac = MochiKit.Text.padRight(arr[1], 2, "0"); |
523 | str = str + "00"; | 502 | var whole = arr[0] + frac.substring(0, 2); |
524 | } else if (fracPos + 3 >= str.length) { | 503 | frac = frac.substring(2); |
525 | var fraction = str.substring(fracPos + 1); | 504 | while (/^0[0-9]/.test(whole)) { |
526 | while (fraction.length < 2) { | 505 | whole = whole.substring(1); |
527 | fraction = fraction + "0"; | ||
528 | } | ||
529 | str = str.substring(0, fracPos) + fraction; | ||
530 | } else { | ||
531 | var fraction = str.substring(fracPos + 1); | ||
532 | str = str.substring(0, fracPos) + fraction.substring(0, 2) + | ||
533 | "." + fraction.substring(2); | ||
534 | } | ||
535 | while (str.length > 1 && str.charAt(0) == "0" && str.charAt(1) != ".") { | ||
536 | str = str.substring(1); | ||
537 | } | ||
538 | return str; | ||
539 | } | 506 | } |
507 | return (frac.length <= 0) ? whole : whole + "." + frac; | ||
508 | }; | ||
540 | 509 | ||
541 | /** | 510 | /** |
542 | * Creates a new format pattern error. | 511 | * Creates a new format pattern error. |
543 | * | 512 | * |
@@ -557,15 +526,15 @@ MochiKit.Text._truncToPercent = function (value, precision) { | |||
557 | MochiKit.Text.FormatPatternError = function (pattern, pos, message) { | 526 | MochiKit.Text.FormatPatternError = function (pattern, pos, message) { |
558 | this.pattern = pattern; | 527 | this.pattern = pattern; |
559 | this.pos = pos; | 528 | this.pos = pos; |
560 | this.message = message; | 529 | this.message = message; |
561 | } | 530 | }; |
562 | MochiKit.Text.FormatPatternError.prototype = | ||
563 | new MochiKit.Base.NamedError("MochiKit.Text.FormatPatternError"); | ||
564 | 531 | ||
532 | MochiKit.Text.FormatPatternError.prototype = new MochiKit.Base.NamedError("MochiKit.Text.FormatPatternError"); | ||
533 | MochiKit.Text.FormatPatternError.constructor = MochiKit.Text.FormatPatternError; | ||
565 | 534 | ||
566 | // | 535 | // |
567 | //XXX: Internet Explorer exception handling blows | 536 | //XXX: Internet Explorer export fix |
568 | // | 537 | // |
569 | if (MochiKit.__export__) { | 538 | if (MochiKit.__export__) { |
570 | formatter = MochiKit.Text.formatter; | 539 | formatter = MochiKit.Text.formatter; |
571 | format = MochiKit.Text.format; | 540 | format = MochiKit.Text.format; |
diff --git a/frontend/gamma/js/MochiKit/Visual.js b/frontend/gamma/js/MochiKit/Visual.js index 648d82a..372d99a 100644 --- a/frontend/gamma/js/MochiKit/Visual.js +++ b/frontend/gamma/js/MochiKit/Visual.js | |||
@@ -7,9 +7,9 @@ See <http://mochikit.com/> for documentation, downloads, license, etc. | |||
7 | (c) 2005 Bob Ippolito and others. All rights Reserved. | 7 | (c) 2005 Bob Ippolito and others. All rights Reserved. |
8 | 8 | ||
9 | ***/ | 9 | ***/ |
10 | 10 | ||
11 | MochiKit.Base._module('Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']); | 11 | MochiKit.Base.module(MochiKit, 'Visual', '1.5', ['Base', 'DOM', 'Style', 'Color', 'Position']); |
12 | 12 | ||
13 | MochiKit.Visual._RoundCorners = function (e, options) { | 13 | MochiKit.Visual._RoundCorners = function (e, options) { |
14 | e = MochiKit.DOM.getElement(e); | 14 | e = MochiKit.DOM.getElement(e); |
15 | this._setOptions(options); | 15 | this._setOptions(options); |
@@ -468,8 +468,13 @@ MochiKit.Visual.Transitions.pulse = function (pos, pulses) { | |||
468 | MochiKit.Visual.Transitions.parabolic = function (pos) { | 468 | MochiKit.Visual.Transitions.parabolic = function (pos) { |
469 | return pos * pos; | 469 | return pos * pos; |
470 | }; | 470 | }; |
471 | 471 | ||
472 | /** @id MochiKit.Visual.Transitions.spring */ | ||
473 | MochiKit.Visual.Transitions.spring = function (pos) { | ||
474 | return 1 - (Math.cos(pos * 2.5 * Math.PI) * Math.exp(-pos * 6)); | ||
475 | }; | ||
476 | |||
472 | /** @id MochiKit.Visual.Transitions.none */ | 477 | /** @id MochiKit.Visual.Transitions.none */ |
473 | MochiKit.Visual.Transitions.none = function (pos) { | 478 | MochiKit.Visual.Transitions.none = function (pos) { |
474 | return 0; | 479 | return 0; |
475 | }; | 480 | }; |
@@ -533,8 +538,13 @@ MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, { | |||
533 | ma(function (e) { | 538 | ma(function (e) { |
534 | e.finalize(); | 539 | e.finalize(); |
535 | }, this.effects); | 540 | }, this.effects); |
536 | break; | 541 | break; |
542 | case 'replace': | ||
543 | ma(function (e) { | ||
544 | e.cancel(); | ||
545 | }, this.effects); | ||
546 | break; | ||
537 | } | 547 | } |
538 | 548 | ||
539 | effect.startOn += timestamp; | 549 | effect.startOn += timestamp; |
540 | effect.finishOn += timestamp; | 550 | effect.finishOn += timestamp; |
@@ -661,10 +671,14 @@ MochiKit.Visual.Base.prototype = { | |||
661 | this.setup(); | 671 | this.setup(); |
662 | this.event('afterSetup'); | 672 | this.event('afterSetup'); |
663 | } | 673 | } |
664 | if (this.state == 'running') { | 674 | if (this.state == 'running') { |
665 | if (this.options.transition) { | 675 | var trans = this.options.transition; |
666 | pos = this.options.transition(pos); | 676 | if (typeof(trans) == "string") { |
677 | trans = MochiKit.Visual.Transitions[trans]; | ||
678 | } | ||
679 | if (typeof(trans) == "function") { | ||
680 | pos = trans(pos); | ||
667 | } | 681 | } |
668 | pos *= (this.options.to - this.options.from); | 682 | pos *= (this.options.to - this.options.from); |
669 | pos += this.options.from; | 683 | pos += this.options.from; |
670 | this.event('beforeUpdate'); | 684 | this.event('beforeUpdate'); |
@@ -1685,10 +1699,10 @@ MochiKit.Visual.squish = function (element, /* optional */ options) { | |||
1685 | var elementDimensions = s.getElementDimensions(element, true); | 1699 | var elementDimensions = s.getElementDimensions(element, true); |
1686 | var elemClip; | 1700 | var elemClip; |
1687 | options = b.update({ | 1701 | options = b.update({ |
1688 | restoreAfterFinish: true, | 1702 | restoreAfterFinish: true, |
1689 | scaleMode: {originalHeight: elementDimensions.w, | 1703 | scaleMode: {originalHeight: elementDimensions.h, |
1690 | originalWidth: elementDimensions.h}, | 1704 | originalWidth: elementDimensions.w}, |
1691 | beforeSetupInternal: function (effect) { | 1705 | beforeSetupInternal: function (effect) { |
1692 | elemClip = s.makeClipping(effect.element); | 1706 | elemClip = s.makeClipping(effect.element); |
1693 | }, | 1707 | }, |
1694 | afterFinishInternal: function (effect) { | 1708 | afterFinishInternal: function (effect) { |
@@ -1957,19 +1971,6 @@ MochiKit.Visual.fold = function (element, /* optional */ options) { | |||
1957 | return new v.Scale(element, 5, options); | 1971 | return new v.Scale(element, 5, options); |
1958 | }; | 1972 | }; |
1959 | 1973 | ||
1960 | 1974 | ||
1961 | /* end of Rico adaptation */ | 1975 | MochiKit.Base.nameFunctions(MochiKit.Visual); |
1962 | |||
1963 | MochiKit.Visual.__new__ = function () { | ||
1964 | var m = MochiKit.Base; | ||
1965 | |||
1966 | // Backwards compatibility aliases | ||
1967 | m._deprecated(this, 'Color', 'MochiKit.Color.Color', '1.1'); | ||
1968 | m._deprecated(this, 'getElementsComputedStyle', 'MochiKit.Style.getStyle', '1.1'); | ||
1969 | |||
1970 | m.nameFunctions(this); | ||
1971 | }; | ||
1972 | |||
1973 | MochiKit.Visual.__new__(); | ||
1974 | |||
1975 | MochiKit.Base._exportSymbols(this, MochiKit.Visual); | 1976 | MochiKit.Base._exportSymbols(this, MochiKit.Visual); |
diff --git a/frontend/gamma/js/MochiKit/__package__.js b/frontend/gamma/js/MochiKit/__package__.js deleted file mode 100644 index 8d644b1..0000000 --- a/frontend/gamma/js/MochiKit/__package__.js +++ b/dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | dojo.kwCompoundRequire({ | ||
2 | "common": [ | ||
3 | "MochiKit.Base", | ||
4 | "MochiKit.Iter", | ||
5 | "MochiKit.Logging", | ||
6 | "MochiKit.DateTime", | ||
7 | "MochiKit.Format", | ||
8 | "MochiKit.Async", | ||
9 | "MochiKit.DOM", | ||
10 | "MochiKit.Style", | ||
11 | "MochiKit.LoggingPane", | ||
12 | "MochiKit.Color", | ||
13 | "MochiKit.Signal", | ||
14 | "MochiKit.Position", | ||
15 | "MochiKit.Visual" | ||
16 | ] | ||
17 | }); | ||
18 | dojo.provide("MochiKit.*"); | ||
diff --git a/frontend/gamma/js/main.js b/frontend/gamma/js/main.js index a9fd65e..934b325 100644 --- a/frontend/gamma/js/main.js +++ b/frontend/gamma/js/main.js | |||
@@ -81,11 +81,11 @@ function run() { | |||
81 | 81 | ||
82 | Clipperz.PM.RunTime.mainController.run(shouldShowRegistrationForm); | 82 | Clipperz.PM.RunTime.mainController.run(shouldShowRegistrationForm); |
83 | 83 | ||
84 | //Clipperz.log("HASH: " + window.location.hash); | 84 | //Clipperz.log("HASH: " + window.location.hash); |
85 | if (window.location.hash != "") { | 85 | //if (window.location.hash != "") { |
86 | window.location.hash = "" | 86 | // window.location.hash = "" |
87 | } | 87 | //} |
88 | //Clipperz.log("HASH cleaned"); | 88 | //Clipperz.log("HASH cleaned"); |
89 | //#credentials=base64encoded({username:'joe', passphrase:'clipperz'}) | 89 | //#credentials=base64encoded({username:'joe', passphrase:'clipperz'}) |
90 | //MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'doLogin', {username:'joe', passphrase:'clipperz'}); | 90 | //MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'doLogin', {username:'joe', passphrase:'clipperz'}); |
91 | } | 91 | } |