public
Description: HomeMarks is a web based GUI to build HTML start pages.
Homepage: http://www.homemarks.com/
Clone URL: git://github.com/metaskills/homemarks.git
Search Repo:
Click here to lend your support to: homemarks and make a donation at www.pledgie.com !
Organizing HomeMarks JS better.
metaskills (author)
Fri May 16 14:42:59 -0700 2008
commit  9ade90a070de02789c47eca04e92ee77c2af1391
tree    2900a8ec22532179c6b666890e885382b3591050
parent  d4325eb06327c9d674ab92933f4f5d705615e83e
...
9
10
11
12
13
14
 
 
 
 
 
 
 
 
 
15
16
17
18
19
20
21
22
23
 
24
25
26
...
9
10
11
 
 
 
12
13
14
15
16
17
18
19
20
21
 
 
 
 
 
 
 
 
22
23
24
25
0
@@ -9,18 +9,17 @@
0
   <link rel="icon" type="image/png" href="/favicon.png" />
0
   <%= stylesheet_link_tag 'application', :media => 'all' %>
0
   <%= stylesheet_link_tag 'utility_styles', :media => 'all' %>
0
- <%= javascript_include_tag 'prototype', 'effects', 'dragdrop', 'builder', :cache => 'homemarksjslib' %>
0
- <%= javascript_include_tag 'hm_site' %>
0
- <script type="text/javascript">Builder.dump();</script>
0
+ <%= javascript_include_tag 'prototype', 'effects', 'dragdrop', 'builder', :cache => 'homemarks_vendor' %>
0
+ <%= javascript_include_tag 'homemarks/utilities','homemarks/site','homemarks/modal', :cache => 'homemarks_site' %>
0
+ <script type="text/javascript">
0
+ document.observe('dom:loaded', function(){
0
+ HmSite = new HomeMarksSite();
0
+ HmModal = new HomeMarksModal();
0
+ });
0
+ Builder.dump();
0
+ </script>
0
 </head>
0
-<body>
0
-
0
- <div id="modalmask" style="display:none;">
0
- <div id="modal_progress" style="display:none;" onclick="location.reload();"></div>
0
- </div>
0
- <div id="modal_html_ap-wrapper">
0
- <div id="modal_html_rel-wrapper" style="display:none;"></div>
0
- </div>
0
+<body id="body">
0
   
0
   <div id="site_wrapper">
0
     
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,47 +1 @@
0
-
0
-var Boxes = $A();
0
-var Box = Class.create({
0
-
0
- initialize: function(box) {
0
- this.box = box;
0
- if (!Boxes.include(this.box)) { Boxes.push(this.box); };
0
- this.action = this.box.down('span.box_action');
0
- this.title = this.box.down('.box_title a');
0
- },
0
-
0
- showActions: function(event) {
0
-
0
- },
0
-
0
- editLinks: function(event) {
0
- var modal = new Modal('bookmarks');
0
- // :before => "this.blur(); setupModal(#{box.id})",
0
- // :loading => "Element.show('modal_progress')" )
0
- //
0
- // Data from request:
0
- //
0
- // page.replace_html 'modal_html_rel-wrapper', :partial => 'edit_links'
0
- // page.hide :modal_progress
0
- // page.visual_effect :slide_down, 'modal_html_rel-wrapper', :duration => 0.4, :queue => {:position => 'end', :scope => "boxid_#{@box.id}"}
0
- },
0
-
0
- initEvents: function() {
0
- this.action.observe('click', this.showActions.bindAsEventListener(this));
0
- }
0
-
0
-});
0
-
0
-
0
-var HomeMarksApp = Class.create(HomeMarksUtilities,{
0
-
0
- initialize: function() {
0
-
0
- }
0
-
0
-});
0
-
0
-
0
-document.observe('dom:loaded', function(){
0
- $$('div.dragable_boxes').each(function(box){ new Box(box); });
0
-});
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
...
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
0
@@ -1,328 +1,4 @@
0
 
0
-var HomeMarksUtilities = {
0
-
0
- getRequestMood: function(request) {
0
- return (request.status >= 200 && request.status < 300) ? 'good' : 'bad';
0
- },
0
-
0
- messagesToAlert: function(request) {
0
- var messages = request.responseJSON;
0
- var alertText = messages.join(".\n");
0
- if (alertText.endsWith('.')) { alert(alertText); } else { alert(alertText+'.'); };
0
- },
0
-
0
- messagesToList: function(request) {
0
- var messages = request.responseJSON;
0
- var messageList = UL();
0
- messages.each(function(message){
0
- messageList.appendChild( LI(message.escapeHTML()) );
0
- });
0
- return messageList;
0
- },
0
-
0
- scroll: function() { return document.viewport.getScrollOffsets(); },
0
-
0
- pageSize: function() {
0
- var xScroll, yScroll;
0
- if (window.innerHeight && window.scrollMaxY) {
0
- xScroll = window.innerWidth + window.scrollMaxX;
0
- yScroll = window.innerHeight + window.scrollMaxY;
0
- } else if (document.body.scrollHeight > document.body.offsetHeight){
0
- xScroll = document.body.scrollWidth;
0
- yScroll = document.body.scrollHeight;
0
- } else {
0
- xScroll = document.body.offsetWidth;
0
- yScroll = document.body.offsetHeight;
0
- }
0
- var windowWidth, windowHeight;
0
- if (self.innerHeight) {
0
- if(document.documentElement.clientWidth){
0
- windowWidth = document.documentElement.clientWidth;
0
- } else {
0
- windowWidth = self.innerWidth;
0
- }
0
- windowHeight = self.innerHeight;
0
- } else if (document.documentElement && document.documentElement.clientHeight) {
0
- windowWidth = document.documentElement.clientWidth;
0
- windowHeight = document.documentElement.clientHeight;
0
- } else if (document.body) {
0
- windowWidth = document.body.clientWidth;
0
- windowHeight = document.body.clientHeight;
0
- }
0
- if(yScroll < windowHeight){
0
- pageHeight = windowHeight;
0
- } else {
0
- pageHeight = yScroll;
0
- }
0
- if(xScroll < windowWidth){
0
- pageWidth = xScroll;
0
- } else {
0
- pageWidth = windowWidth;
0
- }
0
- return { width: pageWidth, height: pageHeight };
0
- }
0
-
0
-};
0
-
0
-var HomeMarksSite = Class.create(HomeMarksUtilities,{
0
-
0
- initialize: function() {
0
- this.ajaxFrom = $('ajaxforms_wrapper');
0
- this.ajaxFromLinks = $$('.ajaxform_link');
0
- this.supportForm = $('support_form');
0
- this.loginForm = $('login_form');
0
- this.signupForm = $('signup_form');
0
- this.flashes = $$('div.flash_message');
0
- this.initEvents();
0
- },
0
-
0
- clearFlashes: function() {
0
- this.flashes.invoke('hide');
0
- this.flashes.invoke('update','');
0
- },
0
-
0
- flash: function(mood,html) {
0
- this.clearFlashes();
0
- var moodFlash = this.flashes.find(function(e){ if (e.id == 'flash_'+mood) {return true}; });
0
- moodFlash.update(html);
0
- moodFlash.show();
0
- $('site_wrapper').scrollTo();
0
- },
0
-
0
- toggleAjaxFormBlind: function(event) {
0
- if (event) { event.element().blur(); };
0
- Effect.toggle(this.ajaxFrom, 'blind', {duration:0.4});
0
- },
0
-
0
- startAjaxForm: function(event) {
0
- event.stop();
0
- var form = event.findElement('form');
0
- var options = Object.extend({loadId:'form_loading',imgSrc:'loading_invert.gif'}, arguments[1] || {});
0
- var imgTag = IMG({src:('/images/'+options.imgSrc)});
0
- $(options.loadId).update(imgTag);
0
- new Ajax.Request(form.action,{
0
- onComplete: function(request){ this.delegateCompleteAjaxForm(form,request) }.bind(this),
0
- parameters: form.serialize(true)
0
- });
0
- form.disable();
0
- },
0
-
0
- delegateCompleteAjaxForm: function(form,request) {
0
- var mood = this.getRequestMood(request);
0
- this.completeAjaxForm(form,{mood:mood});
0
- if (mood == 'good') {
0
- this.clearFlashes();
0
- switch (form) {
0
- case this.supportForm : this.completeSupportForm(request);
0
- case this.loginForm : this.completeLoginForm(request);
0
- case this.signupForm : this.completeSignupForm(request);
0
- }
0
- }
0
- else {
0
- form.enable();
0
- var flashHtml = DIV([H2('Errors:'),this.messagesToList(request)]);
0
- this.flash('bad',flashHtml);
0
- };
0
- },
0
-
0
- completeAjaxForm: function(form) {
0
- var options = Object.extend({loadId:'form_loading',mood:'good'}, arguments[1] || {});
0
- var completeId = 'complete_ajax_form_' + options.loadId;
0
- var imgSrc = '/images/'+options.mood+'.png';
0
- var moodHtml = SPAN({id:completeId,className:'m0 p0'}, [IMG({src:imgSrc})]);
0
- $(options.loadId).update(moodHtml);
0
- setTimeout(function() { $(completeId).fade(); },3000);
0
- },
0
-
0
- submitSupportForm: function(event) {
0
- this.startAjaxForm(event,{imgSrc:'loading.gif'});
0
- },
0
-
0
- completeSupportForm: function(request) {
0
- setTimeout(function(){ this.supportForm.reset(); this.supportForm.enable(); }.bind(this),2000);
0
- this.toggleAjaxFormBlind();
0
- this.flash('good','Thanks for submitting a support request!');
0
- },
0
-
0
- completeLoginForm: function(request) {
0
- window.location = '/myhome'
0
- },
0
-
0
- completeSignupForm: function(request) {
0
- var flashHTML = DIV([H2('Signup Complete:'),P('We have sent an email with a link to verify and activate your account. You can not login unless you verify your email address.')]);
0
- this.flash('good',flashHTML);
0
- },
0
-
0
- initEvents: function() {
0
- if (this.supportForm) { this.supportForm.observe('submit', this.submitSupportForm.bindAsEventListener(this)); };
0
- if (this.loginForm) { this.loginForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
- if (this.signupForm) { this.signupForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
- this.ajaxFromLinks.each(function(element){
0
- element.observe('click', this.toggleAjaxFormBlind.bindAsEventListener(this));
0
- }.bind(this));
0
- }
0
-
0
-});
0
-
0
-
0
-// WindowUtilities.getWindowScroll() // => { top: 0, left: 0, width: 1002, height: 464 }
0
-// document.viewport.getDimensions() // => { width: 987, height: 494 }
0
-// document.viewport.getWidth() // => 987
0
-// document.viewport.getHeight() // => 494
0
-// document.viewport.getScrollOffsets() // => [0, 0]
0
-//
0
-// WindowUtilities.getPageSize() // => { pageWidth: 1002, pageHeight: 3129, windowWidth: 1002 }
0
-// WindowUtilities.getPageSize() // => [987,3129]
0
-
0
-
0
-var HomeMarksModal = Class.create(HomeMarksUtilities,{
0
-
0
- initialize: function(contents) {
0
-
0
- this.contents = contents || 'misc' // ['box','bookmark']
0
- this.mask = $('modalmask');
0
- this.progress = $('modal_progress');
0
- this.wrapper = $('modal_html_ap-wrapper');
0
- this.content = $('modal_html_rel-wrapper');
0
- this.queue = {position:'end', scope:'modalscope'};
0
- this.create();
0
- },
0
-
0
- miscContents: function() { return this.contents == 'misc'; },
0
- boxContents: function() { return this.contents == 'box'; },
0
- bookmarkContents: function() { return this.contents == 'bookmark'; },
0
-
0
- create: function() {
0
- this.center();
0
- this.toggleMask('on');
0
- this.toggleProgress('on');
0
- this.toggleObservers('on');
0
- // document.stopObserving('keypress', actionAreaHelper);
0
- // if (this.action_bar().hasClassName('barout')) { toggleActionArea('inbox'); }
0
- },
0
-
0
- destroy: function(boxid) {
0
- this.toggleObservers('off');
0
- this.toggleProgress('off');
0
- this.toggleMask('off');
0
- // document.observe('keypress', actionAreaHelper);
0
- },
0
-
0
- center: function() {
0
- this.centerMask();
0
- this.centerModal();
0
- },
0
-
0
- centerMask: function() {
0
- this.mask.setStyle({height: this.pageSize().height + 'px'});
0
- this.progress.setStyle({top: (this.scroll().top + 60) + 'px'});
0
- },
0
-
0
- centerModal: function() {
0
- left = (( this.pageSize().width - this.width() ) / 2).ceil();
0
- if (left < 0) left = 0;
0
- this.wrapper.setStyle({left: left+'px'});
0
- },
0
-
0
- width: function() {
0
- switch (this.contents) {
0
- case 'misc' : return 450;
0
- case 'box' : return 652;
0
- case 'bookmark' : return 352;
0
- }
0
- },
0
-
0
- toggleMask: function(toggle) {
0
- if (toggle == 'on') {
0
- this.mask.appear({duration:0.4, from:0.0, to:0.9, queue:this.queue});
0
- }
0
- else {
0
- // May not need visible check.
0
- if (this.content.visible()) { this.content.slideUp({duration:0.4, queue:this.queue}); };
0
- this.mask.fade({duration:0.2, queue:this.queue});
0
- };
0
- },
0
-
0
- toggleObservers: function(toggle) {
0
- if (toggle == 'on') {
0
- Event.observe(window, 'resize', this.center.bindAsEventListener(this));
0
- Event.observe(window, 'scroll', this.center.bind(this));
0
- document.observe('keypress', this.keypress.bind(this));
0
- }
0
- else {
0
- Event.stopObserving(window, 'resize', this.center);
0
- Event.stopObserving(window, 'scroll', this.center);
0
- document.stopObserving('keypress', this.keypress);
0
- };
0
- },
0
-
0
- toggleProgress: function(toggle) {
0
- var options = {duration:0.2, queue:this.queue}
0
- if (toggle == 'on') { this.progress.appear(options); } else { this.progress.fade(options); };
0
- },
0
-
0
- keypress: function(event) {
0
- console.log(event)
0
- if (event.keyCode == Event.KEY_ESC) { this.destroy(); };
0
- },
0
-
0
- build: function() {
0
- var maskHTML = DIV({id:'modalmask',style:'display:none;'},[DIV({id:'modal_progress',style:'display:none;'})]);
0
- var modalHTML = DIV({id:'modal_html_ap-wrapper'},[DIV({id:'modal_html_rel-wrapper',style:'display:none;'})]);
0
-
0
- }
0
-
0
- // hideModal: function(boxid) {
0
- // boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
- // Event.stopObserving(document, 'keypress', respondtoKeypress);
0
- // Effect.SlideUp(modalContent, {duration:0.4, queue:{position:'end', scope:'boxid_' + boxid}});
0
- // Effect.Appear(modalProgress, {duration:0.2, from:0.0, to:0.9, queue:{position:'end', scope:'boxid_' + boxid}});
0
- // },
0
- //
0
- // destroyModalMask: function(boxid) {
0
- // boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
- // Event.stopObserving(window, 'resize', centerStuff);
0
- // Event.stopObserving(window, 'scroll', centerStuff);
0
- // Effect.Fade(modalMask, {duration:0.2, queue:{position:'end', scope:'boxid_' + boxid}});
0
- // },
0
- //
0
- // goHere: function() {
0
- // window.location.reload();
0
- // }
0
-
0
-});
0
-
0
-
0
-
0
-
0
-
0
-document.observe('dom:loaded', function(){
0
- HmSite = new HomeMarksSite();
0
- // HmModal = new HomeMarksModal();
0
-});
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
-
0
 
0
 
0
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
0
@@ -1 +1,47 @@
0
+
0
+var Boxes = $A();
0
+var Box = Class.create({
0
+
0
+ initialize: function(box) {
0
+ this.box = box;
0
+ if (!Boxes.include(this.box)) { Boxes.push(this.box); };
0
+ this.action = this.box.down('span.box_action');
0
+ this.title = this.box.down('.box_title a');
0
+ },
0
+
0
+ showActions: function(event) {
0
+
0
+ },
0
+
0
+ editLinks: function(event) {
0
+ var modal = new Modal('bookmarks');
0
+ // :before => "this.blur(); setupModal(#{box.id})",
0
+ // :loading => "Element.show('modal_progress')" )
0
+ //
0
+ // Data from request:
0
+ //
0
+ // page.replace_html 'modal_html_rel-wrapper', :partial => 'edit_links'
0
+ // page.hide :modal_progress
0
+ // page.visual_effect :slide_down, 'modal_html_rel-wrapper', :duration => 0.4, :queue => {:position => 'end', :scope => "boxid_#{@box.id}"}
0
+ },
0
+
0
+ initEvents: function() {
0
+ this.action.observe('click', this.showActions.bindAsEventListener(this));
0
+ }
0
+
0
+});
0
+
0
+
0
+var HomeMarksApp = Class.create(HomeMarksUtilities,{
0
+
0
+ initialize: function() {
0
+
0
+ }
0
+
0
+});
0
+
0
+
0
+document.observe('dom:loaded', function(){
0
+ $$('div.dragable_boxes').each(function(box){ new Box(box); });
0
+});
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
0
@@ -1 +1,121 @@
0
+
0
+var HomeMarksModal = Class.create(HomeMarksUtilities,{
0
+
0
+ initialize: function(contents) {
0
+ this.build();
0
+ this.contents = contents || 'misc' // ['box','bookmark']
0
+ this.mask = $('modalmask');
0
+ this.progress = $('modal_progress');
0
+ this.wrapper = $('modal_html_ap-wrapper');
0
+ this.content = $('modal_html_rel-wrapper');
0
+ this.queue = {position:'end', scope:'modalscope'};
0
+ },
0
+
0
+ miscContents: function() { return this.contents == 'misc'; },
0
+ boxContents: function() { return this.contents == 'box'; },
0
+ bookmarkContents: function() { return this.contents == 'bookmark'; },
0
+
0
+ build: function() {
0
+ if (!$('modalmask')) {
0
+ var body = $('body');
0
+ var maskHTML = DIV({id:'modalmask',style:'display:none;'},[DIV({id:'modal_progress',style:'display:none;',onclick:'location.reload();'})]);
0
+ var modalHTML = DIV({id:'modal_html_ap-wrapper'},[DIV({id:'modal_html_rel-wrapper',style:'display:none;'})]);
0
+ body.insert({top:modalHTML});
0
+ body.insert({top:maskHTML});
0
+ };
0
+ },
0
+
0
+ create: function() {
0
+ this.center();
0
+ this.toggleMask('on');
0
+ this.toggleProgress('on');
0
+ this.toggleObservers('on');
0
+ // document.stopObserving('keypress', actionAreaHelper);
0
+ // if (this.action_bar().hasClassName('barout')) { toggleActionArea('inbox'); }
0
+ },
0
+
0
+ destroy: function(boxid) {
0
+ this.toggleObservers('off');
0
+ this.toggleProgress('off');
0
+ this.toggleMask('off');
0
+ // document.observe('keypress', actionAreaHelper);
0
+ },
0
+
0
+ center: function() {
0
+ this.centerMask();
0
+ this.centerModal();
0
+ },
0
+
0
+ centerMask: function() {
0
+ this.mask.setStyle({height: this.pageSize().height + 'px'});
0
+ this.progress.setStyle({top: (this.scroll().top + 60) + 'px'});
0
+ },
0
+
0
+ centerModal: function() {
0
+ left = (( this.pageSize().width - this.width() ) / 2).ceil();
0
+ if (left < 0) left = 0;
0
+ this.wrapper.setStyle({left: left+'px'});
0
+ },
0
+
0
+ width: function() {
0
+ switch (this.contents) {
0
+ case 'misc' : return 450;
0
+ case 'box' : return 652;
0
+ case 'bookmark' : return 352;
0
+ }
0
+ },
0
+
0
+ toggleMask: function(toggle) {
0
+ if (toggle == 'on') {
0
+ this.mask.appear({duration:0.4, from:0.0, to:0.9, queue:this.queue});
0
+ }
0
+ else {
0
+ // May not need visible check.
0
+ if (this.content.visible()) { this.content.slideUp({duration:0.4, queue:this.queue}); };
0
+ this.mask.fade({duration:0.2, queue:this.queue});
0
+ };
0
+ },
0
+
0
+ toggleObservers: function(toggle) {
0
+ if (toggle == 'on') {
0
+ Event.observe(window, 'resize', this.center.bindAsEventListener(this));
0
+ Event.observe(window, 'scroll', this.center.bind(this));
0
+ document.observe('keypress', this.keypress.bind(this));
0
+ }
0
+ else {
0
+ Event.stopObserving(window, 'resize', this.center);
0
+ Event.stopObserving(window, 'scroll', this.center);
0
+ document.stopObserving('keypress', this.keypress);
0
+ };
0
+ },
0
+
0
+ toggleProgress: function(toggle) {
0
+ var options = {duration:0.2, queue:this.queue}
0
+ if (toggle == 'on') { this.progress.appear(options); } else { this.progress.fade(options); };
0
+ },
0
+
0
+ keypress: function(event) {
0
+ console.log(event)
0
+ if (event.keyCode == Event.KEY_ESC) { this.destroy(); };
0
+ }
0
+
0
+ // hideModal: function(boxid) {
0
+ // boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ // Event.stopObserving(document, 'keypress', respondtoKeypress);
0
+ // Effect.SlideUp(modalContent, {duration:0.4, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ // Effect.Appear(modalProgress, {duration:0.2, from:0.0, to:0.9, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ // },
0
+ //
0
+ // destroyModalMask: function(boxid) {
0
+ // boxid = (boxid == null) ? 'bookmarklet' : boxid;
0
+ // Event.stopObserving(window, 'resize', centerStuff);
0
+ // Event.stopObserving(window, 'scroll', centerStuff);
0
+ // Effect.Fade(modalMask, {duration:0.2, queue:{position:'end', scope:'boxid_' + boxid}});
0
+ // },
0
+ //
0
+ // goHere: function() {
0
+ // window.location.reload();
0
+ // }
0
+
0
+});
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
0
@@ -1 +1,101 @@
0
+
0
+var HomeMarksSite = Class.create(HomeMarksUtilities,{
0
+
0
+ initialize: function() {
0
+ this.ajaxFrom = $('ajaxforms_wrapper');
0
+ this.ajaxFromLinks = $$('.ajaxform_link');
0
+ this.supportForm = $('support_form');
0
+ this.loginForm = $('login_form');
0
+ this.signupForm = $('signup_form');
0
+ this.flashes = $$('div.flash_message');
0
+ this.initEvents();
0
+ },
0
+
0
+ clearFlashes: function() {
0
+ this.flashes.invoke('hide');
0
+ this.flashes.invoke('update','');
0
+ },
0
+
0
+ flash: function(mood,html) {
0
+ this.clearFlashes();
0
+ var moodFlash = this.flashes.find(function(e){ if (e.id == 'flash_'+mood) {return true}; });
0
+ moodFlash.update(html);
0
+ moodFlash.show();
0
+ $('site_wrapper').scrollTo();
0
+ },
0
+
0
+ toggleAjaxFormBlind: function(event) {
0
+ if (event) { event.element().blur(); };
0
+ Effect.toggle(this.ajaxFrom, 'blind', {duration:0.4});
0
+ },
0
+
0
+ startAjaxForm: function(event) {
0
+ event.stop();
0
+ var form = event.findElement('form');
0
+ var options = Object.extend({loadId:'form_loading',imgSrc:'loading_invert.gif'}, arguments[1] || {});
0
+ var imgTag = IMG({src:('/images/'+options.imgSrc)});
0
+ $(options.loadId).update(imgTag);
0
+ new Ajax.Request(form.action,{
0
+ onComplete: function(request){ this.delegateCompleteAjaxForm(form,request) }.bind(this),
0
+ parameters: form.serialize(true)
0
+ });
0
+ form.disable();
0
+ },
0
+
0
+ delegateCompleteAjaxForm: function(form,request) {
0
+ var mood = this.getRequestMood(request);
0
+ this.completeAjaxForm(form,{mood:mood});
0
+ if (mood == 'good') {
0
+ this.clearFlashes();
0
+ switch (form) {
0
+ case this.supportForm : this.completeSupportForm(request);
0
+ case this.loginForm : this.completeLoginForm(request);
0
+ case this.signupForm : this.completeSignupForm(request);
0
+ }
0
+ }
0
+ else {
0
+ form.enable();
0
+ var flashHtml = DIV([H2('Errors:'),this.messagesToList(request)]);
0
+ this.flash('bad',flashHtml);
0
+ };
0
+ },
0
+
0
+ completeAjaxForm: function(form) {
0
+ var options = Object.extend({loadId:'form_loading',mood:'good'}, arguments[1] || {});
0
+ var completeId = 'complete_ajax_form_' + options.loadId;
0
+ var imgSrc = '/images/'+options.mood+'.png';
0
+ var moodHtml = SPAN({id:completeId,className:'m0 p0'}, [IMG({src:imgSrc})]);
0
+ $(options.loadId).update(moodHtml);
0
+ setTimeout(function() { $(completeId).fade(); },3000);
0
+ },
0
+
0
+ submitSupportForm: function(event) {
0
+ this.startAjaxForm(event,{imgSrc:'loading.gif'});
0
+ },
0
+
0
+ completeSupportForm: function(request) {
0
+ setTimeout(function(){ this.supportForm.reset(); this.supportForm.enable(); }.bind(this),2000);
0
+ this.toggleAjaxFormBlind();
0
+ this.flash('good','Thanks for submitting a support request!');
0
+ },
0
+
0
+ completeLoginForm: function(request) {
0
+ window.location = '/myhome'
0
+ },
0
+
0
+ completeSignupForm: function(request) {
0
+ var flashHTML = DIV([H2('Signup Complete:'),P('We have sent an email with a link to verify and activate your account. You can not login unless you verify your email address.')]);
0
+ this.flash('good',flashHTML);
0
+ },
0
+
0
+ initEvents: function() {
0
+ if (this.supportForm) { this.supportForm.observe('submit', this.submitSupportForm.bindAsEventListener(this)); };
0
+ if (this.loginForm) { this.loginForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
+ if (this.signupForm) { this.signupForm.observe('submit', this.startAjaxForm.bindAsEventListener(this)); };
0
+ this.ajaxFromLinks.each(function(element){
0
+ element.observe('click', this.toggleAjaxFormBlind.bindAsEventListener(this));
0
+ }.bind(this));
0
+ }
0
+
0
+});
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
0
@@ -1 +1,75 @@
0
+
0
+// WindowUtilities.getWindowScroll() // => { top: 0, left: 0, width: 1002, height: 464 }
0
+// document.viewport.getDimensions() // => { width: 987, height: 494 }
0
+// document.viewport.getWidth() // => 987
0
+// document.viewport.getHeight() // => 494
0
+// document.viewport.getScrollOffsets() // => [0, 0]
0
+//
0
+// WindowUtilities.getPageSize() // => { pageWidth: 1002, pageHeight: 3129, windowWidth: 1002 }
0
+// WindowUtilities.getPageSize() // => [987,3129]
0
+
0
+var HomeMarksUtilities = {
0
+
0
+ getRequestMood: function(request) {
0
+ return (request.status >= 200 && request.status < 300) ? 'good' : 'bad';
0
+ },
0
+
0
+ messagesToAlert: function(request) {
0
+ var messages = request.responseJSON;
0
+ var alertText = messages.join(".\n");
0
+ if (alertText.endsWith('.')) { alert(alertText); } else { alert(alertText+'.'); };
0
+ },
0
+
0
+ messagesToList: function(request) {
0
+ var messages = request.responseJSON;
0
+ var messageList = UL();
0
+ messages.each(function(message){
0
+ messageList.appendChild( LI(message.escapeHTML()) );
0
+ });
0
+ return messageList;
0
+ },
0
+
0
+ scroll: function() { retu