atlas_assets 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +86 -0
- data/LICENSE +22 -0
- data/Procfile +1 -0
- data/README.md +36 -0
- data/Rakefile +16 -0
- data/_config.yml +13 -0
- data/atlas_assets.gemspec +21 -0
- data/config.ru +9 -0
- data/docs/.gitignore +1 -0
- data/docs/404.html +1 -0
- data/docs/_layouts/default.html +56 -0
- data/docs/_plugins/jekyll_assets.rb +3 -0
- data/docs/_posts/2013-05-17-buttons.md +43 -0
- data/docs/_posts/2013-05-17-flash.md +58 -0
- data/docs/_posts/2013-05-17-fonts.md +26 -0
- data/docs/_posts/2013-05-17-grid.md +60 -0
- data/docs/_posts/2013-05-17-helpers.md +9 -0
- data/docs/_posts/2013-05-17-icons.md +1089 -0
- data/docs/_posts/2013-05-17-lists.md +76 -0
- data/docs/_posts/2013-05-17-navbar.md +73 -0
- data/docs/_posts/2013-05-21-forms.md +423 -0
- data/docs/index.html +31 -0
- data/lib/assets/fonts/atlas.eot +0 -0
- data/lib/assets/fonts/atlas.svg +279 -0
- data/lib/assets/fonts/atlas.ttf +0 -0
- data/lib/assets/fonts/atlas.woff +0 -0
- data/lib/assets/javascripts/atlas_assets.js +9 -0
- data/lib/assets/javascripts/backbone.js +1572 -0
- data/lib/assets/javascripts/jquery.js +9405 -0
- data/lib/assets/javascripts/jquery_ujs.js +378 -0
- data/lib/assets/javascripts/keypress.js +20 -0
- data/lib/assets/javascripts/pusher.js +101 -0
- data/lib/assets/javascripts/setup.js +35 -0
- data/lib/assets/javascripts/string.js +912 -0
- data/lib/assets/javascripts/underscore.js +1228 -0
- data/lib/assets/stylesheets/atlas_assets.css +10 -0
- data/lib/assets/stylesheets/buttons.css.scss +56 -0
- data/lib/assets/stylesheets/flash.css.scss +32 -0
- data/lib/assets/stylesheets/fonts.css.scss +66 -0
- data/lib/assets/stylesheets/forms.css.scss +861 -0
- data/lib/assets/stylesheets/grid.css.scss +762 -0
- data/lib/assets/stylesheets/helpers.css.scss +55 -0
- data/lib/assets/stylesheets/icons.css.scss +823 -0
- data/lib/assets/stylesheets/lists.css.scss +73 -0
- data/lib/assets/stylesheets/navbar.css.scss +121 -0
- data/lib/assets/stylesheets/pre.css.scss +7 -0
- data/lib/atlas_assets/engine.rb +8 -0
- data/lib/atlas_assets/version.rb +5 -0
- data/lib/atlas_assets.rb +1 -0
- data/rails/init.rb +1 -0
- metadata +114 -0
@@ -0,0 +1,378 @@
|
|
1
|
+
|
2
|
+
(function($, undefined) {
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Unobtrusive scripting adapter for jQuery
|
6
|
+
*
|
7
|
+
* Requires jQuery 1.6.0 or later.
|
8
|
+
* https://github.com/rails/jquery-ujs
|
9
|
+
|
10
|
+
* Uploading file using rails.js
|
11
|
+
* =============================
|
12
|
+
*
|
13
|
+
* By default, browsers do not allow files to be uploaded via AJAX. As a result, if there are any non-blank file fields
|
14
|
+
* in the remote form, this adapter aborts the AJAX submission and allows the form to submit through standard means.
|
15
|
+
*
|
16
|
+
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
|
17
|
+
*
|
18
|
+
* Ex:
|
19
|
+
* $('form').live('ajax:aborted:file', function(event, elements){
|
20
|
+
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
|
21
|
+
* // Returning false in this handler tells rails.js to disallow standard form submission
|
22
|
+
* return false;
|
23
|
+
* });
|
24
|
+
*
|
25
|
+
* The `ajax:aborted:file` event is fired when a file-type input is detected with a non-blank value.
|
26
|
+
*
|
27
|
+
* Third-party tools can use this hook to detect when an AJAX file upload is attempted, and then use
|
28
|
+
* techniques like the iframe method to upload the file instead.
|
29
|
+
*
|
30
|
+
* Required fields in rails.js
|
31
|
+
* ===========================
|
32
|
+
*
|
33
|
+
* If any blank required inputs (required="required") are detected in the remote form, the whole form submission
|
34
|
+
* is canceled. Note that this is unlike file inputs, which still allow standard (non-AJAX) form submission.
|
35
|
+
*
|
36
|
+
* The `ajax:aborted:required` event allows you to bind your own handler to inform the user of blank required inputs.
|
37
|
+
*
|
38
|
+
* !! Note that Opera does not fire the form's submit event if there are blank required inputs, so this event may never
|
39
|
+
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
|
40
|
+
*
|
41
|
+
* Ex:
|
42
|
+
* $('form').live('ajax:aborted:required', function(event, elements){
|
43
|
+
* // Returning false in this handler tells rails.js to submit the form anyway.
|
44
|
+
* // The blank required inputs are passed to this function in `elements`.
|
45
|
+
* return ! confirm("Would you like to submit the form with missing info?");
|
46
|
+
* });
|
47
|
+
*/
|
48
|
+
|
49
|
+
// Shorthand to make it a little easier to call public rails functions from within rails.js
|
50
|
+
var rails;
|
51
|
+
|
52
|
+
$.rails = rails = {
|
53
|
+
// Link elements bound by jquery-ujs
|
54
|
+
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
|
55
|
+
|
56
|
+
// Select elements bound by jquery-ujs
|
57
|
+
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
|
58
|
+
|
59
|
+
// Form elements bound by jquery-ujs
|
60
|
+
formSubmitSelector: 'form',
|
61
|
+
|
62
|
+
// Form input elements bound by jquery-ujs
|
63
|
+
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not(button[type])',
|
64
|
+
|
65
|
+
// Form input elements disabled during form submission
|
66
|
+
disableSelector: 'input[data-disable-with], button[data-disable-with], textarea[data-disable-with]',
|
67
|
+
|
68
|
+
// Form input elements re-enabled after form submission
|
69
|
+
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled',
|
70
|
+
|
71
|
+
// Form required input elements
|
72
|
+
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
|
73
|
+
|
74
|
+
// Form file input elements
|
75
|
+
fileInputSelector: 'input:file',
|
76
|
+
|
77
|
+
// Link onClick disable selector with possible reenable after remote submission
|
78
|
+
linkDisableSelector: 'a[data-disable-with]',
|
79
|
+
|
80
|
+
// Make sure that every Ajax request sends the CSRF token
|
81
|
+
CSRFProtection: function(xhr) {
|
82
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
83
|
+
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
|
84
|
+
},
|
85
|
+
|
86
|
+
// Triggers an event on an element and returns false if the event result is false
|
87
|
+
fire: function(obj, name, data) {
|
88
|
+
var event = $.Event(name);
|
89
|
+
obj.trigger(event, data);
|
90
|
+
return event.result !== false;
|
91
|
+
},
|
92
|
+
|
93
|
+
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
|
94
|
+
confirm: function(message) {
|
95
|
+
return confirm(message);
|
96
|
+
},
|
97
|
+
|
98
|
+
// Default ajax function, may be overridden with custom function in $.rails.ajax
|
99
|
+
ajax: function(options) {
|
100
|
+
return $.ajax(options);
|
101
|
+
},
|
102
|
+
|
103
|
+
// Default way to get an element's href. May be overridden at $.rails.href.
|
104
|
+
href: function(element) {
|
105
|
+
return element.attr('href');
|
106
|
+
},
|
107
|
+
|
108
|
+
// Submits "remote" forms and links with ajax
|
109
|
+
handleRemote: function(element) {
|
110
|
+
var method, url, data, crossDomain, dataType, options;
|
111
|
+
|
112
|
+
if (rails.fire(element, 'ajax:before')) {
|
113
|
+
crossDomain = element.data('cross-domain') || null;
|
114
|
+
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
115
|
+
|
116
|
+
if (element.is('form')) {
|
117
|
+
method = element.attr('method');
|
118
|
+
url = element.attr('action');
|
119
|
+
data = element.serializeArray();
|
120
|
+
// memoized value from clicked submit button
|
121
|
+
var button = element.data('ujs:submit-button');
|
122
|
+
if (button) {
|
123
|
+
data.push(button);
|
124
|
+
element.data('ujs:submit-button', null);
|
125
|
+
}
|
126
|
+
} else if (element.is(rails.inputChangeSelector)) {
|
127
|
+
method = element.data('method');
|
128
|
+
url = element.data('url');
|
129
|
+
data = element.serialize();
|
130
|
+
if (element.data('params')) data = data + "&" + element.data('params');
|
131
|
+
} else {
|
132
|
+
method = element.data('method');
|
133
|
+
url = rails.href(element);
|
134
|
+
data = element.data('params') || null;
|
135
|
+
}
|
136
|
+
|
137
|
+
options = {
|
138
|
+
type: method || 'GET', data: data, dataType: dataType, crossDomain: crossDomain,
|
139
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
140
|
+
beforeSend: function(xhr, settings) {
|
141
|
+
if (settings.dataType === undefined) {
|
142
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
143
|
+
}
|
144
|
+
return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
|
145
|
+
},
|
146
|
+
success: function(data, status, xhr) {
|
147
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
148
|
+
},
|
149
|
+
complete: function(xhr, status) {
|
150
|
+
element.trigger('ajax:complete', [xhr, status]);
|
151
|
+
},
|
152
|
+
error: function(xhr, status, error) {
|
153
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
154
|
+
}
|
155
|
+
};
|
156
|
+
// Only pass url to `ajax` options if not blank
|
157
|
+
if (url) { options.url = url; }
|
158
|
+
|
159
|
+
return rails.ajax(options);
|
160
|
+
} else {
|
161
|
+
return false;
|
162
|
+
}
|
163
|
+
},
|
164
|
+
|
165
|
+
// Handles "data-method" on links such as:
|
166
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
167
|
+
handleMethod: function(link) {
|
168
|
+
var href = rails.href(link),
|
169
|
+
method = link.data('method'),
|
170
|
+
target = link.attr('target'),
|
171
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
172
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
173
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
174
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
175
|
+
|
176
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
177
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
178
|
+
}
|
179
|
+
|
180
|
+
if (target) { form.attr('target', target); }
|
181
|
+
|
182
|
+
form.hide().append(metadata_input).appendTo('body');
|
183
|
+
form.submit();
|
184
|
+
},
|
185
|
+
|
186
|
+
/* Disables form elements:
|
187
|
+
- Caches element value in 'ujs:enable-with' data store
|
188
|
+
- Replaces element text with value of 'data-disable-with' attribute
|
189
|
+
- Sets disabled property to true
|
190
|
+
*/
|
191
|
+
disableFormElements: function(form) {
|
192
|
+
form.find(rails.disableSelector).each(function() {
|
193
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
194
|
+
element.data('ujs:enable-with', element[method]());
|
195
|
+
element[method](element.data('disable-with'));
|
196
|
+
element.prop('disabled', true);
|
197
|
+
});
|
198
|
+
},
|
199
|
+
|
200
|
+
/* Re-enables disabled form elements:
|
201
|
+
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
|
202
|
+
- Sets disabled property to false
|
203
|
+
*/
|
204
|
+
enableFormElements: function(form) {
|
205
|
+
form.find(rails.enableSelector).each(function() {
|
206
|
+
var element = $(this), method = element.is('button') ? 'html' : 'val';
|
207
|
+
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
|
208
|
+
element.prop('disabled', false);
|
209
|
+
});
|
210
|
+
},
|
211
|
+
|
212
|
+
/* For 'data-confirm' attribute:
|
213
|
+
- Fires `confirm` event
|
214
|
+
- Shows the confirmation dialog
|
215
|
+
- Fires the `confirm:complete` event
|
216
|
+
|
217
|
+
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
|
218
|
+
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
|
219
|
+
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
|
220
|
+
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
|
221
|
+
*/
|
222
|
+
allowAction: function(element) {
|
223
|
+
var message = element.data('confirm'),
|
224
|
+
answer = false, callback;
|
225
|
+
if (!message) { return true; }
|
226
|
+
|
227
|
+
if (rails.fire(element, 'confirm')) {
|
228
|
+
answer = rails.confirm(message);
|
229
|
+
callback = rails.fire(element, 'confirm:complete', [answer]);
|
230
|
+
}
|
231
|
+
return answer && callback;
|
232
|
+
},
|
233
|
+
|
234
|
+
// Helper function which checks for blank inputs in a form that match the specified CSS selector
|
235
|
+
blankInputs: function(form, specifiedSelector, nonBlank) {
|
236
|
+
var inputs = $(), input,
|
237
|
+
selector = specifiedSelector || 'input,textarea';
|
238
|
+
form.find(selector).each(function() {
|
239
|
+
input = $(this);
|
240
|
+
// Collect non-blank inputs if nonBlank option is true, otherwise, collect blank inputs
|
241
|
+
if (nonBlank ? input.val() : !input.val()) {
|
242
|
+
inputs = inputs.add(input);
|
243
|
+
}
|
244
|
+
});
|
245
|
+
return inputs.length ? inputs : false;
|
246
|
+
},
|
247
|
+
|
248
|
+
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
|
249
|
+
nonBlankInputs: function(form, specifiedSelector) {
|
250
|
+
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
|
251
|
+
},
|
252
|
+
|
253
|
+
// Helper function, needed to provide consistent behavior in IE
|
254
|
+
stopEverything: function(e) {
|
255
|
+
$(e.target).trigger('ujs:everythingStopped');
|
256
|
+
e.stopImmediatePropagation();
|
257
|
+
return false;
|
258
|
+
},
|
259
|
+
|
260
|
+
// find all the submit events directly bound to the form and
|
261
|
+
// manually invoke them. If anyone returns false then stop the loop
|
262
|
+
callFormSubmitBindings: function(form, event) {
|
263
|
+
var events = form.data('events'), continuePropagation = true;
|
264
|
+
if (events !== undefined && events['submit'] !== undefined) {
|
265
|
+
$.each(events['submit'], function(i, obj){
|
266
|
+
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
|
267
|
+
});
|
268
|
+
}
|
269
|
+
return continuePropagation;
|
270
|
+
},
|
271
|
+
|
272
|
+
// replace element's html with the 'data-disable-with' after storing original html
|
273
|
+
// and prevent clicking on it
|
274
|
+
disableElement: function(element) {
|
275
|
+
element.data('ujs:enable-with', element.html()); // store enabled state
|
276
|
+
element.html(element.data('disable-with')); // set to disabled state
|
277
|
+
element.bind('click.railsDisable', function(e) { // prevent further clicking
|
278
|
+
return rails.stopEverything(e)
|
279
|
+
});
|
280
|
+
},
|
281
|
+
|
282
|
+
// restore element to its original state which was disabled by 'disableElement' above
|
283
|
+
enableElement: function(element) {
|
284
|
+
if (element.data('ujs:enable-with') !== undefined) {
|
285
|
+
element.html(element.data('ujs:enable-with')); // set to old enabled state
|
286
|
+
// this should be element.removeData('ujs:enable-with')
|
287
|
+
// but, there is currently a bug in jquery which makes hyphenated data attributes not get removed
|
288
|
+
element.data('ujs:enable-with', false); // clean up cache
|
289
|
+
}
|
290
|
+
element.unbind('click.railsDisable'); // enable element
|
291
|
+
}
|
292
|
+
|
293
|
+
};
|
294
|
+
|
295
|
+
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
|
296
|
+
|
297
|
+
$(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
|
298
|
+
rails.enableElement($(this));
|
299
|
+
});
|
300
|
+
|
301
|
+
$(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
|
302
|
+
var link = $(this), method = link.data('method'), data = link.data('params');
|
303
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
304
|
+
|
305
|
+
if (link.is(rails.linkDisableSelector)) rails.disableElement(link);
|
306
|
+
|
307
|
+
if (link.data('remote') !== undefined) {
|
308
|
+
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
|
309
|
+
|
310
|
+
if (rails.handleRemote(link) === false) { rails.enableElement(link); }
|
311
|
+
return false;
|
312
|
+
|
313
|
+
} else if (link.data('method')) {
|
314
|
+
rails.handleMethod(link);
|
315
|
+
return false;
|
316
|
+
}
|
317
|
+
});
|
318
|
+
|
319
|
+
$(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
|
320
|
+
var link = $(this);
|
321
|
+
if (!rails.allowAction(link)) return rails.stopEverything(e);
|
322
|
+
|
323
|
+
rails.handleRemote(link);
|
324
|
+
return false;
|
325
|
+
});
|
326
|
+
|
327
|
+
$(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
|
328
|
+
var form = $(this),
|
329
|
+
remote = form.data('remote') !== undefined,
|
330
|
+
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
|
331
|
+
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
|
332
|
+
|
333
|
+
if (!rails.allowAction(form)) return rails.stopEverything(e);
|
334
|
+
|
335
|
+
// skip other logic when required values are missing or file upload is present
|
336
|
+
if (blankRequiredInputs && form.attr("novalidate") == undefined && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
|
337
|
+
return rails.stopEverything(e);
|
338
|
+
}
|
339
|
+
|
340
|
+
if (remote) {
|
341
|
+
if (nonBlankFileInputs) {
|
342
|
+
return rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
|
343
|
+
}
|
344
|
+
|
345
|
+
// If browser does not support submit bubbling, then this live-binding will be called before direct
|
346
|
+
// bindings. Therefore, we should directly call any direct bindings before remotely submitting form.
|
347
|
+
if (!$.support.submitBubbles && $().jquery < '1.7' && rails.callFormSubmitBindings(form, e) === false) return rails.stopEverything(e);
|
348
|
+
|
349
|
+
rails.handleRemote(form);
|
350
|
+
return false;
|
351
|
+
|
352
|
+
} else {
|
353
|
+
// slight timeout so that the submit button gets properly serialized
|
354
|
+
setTimeout(function(){ rails.disableFormElements(form); }, 13);
|
355
|
+
}
|
356
|
+
});
|
357
|
+
|
358
|
+
$(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
|
359
|
+
var button = $(this);
|
360
|
+
|
361
|
+
if (!rails.allowAction(button)) return rails.stopEverything(event);
|
362
|
+
|
363
|
+
// register the pressed submit button
|
364
|
+
var name = button.attr('name'),
|
365
|
+
data = name ? {name:name, value:button.val()} : null;
|
366
|
+
|
367
|
+
button.closest('form').data('ujs:submit-button', data);
|
368
|
+
});
|
369
|
+
|
370
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
|
371
|
+
if (this == event.target) rails.disableFormElements($(this));
|
372
|
+
});
|
373
|
+
|
374
|
+
$(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
|
375
|
+
if (this == event.target) rails.enableFormElements($(this));
|
376
|
+
});
|
377
|
+
|
378
|
+
})( jQuery );
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/* Keypress version 1.0.3 */
|
2
|
+
(function(){var v,w,j,O,P,Q,R,D,x,y,E,F,m,S,T,U,G,V,W,X,H,Y,n,q,g,I,r,J,s,t,K,z,u,L,A,k,M,p,B,N,C,Z,h=[].indexOf||function(a){for(var c=0,b=this.length;c<b;c++)if(c in this&&this[c]===a)return c;return-1},aa={}.hasOwnProperty;Array.prototype.filter||(Array.prototype.filter=function(a){var c,b,d,e;e=[];b=0;for(d=this.length;b<d;b++)c=this[b],a(c)&&e.push(c);return e});k=[];p=[];B=null;g=[];j=[];z=!1;s="ctrl";K="meta alt option ctrl shift cmd".split(" ");C=[];x={keys:[],count:0};r=function(){return console.log.apply(console,
|
3
|
+
arguments)};y=function(a,c){var b,d,e;if(a.length!==c.length)return false;d=0;for(e=a.length;d<e;d++){b=a[d];if(!(h.call(c,b)>=0))return false}d=0;for(e=c.length;d<e;d++){b=c[d];if(!(h.call(a,b)>=0))return false}return true};u=function(a,c){if((c||keypress.suppress_event_defaults)&&!keypress.force_event_defaults){a.preventDefault?a.preventDefault():a.returnValue=false;if(a.stopPropagation)return a.stopPropagation()}};Q=function(a){if(a.prevent_repeat)return false;if(typeof a.on_keydown==="function")return true};
|
4
|
+
I=function(a){var c,b,d,e;e=a.keys;b=0;for(d=e.length;b<d;b++){a=e[b];if(h.call(g,a)>=0){c=true;break}}return c};m=function(a,c,b){typeof c["on_"+a]==="function"&&u(b,c["on_"+a].call(c["this"],b,c.count)===false);if(a==="release")c.count=0;if(a==="keyup")return c.keyup_fired=true};J=function(a,c,b){var d,e,f,i;b==null&&(b=false);d=[];f=0;for(i=c.length;f<i;f++){e=c[f];if(!c.is_sequence)if(e.is_ordered){a.join("")===e.keys.join("")&&d.push(e);b&&a.join("")===e.keys.slice(0,a.length).join("")&&d.push(e)}else{y(a,
|
5
|
+
e.keys)&&d.push(e);b&&y(a,e.keys.slice(0,a.length))&&d.push(e)}}return d};D=function(a){return h.call(g,"cmd")>=0&&h.call(a,"cmd")<0?false:true};S=function(a){var c,b,d,e,f,i,h;e=[];b=g.filter(function(b){return b!==a});b.push(a);d=J(b,k);d.length&&D(b)&&(e=d);c=false;i=0;for(h=e.length;i<h;i++){d=e[i];d.is_exclusive&&(c=true)}f=function(a){var b,d,i,h,g,$,j;b=h=0;for(j=a.length;0<=j?h<j:h>j;b=0<=j?++h:--h){i=a.slice();i.splice(b,1);if(i.length){d=J(i,k);g=0;for($=d.length;g<$;g++){b=d[g];(!c||!b.is_exclusive)&&
|
6
|
+
e.push(b)}f(i)}}};f(b);return e};U=function(a){var c,b,d,e;b=[];d=0;for(e=k.length;d<e;d++){c=k[d];c.is_sequence||h.call(c.keys,a)>=0&&D(c.keys)&&b.push(c)}return b};P=function(a){var c,b,d,e,f,i,g,k,l;f=false;if(h.call(j,a)>=0)return false;if(j.length){d=i=0;for(l=j.length;0<=l?i<l:i>l;d=0<=l?++i:--i){c=j[d];if(c.is_exclusive&&a.is_exclusive){b=c.keys.slice();g=0;for(k=b.length;g<k;g++){c=b[g];e=true;if(h.call(a.keys,c)<0){e=false;break}}if(e){j.splice(d,1,a);f=true;break}}}}f||j.unshift(a);return true};
|
7
|
+
M=function(a){var c,b,d,e;b=d=0;for(e=j.length;0<=e?d<e:d>e;b=0<=e?++d:--d){c=j[b];if(c===a){j.splice(b,1);break}}};O=function(a,c){var b,d,e,f;p.push(a);d=T();if(d.length){e=0;for(f=d.length;e<f;e++){b=d[e];u(c,b.prevent_default)}B&&clearTimeout(B);keypress.sequence_delay>-1&&(B=setTimeout(function(){return p=[]},keypress.sequence_delay))}else p=[]};T=function(){var a,c,b,d,e,f,i,g,j,l,o;d=[];f=0;for(j=k.length;f<j;f++){a=k[f];c=i=1;for(l=p.length;1<=l?i<=l:i>=l;c=1<=l?++i:--i){e=p.slice(-c);if(a.is_sequence){if(h.call(a.keys,
|
8
|
+
"shift")<0){e=e.filter(function(a){return a!=="shift"});if(!e.length)continue}c=g=0;for(o=e.length;0<=o?g<o:g>o;c=0<=o?++g:--g)if(a.keys[c]===e[c])b=true;else{b=false;break}b&&d.push(a)}}}return d};G=function(a){var c,b,d,e,f,g,j,m,l,o,n;g=0;for(l=k.length;g<l;g++){c=k[g];if(c.is_sequence){b=j=1;for(o=p.length;1<=o?j<=o:j>=o;b=1<=o?++j:--j){f=p.filter(function(a){return h.call(c.keys,"shift")>=0?true:a!=="shift"}).slice(-b);if(c.keys.length===f.length){b=m=0;for(n=f.length;0<=n?m<n:m>n;b=0<=n?++m:
|
9
|
+
--m){e=f[b];if(!(h.call(c.keys,"shift")<0&&e==="shift")&&!(a==="shift"&&h.call(c.keys,"shift")<0))if(c.keys[b]===e)d=true;else{d=false;break}}}}if(d)return c}}return false};F=function(a,c){var b;if(!c.shiftKey)return false;b=q[a];return b!=null?b:false};V=function(a,c,b){if(h.call(a.keys,c)<0)return false;u(b,a&&a.prevent_default);if(h.call(g,c)>=0&&!Q(a))return false;P(a,c);a.keyup_fired=false;if(a.is_counting&&typeof a.on_keydown==="function")a.count=a.count+1;return m("keydown",a,b)};X=function(a,
|
10
|
+
c){var b,d,e,f;(d=F(a,c))&&(a=d);O(a,c);(d=G(a))&&m("keydown",d,c);for(b in t){d=t[b];if(c[d]){b==="meta"&&(b=s);b===a||h.call(g,b)>=0||g.push(b)}}for(b in t){d=t[b];b==="meta"&&(b=s);if(b!==a&&h.call(g,b)>=0&&!c[d]){d=e=0;for(f=g.length;0<=f?e<f:e>f;d=0<=f?++e:--e)g[d]===b&&g.splice(d,1)}}d=S(a);e=0;for(f=d.length;e<f;e++){b=d[e];V(b,a,c)}d=U(a);if(d.length){e=0;for(f=d.length;e<f;e++){b=d[e];u(c,b.prevent_default)}}h.call(g,a)<0&&g.push(a)};W=function(a,c){var b;b=I(a);if(!a.keyup_fired&&(!a.is_counting||
|
11
|
+
a.is_counting&&b)){m("keyup",a,c);if(a.is_counting&&typeof a.on_keyup==="function"&&typeof a.on_keydown!=="function")a.count=a.count+1}if(!b){a.is_counting&&m("release",a,c);M(a)}};H=function(a,c){var b,d,e,f,i,k;d=a;(e=F(a,c))&&(a=e);e=q[d];c.shiftKey?e&&h.call(g,e)>=0||(a=d):d&&h.call(g,d)>=0||(a=e);(f=G(a))&&m("keyup",f,c);if(h.call(g,a)<0)return false;f=i=0;for(k=g.length;0<=k?i<k:i>k;f=0<=k?++i:--i)if((b=g[f])===a||b===e||b===d){g.splice(f,1);break}d=j.length;e=[];f=0;for(i=j.length;f<i;f++){b=
|
12
|
+
j[f];h.call(b.keys,a)>=0&&e.push(b)}f=0;for(i=e.length;f<i;f++){b=e[f];W(b,c)}if(d>1){d=0;for(f=j.length;d<f;d++){b=j[d];b===void 0||h.call(e,b)>=0||I(b)||M(b)}}};A=function(a,c){var b;if(z)g.length&&(g=[]);else if(c||g.length)if(b=E(a.keyCode))return c?X(b,a):H(b,a)};N=function(a){var c,b,d,e;e=[];c=b=0;for(d=k.length;0<=d?b<d:b>d;c=0<=d?++b:--b)if(a===k[c]){k.splice(c,1);break}else e.push(void 0);return e};Z=function(a){var c,b,d,e,f;a.keys.length||r("You're trying to bind a combo with no keys.");
|
13
|
+
b=e=0;for(f=a.keys.length;0<=f?e<f:e>f;b=0<=f?++e:--e){d=a.keys[b];(c=Y[d])&&(d=a.keys[b]=c);d==="meta"&&a.keys.splice(b,1,s);d==="cmd"&&r('Warning: use the "meta" key rather than "cmd" for Windows compatibility')}f=a.keys;c=0;for(e=f.length;c<e;c++){d=f[c];if(h.call(C,d)<0){r('Do not recognize the key "'+d+'"');return false}}if(h.call(a.keys,"meta")>=0||h.call(a.keys,"cmd")>=0){c=a.keys.slice();e=0;for(f=K.length;e<f;e++){d=K[e];(b=c.indexOf(d))>-1&&c.splice(b,1)}c.length>1&&r("META and CMD key combos cannot have more than 1 non-modifier keys",
|
14
|
+
a,c)}return true};R=function(a){var c;if(h.call(g,"cmd")>=0&&(c=E(a.keyCode))!=="cmd"&&c!=="shift"&&c!=="alt"&&c!=="caps"&&c!=="tab")return A(a,false)};window.keypress={};keypress.force_event_defaults=!1;keypress.suppress_event_defaults=!1;keypress.sequence_delay=800;keypress.reset=function(){k=[]};keypress.combo=function(a,c,b){b==null&&(b=false);return keypress.register_combo({keys:a,on_keydown:c,prevent_default:b})};keypress.counting_combo=function(a,c,b){b==null&&(b=false);return keypress.register_combo({keys:a,
|
15
|
+
is_counting:true,is_ordered:true,on_keydown:c,prevent_default:b})};keypress.sequence_combo=function(a,c,b){b==null&&(b=false);return keypress.register_combo({keys:a,on_keydown:c,is_sequence:true,prevent_default:b})};keypress.register_combo=function(a){var c,b;if(typeof a.keys==="string")a.keys=a.keys.split(" ");for(c in x)if(aa.call(x,c)){b=x[c];a[c]==null&&(a[c]=b)}if(Z(a)){k.push(a);return true}};keypress.register_many=function(a){var c,b,d,e;e=[];b=0;for(d=a.length;b<d;b++){c=a[b];e.push(keypress.register_combo(c))}return e};
|
16
|
+
keypress.unregister_combo=function(a){var c,b,d;if(!a)return false;if(a.keys)return N(a);d=[];c=0;for(b=k.length;c<b;c++)(a=k[c])&&(y(keys,a.keys)?d.push(N(a)):d.push(void 0));return d};keypress.unregister_many=function(a){var c,b,d,e;e=[];b=0;for(d=a.length;b<d;b++){c=a[b];e.push(keypress.unregister_combo(c))}return e};keypress.listen=function(){return z=false};keypress.stop_listening=function(){return z=true};E=function(a){return n[a]};t={meta:"metaKey",ctrl:"ctrlKey",shift:"shiftKey",alt:"altKey"};
|
17
|
+
Y={control:"ctrl",command:"cmd","break":"pause",windows:"cmd",option:"alt",caps_lock:"caps",apostrophe:"'",semicolon:";",tilde:"~",accent:"`",scroll_lock:"scroll",num_lock:"num"};q={"/":"?",".":">",",":"<","'":'"',";":":","[":"{","]":"}","\\":"|","`":"~","=":"+","-":"_",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(","0":")"};n={"0":"\\",8:"backspace",9:"tab",12:"num",13:"enter",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"caps",27:"escape",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",
|
18
|
+
37:"left",38:"up",39:"right",40:"down",44:"print",45:"insert",46:"delete",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",91:"cmd",92:"cmd",93:"cmd",96:"num_0",97:"num_1",98:"num_2",99:"num_3",100:"num_4",101:"num_5",102:"num_6",103:"num_7",104:"num_8",105:"num_9",106:"num_multiply",107:"num_add",
|
19
|
+
108:"num_enter",109:"num_subtract",110:"num_decimal",111:"num_divide",124:"print",144:"num",145:"scroll",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",224:"cmd",57392:"ctrl",63289:"num"};for(w in n)v=n[w],C.push(v);for(w in q)v=q[w],C.push(v);-1!==navigator.userAgent.indexOf("Mac OS X")&&(s="cmd");-1!==navigator.userAgent.indexOf("Opera")&&(n["17"]="cmd");L=function(a){return/loading/.test(document.readyState)?setTimeout(function(){return L(a)},9):a()};L(function(){document.body.onkeydown=
|
20
|
+
function(a){a=a||window.event;A(a,true);return R(a)};document.body.onkeyup=function(a){a=a||window.event;return A(a,false)};return window.onblur=function(){var a,c,b;c=0;for(b=g.length;c<b;c++){a=g[c];H(a,{})}g=[];return[]}})}).call(this);
|
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
/*!
|
3
|
+
* Pusher JavaScript Library v2.0.0
|
4
|
+
* http://pusherapp.com/
|
5
|
+
*
|
6
|
+
* Copyright 2013, Pusher
|
7
|
+
* Released under the MIT licence.
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function(){function b(a,h){var e=this;this.options=h||{};this.key=a;this.channels=new b.Channels;this.global_emitter=new b.EventsDispatcher;this.sessionID=Math.floor(Math.random()*1E9);c(this.key);this.connection=new b.ConnectionManager(this.key,b.Util.extend({getStrategy:function(a){return b.StrategyBuilder.build(b.getDefaultStrategy(),b.Util.extend({},e.options,a))},getTimeline:function(){return new b.Timeline(e.key,e.sessionID,{features:b.Util.getClientFeatures(),params:e.options.timelineParams||
|
11
|
+
{},limit:25,level:b.Timeline.INFO,version:b.VERSION})},getTimelineSender:function(a,d){return e.options.disableStats?null:new b.TimelineSender(a,{encrypted:e.isEncrypted()||!!d.encrypted,host:b.stats_host,path:"/timeline"})},activityTimeout:b.activity_timeout,pongTimeout:b.pong_timeout,unavailableTimeout:b.unavailable_timeout},this.options,{encrypted:this.isEncrypted()}));this.connection.bind("connected",function(){e.subscribeAll()});this.connection.bind("message",function(a){var d=a.event.indexOf("pusher_internal:")===
|
12
|
+
0;if(a.channel){var b=e.channel(a.channel);b&&b.emit(a.event,a.data)}d||e.global_emitter.emit(a.event,a.data)});this.connection.bind("disconnected",function(){e.channels.disconnect()});this.connection.bind("error",function(a){b.warn("Error",a)});b.instances.push(this);b.isReady&&e.connect()}function c(a){(a===null||a===void 0)&&b.warn("Warning","You must pass your app key when you instantiate Pusher.")}var a=b.prototype;b.instances=[];b.isReady=!1;b.debug=function(){b.log&&b.log(b.Util.stringify.apply(this,
|
13
|
+
arguments))};b.warn=function(){window.console&&window.console.warn?window.console.warn(b.Util.stringify.apply(this,arguments)):b.log&&b.log(b.Util.stringify.apply(this,arguments))};b.ready=function(){b.isReady=!0;for(var a=0,c=b.instances.length;a<c;a++)b.instances[a].connect()};a.channel=function(a){return this.channels.find(a)};a.connect=function(){this.connection.connect()};a.disconnect=function(){this.connection.disconnect()};a.bind=function(a,b){this.global_emitter.bind(a,b);return this};a.bind_all=
|
14
|
+
function(a){this.global_emitter.bind_all(a);return this};a.subscribeAll=function(){for(var a in this.channels.channels)this.channels.channels.hasOwnProperty(a)&&this.subscribe(a)};a.subscribe=function(a){var b=this,c=this.channels.add(a,this);this.connection.state==="connected"&&c.authorize(this.connection.socket_id,this.options,function(f,g){f?c.emit("pusher:subscription_error",g):b.send_event("pusher:subscribe",{channel:a,auth:g.auth,channel_data:g.channel_data})});return c};a.unsubscribe=function(a){this.channels.remove(a);
|
15
|
+
this.connection.state==="connected"&&this.send_event("pusher:unsubscribe",{channel:a})};a.send_event=function(a,b,c){return this.connection.send_event(a,b,c)};a.isEncrypted=function(){return b.Util.getDocumentLocation().protocol==="https:"?!0:!!this.options.encrypted};this.Pusher=b}).call(this);
|
16
|
+
(function(){Pusher.Util={now:function(){return Date.now?Date.now():(new Date).valueOf()},extend:function(b){for(var c=1;c<arguments.length;c++){var a=arguments[c],d;for(d in a)b[d]=a[d]&&a[d].constructor&&a[d].constructor===Object?Pusher.Util.extend(b[d]||{},a[d]):a[d]}return b},stringify:function(){for(var b=["Pusher"],c=0;c<arguments.length;c++)typeof arguments[c]==="string"?b.push(arguments[c]):window.JSON===void 0?b.push(arguments[c].toString()):b.push(JSON.stringify(arguments[c]));return b.join(" : ")},
|
17
|
+
arrayIndexOf:function(b,c){var a=Array.prototype.indexOf;if(b===null)return-1;if(a&&b.indexOf===a)return b.indexOf(c);for(var a=0,d=b.length;a<d;a++)if(b[a]===c)return a;return-1},keys:function(b){var c=[],a;for(a in b)Object.prototype.hasOwnProperty.call(b,a)&&c.push(a);return c},apply:function(b,c){for(var a=0;a<b.length;a++)c(b[a],a,b)},objectApply:function(b,c){for(var a in b)Object.prototype.hasOwnProperty.call(b,a)&&c(b[a],a,b)},map:function(b,c){for(var a=[],d=0;d<b.length;d++)a.push(c(b[d],
|
18
|
+
d,b,a));return a},mapObject:function(b,c){var a={},d;for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=c(b[d]));return a},filter:function(b,c){for(var c=c||function(a){return!!a},a=[],d=0;d<b.length;d++)c(b[d],d,b,a)&&a.push(b[d]);return a},filterObject:function(b,c){var c=c||function(a){return!!a},a={},d;for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&c(b[d],d,b,a)&&(a[d]=b[d]);return a},flatten:function(b){var c=[],a;for(a in b)Object.prototype.hasOwnProperty.call(b,a)&&c.push([a,
|
19
|
+
b[a]]);return c},any:function(b,c){for(var a=0;a<b.length;a++)if(c(b[a],a,b))return!0;return!1},all:function(b,c){for(var a=0;a<b.length;a++)if(!c(b[a],a,b))return!1;return!0},method:function(b){var c=Array.prototype.slice.call(arguments,1);return function(a){return a[b].apply(a,c.concat(arguments))}},getDocument:function(){return document},getDocumentLocation:function(){return Pusher.Util.getDocument().location},getLocalStorage:function(){return window.localStorage},getClientFeatures:function(){return Pusher.Util.keys(Pusher.Util.filterObject({ws:Pusher.WSTransport,
|
20
|
+
flash:Pusher.FlashTransport},function(b){return b.isSupported()}))}}}).call(this);
|
21
|
+
(function(){Pusher.VERSION="2.0.0";Pusher.PROTOCOL=6;Pusher.host="ws.pusherapp.com";Pusher.ws_port=80;Pusher.wss_port=443;Pusher.sockjs_host="sockjs.pusher.com";Pusher.sockjs_http_port=80;Pusher.sockjs_https_port=443;Pusher.sockjs_path="/pusher";Pusher.stats_host="stats.pusher.com";Pusher.channel_auth_endpoint="/pusher/auth";Pusher.cdn_http="http://js.pusher.com/";Pusher.cdn_https="https://d3dy5gmtp8yhk7.cloudfront.net/";Pusher.dependency_suffix=".min";Pusher.channel_auth_transport="ajax";Pusher.activity_timeout=
|
22
|
+
12E4;Pusher.pong_timeout=3E4;Pusher.unavailable_timeout=1E4;Pusher.getDefaultStrategy=function(){return[[":def","ws_options",{hostUnencrypted:Pusher.host+":"+Pusher.ws_port,hostEncrypted:Pusher.host+":"+Pusher.wss_port}],[":def","sockjs_options",{hostUnencrypted:Pusher.sockjs_host+":"+Pusher.sockjs_http_port,hostEncrypted:Pusher.sockjs_host+":"+Pusher.sockjs_https_port}],[":def","timeouts",{loop:!0,timeout:15E3,timeoutLimit:6E4}],[":def","ws_manager",[":transport_manager",{lives:2}]],[":def_transport",
|
23
|
+
"ws","ws",3,":ws_options",":ws_manager"],[":def_transport","flash","flash",2,":ws_options",":ws_manager"],[":def_transport","sockjs","sockjs",1,":sockjs_options"],[":def","ws_loop",[":sequential",":timeouts",":ws"]],[":def","flash_loop",[":sequential",":timeouts",":flash"]],[":def","sockjs_loop",[":sequential",":timeouts",":sockjs"]],[":def","strategy",[":cached",18E5,[":first_connected",[":if",[":is_supported",":ws"],[":best_connected_ever",":ws_loop",[":delayed",2E3,[":sockjs_loop"]]],[":if",[":is_supported",
|
24
|
+
":flash"],[":best_connected_ever",":flash_loop",[":delayed",2E3,[":sockjs_loop"]]],[":sockjs_loop"]]]]]]]}}).call(this);(function(){function b(b){var a=function(a){Error.call(this,a);this.name=b};Pusher.Util.extend(a.prototype,Error.prototype);return a}Pusher.Errors={UnsupportedTransport:b("UnsupportedTransport"),UnsupportedStrategy:b("UnsupportedStrategy"),TransportPriorityTooLow:b("TransportPriorityTooLow"),TransportClosed:b("TransportClosed")}}).call(this);
|
25
|
+
(function(){function b(a){this.callbacks=new c;this.global_callbacks=[];this.failThrough=a}function c(){this._callbacks={}}var a=b.prototype;a.bind=function(a,b){this.callbacks.add(a,b);return this};a.bind_all=function(a){this.global_callbacks.push(a);return this};a.unbind=function(a,b){this.callbacks.remove(a,b);return this};a.emit=function(a,b){var c;for(c=0;c<this.global_callbacks.length;c++)this.global_callbacks[c](a,b);var f=this.callbacks.get(a);if(f&&f.length>0)for(c=0;c<f.length;c++)f[c](b);
|
26
|
+
else this.failThrough&&this.failThrough(a,b);return this};c.prototype.get=function(a){return this._callbacks[this._prefix(a)]};c.prototype.add=function(a,b){var c=this._prefix(a);this._callbacks[c]=this._callbacks[c]||[];this._callbacks[c].push(b)};c.prototype.remove=function(a,b){if(this.get(a)){var c=Pusher.Util.arrayIndexOf(this.get(a),b),f=this._callbacks[this._prefix(a)].slice(0);f.splice(c,1);this._callbacks[this._prefix(a)]=f}};c.prototype._prefix=function(a){return"_"+a};Pusher.EventsDispatcher=
|
27
|
+
b}).call(this);
|
28
|
+
(function(){function b(a){this.options=a;this.loading={};this.loaded={}}function c(a,d){Pusher.Util.getDocument().addEventListener?a.addEventListener("load",d,!1):a.attachEvent("onreadystatechange",function(){(a.readyState==="loaded"||a.readyState==="complete")&&d()})}function a(a,d){var b=Pusher.Util.getDocument(),g=b.getElementsByTagName("head")[0],b=b.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");b.setAttribute("async",!0);c(b,function(){setTimeout(d,0)});
|
29
|
+
g.appendChild(b)}var d=b.prototype;d.load=function(d,b){var c=this;this.loaded[d]?b():(this.loading[d]||(this.loading[d]=[]),this.loading[d].push(b),this.loading[d].length>1||a(this.getPath(d),function(){for(var a=0;a<c.loading[d].length;a++)c.loading[d][a]();delete c.loading[d];c.loaded[d]=!0}))};d.getRoot=function(a){var d=Pusher.Util.getDocumentLocation().protocol;return(a&&a.encrypted||d==="https:"?this.options.cdn_https:this.options.cdn_http).replace(/\/*$/,"")+"/"+this.options.version};d.getPath=
|
30
|
+
function(a,d){return this.getRoot(d)+"/"+a+this.options.suffix+".js"};Pusher.DependencyLoader=b}).call(this);
|
31
|
+
(function(){function b(){Pusher.ready()}function c(a){document.body?a():setTimeout(function(){c(a)},0)}function a(){c(b)}Pusher.Dependencies=new Pusher.DependencyLoader({cdn_http:Pusher.cdn_http,cdn_https:Pusher.cdn_https,version:Pusher.VERSION,suffix:Pusher.dependency_suffix});if(!window.WebSocket&&window.MozWebSocket)window.WebSocket=window.MozWebSocket;window.JSON?a():Pusher.Dependencies.load("json2",a)})();
|
32
|
+
(function(){function b(a,d){var b=this;this.timeout=setTimeout(function(){if(b.timeout!==null)d(),b.timeout=null},a)}var c=b.prototype;c.isRunning=function(){return this.timeout!==null};c.ensureAborted=function(){if(this.timeout)clearTimeout(this.timeout),this.timeout=null};Pusher.Timer=b}).call(this);
|
33
|
+
(function(){for(var b=String.fromCharCode,c=0;c<64;c++)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c);var a=function(a){var d=a.charCodeAt(0);return d<128?a:d<2048?b(192|d>>>6)+b(128|d&63):b(224|d>>>12&15)+b(128|d>>>6&63)+b(128|d&63)},d=function(a){var d=[0,2,1][a.length%3],a=a.charCodeAt(0)<<16|(a.length>1?a.charCodeAt(1):0)<<8|(a.length>2?a.charCodeAt(2):0);return["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>18),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>
|
34
|
+
12&63),d>=2?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6&63),d>=1?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a&63)].join("")},h=window.btoa||function(a){return a.replace(/[\s\S]{1,3}/g,d)};Pusher.Base64={encode:function(d){return h(d.replace(/[^\x00-\x7F]/g,a))}}}).call(this);
|
35
|
+
(function(){function b(a){this.options=a}function c(a){return Pusher.Util.mapObject(a,function(a){typeof a==="object"&&(a=JSON.stringify(a));return encodeURIComponent(Pusher.Base64.encode(a.toString()))})}b.send=function(a,b){var c=new Pusher.JSONPRequest({url:a.url,receiver:a.receiverName,tagPrefix:a.tagPrefix}),f=a.receiver.register(function(a,d){c.cleanup();b(a,d)});return c.send(f,a.data,function(b){var c=a.receiver.unregister(f);c&&c(b)})};var a=b.prototype;a.send=function(a,b,e){if(this.script)return!1;
|
36
|
+
var f=this.options.tagPrefix||"_pusher_jsonp_",b=Pusher.Util.extend({},b,{receiver:this.options.receiver}),b=Pusher.Util.map(Pusher.Util.flatten(c(Pusher.Util.filterObject(b,function(a){return a!==void 0}))),Pusher.Util.method("join","=")).join("&");this.script=document.createElement("script");this.script.id=f+a;this.script.src=this.options.url+"/"+a+"?"+b;this.script.type="text/javascript";this.script.charset="UTF-8";this.script.onerror=this.script.onload=e;if(this.script.async===void 0&&document.attachEvent&&
|
37
|
+
/opera/i.test(navigator.userAgent))f=this.options.receiver||"Pusher.JSONP.receive",this.errorScript=document.createElement("script"),this.errorScript.text=f+"("+a+", true);",this.script.async=this.errorScript.async=!1;var g=this;this.script.onreadystatechange=function(){g.script&&/loaded|complete/.test(g.script.readyState)&&e(!0)};a=document.getElementsByTagName("head")[0];a.insertBefore(this.script,a.firstChild);this.errorScript&&a.insertBefore(this.errorScript,this.script.nextSibling);return!0};
|
38
|
+
a.cleanup=function(){if(this.script&&this.script.parentNode)this.script.parentNode.removeChild(this.script),this.script=null;if(this.errorScript&&this.errorScript.parentNode)this.errorScript.parentNode.removeChild(this.errorScript),this.errorScript=null};Pusher.JSONPRequest=b}).call(this);
|
39
|
+
(function(){function b(){this.lastId=0;this.callbacks={}}var c=b.prototype;c.register=function(a){this.lastId++;var b=this.lastId;this.callbacks[b]=a;return b};c.unregister=function(a){if(this.callbacks[a]){var b=this.callbacks[a];delete this.callbacks[a];return b}else return null};c.receive=function(a,b,c){(a=this.unregister(a))&&a(b,c)};Pusher.JSONPReceiver=b;Pusher.JSONP=new b}).call(this);
|
40
|
+
(function(){function b(a,b,c){this.key=a;this.session=b;this.events=[];this.options=c||{};this.uniqueID=this.sent=0}var c=b.prototype;b.ERROR=3;b.INFO=6;b.DEBUG=7;c.log=function(a,b){if(this.options.level===void 0||a<=this.options.level)this.events.push(Pusher.Util.extend({},b,{timestamp:Pusher.Util.now(),level:a})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift()};c.error=function(a){this.log(b.ERROR,a)};c.info=function(a){this.log(b.INFO,a)};c.debug=function(a){this.log(b.DEBUG,
|
41
|
+
a)};c.isEmpty=function(){return this.events.length===0};c.send=function(a,b){var c=this,e={};this.sent===0&&(e=Pusher.Util.extend({key:this.key,features:this.options.features,version:this.options.version},this.options.params||{}));e.session=this.session;e.timeline=this.events;e=Pusher.Util.filterObject(e,function(a){return a!==void 0});this.events=[];a(e,function(a,e){a||c.sent++;b(a,e)});return!0};c.generateUniqueID=function(){this.uniqueID++;return this.uniqueID};Pusher.Timeline=b}).call(this);
|
42
|
+
(function(){function b(a,b){this.timeline=a;this.options=b||{}}var c=b.prototype;c.send=function(a){if(!this.timeline.isEmpty()){var b=this.options,c="http"+(this.isEncrypted()?"s":"")+"://";this.timeline.send(function(a,f){return Pusher.JSONPRequest.send({data:a,url:c+b.host+b.path,receiver:Pusher.JSONP},f)},a)}};c.isEncrypted=function(){return!!this.options.encrypted};Pusher.TimelineSender=b}).call(this);
|
43
|
+
(function(){function b(a){this.strategies=a}function c(a,b,c){var h=Pusher.Util.map(a,function(a,d,h,e){return a.connect(b,c(d,e))});return{abort:function(){Pusher.Util.apply(h,d)},forceMinPriority:function(a){Pusher.Util.apply(h,function(b){b.forceMinPriority(a)})}}}function a(a){return Pusher.Util.all(a,function(a){return Boolean(a.error)})}function d(a){if(!a.error&&!a.aborted)a.abort(),a.aborted=!0}var h=b.prototype;h.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))};
|
44
|
+
h.connect=function(b,d){return c(this.strategies,b,function(b,c){return function(h,e){(c[b].error=h)?a(c)&&d(!0):(Pusher.Util.apply(c,function(a){a.forceMinPriority(e.priority)}),d(null,e))}})};Pusher.BestConnectedEverStrategy=b}).call(this);
|
45
|
+
(function(){function b(a,b,c){this.strategy=a;this.transports=b;this.ttl=c.ttl||18E5;this.timeline=c.timeline}function c(){var a=Pusher.Util.getLocalStorage();return a&&a.pusherTransport?JSON.parse(a.pusherTransport):null}var a=b.prototype;a.isSupported=function(){return this.strategy.isSupported()};a.connect=function(a,b){var e=c(),f=[this.strategy];if(e&&e.timestamp+this.ttl>=Pusher.Util.now()){var g=this.transports[e.transport];g&&(this.timeline.info({cached:!0,transport:e.transport}),f.push(new Pusher.SequentialStrategy([g],
|
46
|
+
{timeout:e.latency*2,failFast:!0})))}var i=Pusher.Util.now(),j=f.pop().connect(a,function k(c,e){if(c){var g=Pusher.Util.getLocalStorage();g&&delete g.pusherTransport;f.length>0?(i=Pusher.Util.now(),j=f.pop().connect(a,k)):b(c)}else{var g=Pusher.Util.now()-i,o=e.name,n=Pusher.Util.getLocalStorage();if(n)n.pusherTransport=JSON.stringify({timestamp:Pusher.Util.now(),transport:o,latency:g});b(null,e)}});return{abort:function(){j.abort()},forceMinPriority:function(b){a=b;j&&j.forceMinPriority(b)}}};Pusher.CachedStrategy=
|
47
|
+
b}).call(this);(function(){function b(a,b){this.strategy=a;this.options={delay:b.delay}}var c=b.prototype;c.isSupported=function(){return this.strategy.isSupported()};c.connect=function(a,b){var c=this.strategy,e,f=new Pusher.Timer(this.options.delay,function(){e=c.connect(a,b)});return{abort:function(){f.ensureAborted();e&&e.abort()},forceMinPriority:function(b){a=b;e&&e.forceMinPriority(b)}}};Pusher.DelayedStrategy=b}).call(this);
|
48
|
+
(function(){function b(a){this.strategy=a}var c=b.prototype;c.isSupported=function(){return this.strategy.isSupported()};c.connect=function(a,b){var c=this.strategy.connect(a,function(a,f){f&&c.abort();b(a,f)});return c};Pusher.FirstConnectedStrategy=b}).call(this);
|
49
|
+
(function(){function b(a,b,c){this.test=a;this.trueBranch=b;this.falseBranch=c}var c=b.prototype;c.isSupported=function(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()};c.connect=function(a,b){return(this.test()?this.trueBranch:this.falseBranch).connect(a,b)};Pusher.IfStrategy=b}).call(this);
|
50
|
+
(function(){function b(a,b){this.strategies=a;this.loop=Boolean(b.loop);this.failFast=Boolean(b.failFast);this.timeout=b.timeout;this.timeoutLimit=b.timeoutLimit}var c=b.prototype;c.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))};c.connect=function(a,b){var c=this,e=this.strategies,f=0,g=this.timeout,i=null,j=function(l,k){k?b(null,k):(f+=1,c.loop&&(f%=e.length),f<e.length?(g&&(g*=2,c.timeoutLimit&&(g=Math.min(g,c.timeoutLimit))),i=c.tryStrategy(e[f],
|
51
|
+
a,{timeout:g,failFast:c.failFast},j)):b(!0))},i=this.tryStrategy(e[f],a,{timeout:g,failFast:this.failFast},j);return{abort:function(){i.abort()},forceMinPriority:function(b){a=b;i&&i.forceMinPriority(b)}}};c.tryStrategy=function(a,b,c,e){var f=null,g=null,g=a.connect(b,function(a,b){if(!a||!f||!f.isRunning()||c.failFast)f&&f.ensureAborted(),e(a,b)});c.timeout>0&&(f=new Pusher.Timer(c.timeout,function(){g.abort();e(!0)}));return{abort:function(){f&&f.ensureAborted();g.abort()},forceMinPriority:function(a){g.forceMinPriority(a)}}};
|
52
|
+
Pusher.SequentialStrategy=b}).call(this);
|
53
|
+
(function(){function b(a,b,c,f){this.name=a;this.priority=b;this.transport=c;this.options=f||{}}function c(a,b){new Pusher.Timer(0,function(){b(a)});return{abort:function(){},forceMinPriority:function(){}}}var a=b.prototype;a.isSupported=function(){return this.transport.isSupported({disableFlash:!!this.options.disableFlash})};a.connect=function(a,b){if(this.transport.isSupported()){if(this.priority<a)return c(new Pusher.Errors.TransportPriorityTooLow,b)}else return c(new Pusher.Errors.UnsupportedStrategy,b);
|
54
|
+
var e=this,f=this.transport.createConnection(this.name,this.priority,this.options.key,this.options),g=function(){f.unbind("initialized",g);f.connect()},i=function(){k();b(null,f)},j=function(a){k();b(a)},l=function(){k();b(new Pusher.Errors.TransportClosed(this.transport))},k=function(){f.unbind("initialized",g);f.unbind("open",i);f.unbind("error",j);f.unbind("closed",l)};f.bind("initialized",g);f.bind("open",i);f.bind("error",j);f.bind("closed",l);f.initialize();return{abort:function(){f.state!==
|
55
|
+
"open"&&(k(),f.close())},forceMinPriority:function(a){f.state!=="open"&&e.priority<a&&f.close()}}};Pusher.TransportStrategy=b}).call(this);
|
56
|
+
(function(){function b(a,b,c,f){Pusher.EventsDispatcher.call(this);this.name=a;this.priority=b;this.key=c;this.state="new";this.timeline=f.timeline;this.id=this.timeline.generateUniqueID();this.options={encrypted:Boolean(f.encrypted),hostUnencrypted:f.hostUnencrypted,hostEncrypted:f.hostEncrypted}}function c(a){return typeof a==="string"?a:typeof a==="object"?Pusher.Util.mapObject(a,function(a){var b=typeof a;return b==="object"||b=="function"?b:a}):typeof a}var a=b.prototype;Pusher.Util.extend(a,
|
57
|
+
Pusher.EventsDispatcher.prototype);b.isSupported=function(){return!1};a.supportsPing=function(){return!1};a.initialize=function(){this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.encrypted?"s":"")}));this.timeline.debug(this.buildTimelineMessage({method:"initialize"}));this.changeState("initialized")};a.connect=function(){var a=this.getURL(this.key,this.options);this.timeline.debug(this.buildTimelineMessage({method:"connect",url:a}));if(this.socket||this.state!=="initialized")return!1;
|
58
|
+
this.socket=this.createSocket(a);this.bindListeners();Pusher.debug("Connecting",{transport:this.name,url:a});this.changeState("connecting");return!0};a.close=function(){this.timeline.debug(this.buildTimelineMessage({method:"close"}));return this.socket?(this.socket.close(),!0):!1};a.send=function(a){this.timeline.debug(this.buildTimelineMessage({method:"send",data:a}));if(this.state==="open"){var b=this;setTimeout(function(){b.socket.send(a)},0);return!0}else return!1};a.requestPing=function(){this.emit("ping_request")};
|
59
|
+
a.onOpen=function(){this.changeState("open");this.socket.onopen=void 0};a.onError=function(a){this.emit("error",{type:"WebSocketError",error:a});this.timeline.error(this.buildTimelineMessage({error:c(a)}))};a.onClose=function(a){this.changeState("closed",a);this.socket=void 0};a.onMessage=function(a){this.timeline.debug(this.buildTimelineMessage({message:a.data}));this.emit("message",a)};a.bindListeners=function(){var a=this;this.socket.onopen=function(){a.onOpen()};this.socket.onerror=function(b){a.onError(b)};
|
60
|
+
this.socket.onclose=function(b){a.onClose(b)};this.socket.onmessage=function(b){a.onMessage(b)}};a.createSocket=function(){return null};a.getScheme=function(){return this.options.encrypted?"wss":"ws"};a.getBaseURL=function(){var a;a=this.options.encrypted?this.options.hostEncrypted:this.options.hostUnencrypted;return this.getScheme()+"://"+a};a.getPath=function(){return"/app/"+this.key};a.getQueryString=function(){return"?protocol="+Pusher.PROTOCOL+"&client=js&version="+Pusher.VERSION};a.getURL=function(){return this.getBaseURL()+
|
61
|
+
this.getPath()+this.getQueryString()};a.changeState=function(a,b){this.state=a;this.timeline.info(this.buildTimelineMessage({state:a,params:b}));this.emit(a,b)};a.buildTimelineMessage=function(a){return Pusher.Util.extend({cid:this.id},a)};Pusher.AbstractTransport=b}).call(this);
|
62
|
+
(function(){function b(a,b,c,e){Pusher.AbstractTransport.call(this,a,b,c,e)}var c=b.prototype;Pusher.Util.extend(c,Pusher.AbstractTransport.prototype);b.createConnection=function(a,c,h,e){return new b(a,c,h,e)};b.isSupported=function(a){if(a&&a.disableFlash)return!1;try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(b){return navigator.mimeTypes["application/x-shockwave-flash"]!==void 0}};c.initialize=function(){var a=this;this.timeline.info(this.buildTimelineMessage({transport:this.name+
|
63
|
+
(this.options.encrypted?"s":"")}));this.timeline.debug(this.buildTimelineMessage({method:"initialize"}));this.changeState("initializing");if(window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR===void 0)window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR=!0;window.WEB_SOCKET_SWF_LOCATION=Pusher.Dependencies.getRoot()+"/WebSocketMain.swf";Pusher.Dependencies.load("flashfallback",function(){a.changeState("initialized")})};c.createSocket=function(a){return new FlashWebSocket(a)};c.getQueryString=function(){return Pusher.AbstractTransport.prototype.getQueryString.call(this)+
|
64
|
+
"&flash=true"};Pusher.FlashTransport=b}).call(this);
|
65
|
+
(function(){function b(a,b,c,e){Pusher.AbstractTransport.call(this,a,b,c,e)}var c=b.prototype;Pusher.Util.extend(c,Pusher.AbstractTransport.prototype);b.createConnection=function(a,c,h,e){return new b(a,c,h,e)};b.isSupported=function(){return!0};c.initialize=function(){var a=this;this.timeline.info(this.buildTimelineMessage({transport:this.name+(this.options.encrypted?"s":"")}));this.timeline.debug(this.buildTimelineMessage({method:"initialize"}));this.changeState("initializing");Pusher.Dependencies.load("sockjs",
|
66
|
+
function(){a.changeState("initialized")})};c.supportsPing=function(){return!0};c.createSocket=function(a){return new SockJS(a,null,{js_path:Pusher.Dependencies.getPath("sockjs",{encrypted:this.options.encrypted})})};c.getScheme=function(){return this.options.encrypted?"https":"http"};c.getPath=function(){return"/pusher"};c.getQueryString=function(){return""};c.onOpen=function(){this.socket.send(JSON.stringify({path:Pusher.AbstractTransport.prototype.getPath.call(this)+Pusher.AbstractTransport.prototype.getQueryString.call(this)}));
|
67
|
+
this.changeState("open");this.socket.onopen=void 0};Pusher.SockJSTransport=b}).call(this);
|
68
|
+
(function(){function b(a,b,c,e){Pusher.AbstractTransport.call(this,a,b,c,e)}var c=b.prototype;Pusher.Util.extend(c,Pusher.AbstractTransport.prototype);b.createConnection=function(a,c,h,e){return new b(a,c,h,e)};b.isSupported=function(){return window.WebSocket!==void 0||window.MozWebSocket!==void 0};c.createSocket=function(a){return new (window.WebSocket||window.MozWebSocket)(a)};c.getQueryString=function(){return Pusher.AbstractTransport.prototype.getQueryString.call(this)+"&flash=false"};Pusher.WSTransport=
|
69
|
+
b}).call(this);
|
70
|
+
(function(){function b(a,b,c){this.manager=a;this.transport=b;this.minPingDelay=c.minPingDelay||1E4;this.maxPingDelay=c.maxPingDelay||Pusher.activity_timeout;this.pingDelay=null}var c=b.prototype;c.createConnection=function(a,b,c,e){var f=this.transport.createConnection(a,b,c,e),g=this,i=null,j=null,l=function(){f.unbind("open",l);i=Pusher.Util.now();g.pingDelay&&(j=setInterval(function(){j&&f.requestPing()},g.pingDelay));f.bind("closed",k)},k=function(a){f.unbind("closed",k);j&&(clearInterval(j),j=
|
71
|
+
null);if(!a.wasClean&&i&&(a=Pusher.Util.now()-i,a<2*g.maxPingDelay))g.manager.reportDeath(),g.pingDelay=Math.max(a/2,g.minPingDelay)};f.bind("open",l);return f};c.isSupported=function(){return this.manager.isAlive()&&this.transport.isSupported()};Pusher.AssistantToTheTransportManager=b}).call(this);
|
72
|
+
(function(){function b(a){this.options=a||{};this.livesLeft=this.options.lives||Infinity}var c=b.prototype;c.getAssistant=function(a){return new Pusher.AssistantToTheTransportManager(this,a,{minPingDelay:this.options.minPingDelay,maxPingDelay:this.options.maxPingDelay})};c.isAlive=function(){return this.livesLeft>0};c.reportDeath=function(){this.livesLeft-=1};Pusher.TransportManager=b}).call(this);
|
73
|
+
(function(){function b(a){return function(b){return[a.apply(this,arguments),b]}}function c(a,b){if(a.length===0)return[[],b];var e=d(a[0],b),h=c(a.slice(1),e[1]);return[[e[0]].concat(h[0]),h[1]]}function a(a,b){if(typeof a[0]==="string"&&a[0].charAt(0)===":"){var e=b[a[0].slice(1)];if(a.length>1){if(typeof e!=="function")throw"Calling non-function "+a[0];var h=[Pusher.Util.extend({},b)].concat(Pusher.Util.map(a.slice(1),function(a){return d(a,Pusher.Util.extend({},b))[0]}));return e.apply(this,h)}else return[e,
|
74
|
+
b]}else return c(a,b)}function d(b,c){if(typeof b==="string"){var d;if(typeof b==="string"&&b.charAt(0)===":"){d=c[b.slice(1)];if(d===void 0)throw"Undefined symbol "+b;d=[d,c]}else d=[b,c];return d}else if(typeof b==="object"&&b instanceof Array&&b.length>0)return a(b,c);return[b,c]}var h={ws:Pusher.WSTransport,flash:Pusher.FlashTransport,sockjs:Pusher.SockJSTransport},e={def:function(a,b,c){if(a[b]!==void 0)throw"Redefining symbol "+b;a[b]=c;return[void 0,a]},def_transport:function(a,b,c,d,e,k){var m=
|
75
|
+
h[c];if(!m)throw new Pusher.Errors.UnsupportedTransport(c);c=Pusher.Util.extend({},{key:a.key,encrypted:a.encrypted,timeline:a.timeline,disableFlash:a.disableFlash},e);k&&(m=k.getAssistant(m));d=new Pusher.TransportStrategy(b,d,m,c);k=a.def(a,b,d)[1];k.transports=a.transports||{};k.transports[b]=d;return[void 0,k]},transport_manager:b(function(a,b){return new Pusher.TransportManager(b)}),sequential:b(function(a,b){var c=Array.prototype.slice.call(arguments,2);return new Pusher.SequentialStrategy(c,
|
76
|
+
b)}),cached:b(function(a,b,c){return new Pusher.CachedStrategy(c,a.transports,{ttl:b,timeline:a.timeline})}),first_connected:b(function(a,b){return new Pusher.FirstConnectedStrategy(b)}),best_connected_ever:b(function(){var a=Array.prototype.slice.call(arguments,1);return new Pusher.BestConnectedEverStrategy(a)}),delayed:b(function(a,b,c){return new Pusher.DelayedStrategy(c,{delay:b})}),"if":b(function(a,b,c,d){return new Pusher.IfStrategy(b,c,d)}),is_supported:b(function(a,b){return function(){return b.isSupported()}})};
|
77
|
+
Pusher.StrategyBuilder={build:function(a,b){var c=Pusher.Util.extend({},e,b);return d(a,c)[1].strategy}}}).call(this);
|
78
|
+
(function(){function b(a){Pusher.EventsDispatcher.call(this);this.transport=a;this.bindListeners()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.supportsPing=function(){return this.transport.supportsPing()};c.send=function(a){return this.transport.send(a)};c.send_event=function(a,b,c){a={event:a,data:b};if(c)a.channel=c;Pusher.debug("Event sent",a);return this.send(JSON.stringify(a))};c.close=function(){this.transport.close()};c.bindListeners=function(){var a=this,b=
|
79
|
+
function(f){f=a.parseMessage(f);if(f!==void 0)f.event==="pusher:connection_established"?(a.id=f.data.socket_id,a.transport.unbind("message",b),a.transport.bind("message",c),a.transport.bind("ping_request",e),a.emit("connected",a.id)):f.event==="pusher:error"&&(a.handleCloseCode(f.data.code,f.data.message),a.transport.close())},c=function(b){b=a.parseMessage(b);if(b!==void 0){Pusher.debug("Event recd",b);switch(b.event){case "pusher:error":a.emit("error",{type:"PusherError",data:b.data});break;case "pusher:ping":a.emit("ping");
|
80
|
+
break;case "pusher:pong":a.emit("pong")}a.emit("message",b)}},e=function(){a.emit("ping_request")},f=function(b){a.emit("error",{type:"WebSocketError",error:b})},g=function(i){i&&i.code&&a.handleCloseCode(i.code,i.reason);a.transport.unbind("message",b);a.transport.unbind("message",c);a.transport.unbind("ping_request",e);a.transport.unbind("error",f);a.transport.unbind("closed",g);a.transport=null;a.emit("closed")};this.transport.bind("message",b);this.transport.bind("error",f);this.transport.bind("closed",
|
81
|
+
g)};c.parseMessage=function(a){try{var b=JSON.parse(a.data);if(typeof b.data==="string")try{b.data=JSON.parse(b.data)}catch(c){if(!(c instanceof SyntaxError))throw c;}return b}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:a.data})}};c.handleCloseCode=function(a,b){this.emit("error",{type:"PusherError",data:{code:a,message:b}});a<4E3?a>=1002&&a<=1004&&this.emit("backoff"):a===4E3?this.emit("ssl_only"):a<4100?this.emit("refused"):a<4200?this.emit("backoff"):a<4300?this.emit("retry"):
|
82
|
+
this.emit("refused")};Pusher.ProtocolWrapper=b}).call(this);
|
83
|
+
(function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.key=a;this.options=b||{};this.state="initialized";this.connection=null;this.encrypted=!!b.encrypted;this.timeline=this.options.getTimeline();var c=this;Pusher.Network.bind("online",function(){c.state==="unavailable"&&c.connect()});Pusher.Network.bind("offline",function(){c.shouldRetry()&&(c.disconnect(),c.updateState("unavailable"))});var e=function(){c.timelineSender&&c.timelineSender.send(function(){})};this.bind("connected",e);
|
84
|
+
setInterval(e,6E4)}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.connect=function(){if(!this.connection&&this.state!=="connecting"){var a=this.options.getStrategy({key:this.key,timeline:this.timeline,encrypted:this.encrypted});if(a.isSupported())if(Pusher.Network.isOnline()===!1)this.updateState("unavailable");else{this.updateState("connecting");this.timelineSender=this.options.getTimelineSender(this.timeline,{encrypted:this.encrypted},this);var b=this,c=function(e,f){e?
|
85
|
+
b.runner=a.connect(0,c):(b.runner.abort(),b.setConnection(b.wrapTransport(f)))};this.runner=a.connect(0,c);this.setUnavailableTimer()}else this.updateState("failed")}};c.send=function(a){return this.connection?this.connection.send(a):!1};c.send_event=function(a,b,c){return this.connection?this.connection.send_event(a,b,c):!1};c.disconnect=function(){this.runner&&this.runner.abort();this.clearRetryTimer();this.clearUnavailableTimer();this.stopActivityCheck();this.updateState("disconnected");if(this.connection)this.connection.close(),
|
86
|
+
this.connection=null};c.retryIn=function(a){var b=this;this.retryTimer=setTimeout(function(){if(b.retryTimer!==null)b.retryTimer=null,b.disconnect(),b.connect()},a||0)};c.clearRetryTimer=function(){if(this.retryTimer)clearTimeout(this.retryTimer),this.retryTimer=null};c.setUnavailableTimer=function(){var a=this;this.unavailableTimer=setTimeout(function(){if(a.unavailableTimer)a.updateState("unavailable"),a.unavailableTimer=null},this.options.unavailableTimeout)};c.clearUnavailableTimer=function(){if(this.unavailableTimer)clearTimeout(this.unavailableTimer),
|
87
|
+
this.unavailableTimer=null};c.resetActivityCheck=function(){this.stopActivityCheck();if(!this.connection.supportsPing()){var a=this;this.activityTimer=setTimeout(function(){a.send_event("pusher:ping",{});a.activityTimer=setTimeout(function(){a.connection.close()},a.options.pongTimeout)},this.options.activityTimeout)}};c.stopActivityCheck=function(){if(this.activityTimer)clearTimeout(this.activityTimer),this.activityTimer=null};c.setConnection=function(a){this.connection=a;var b=this,c=function(a){b.clearUnavailableTimer();
|
88
|
+
b.socket_id=a;b.updateState("connected");b.resetActivityCheck()},e=function(a){b.resetActivityCheck();b.emit("message",a)},f=function(){b.send_event("pusher:pong",{})},g=function(){b.send_event("pusher:ping",{})},i=function(a){b.emit("error",{type:"WebSocketError",error:a})},j=function(){a.unbind("connected",c);a.unbind("message",e);a.unbind("ping",f);a.unbind("ping_request",g);a.unbind("error",i);a.unbind("closed",j);b.connection=null;b.shouldRetry()&&b.retryIn(1E3)};a.bind("connected",c);a.bind("message",
|
89
|
+
e);a.bind("ping",f);a.bind("ping_request",g);a.bind("error",i);a.bind("closed",j);a.bind("ssl_only",function(){b.encrypted=!0;b.retryIn(0)});a.bind("refused",function(){b.disconnect()});a.bind("backoff",function(){b.retryIn(1E3)});a.bind("retry",function(){b.retryIn(0)});this.resetActivityCheck()};c.updateState=function(a,b){var c=this.state;this.state=a;c!==a&&(Pusher.debug("State changed",c+" -> "+a),this.emit("state_change",{previous:c,current:a}),this.emit(a,b))};c.shouldRetry=function(){return this.state===
|
90
|
+
"connecting"||this.state==="connected"};c.wrapTransport=function(a){return new Pusher.ProtocolWrapper(a)};Pusher.ConnectionManager=b}).call(this);
|
91
|
+
(function(){function b(){Pusher.EventsDispatcher.call(this);var b=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){b.emit("online")},!1),window.addEventListener("offline",function(){b.emit("offline")},!1))}Pusher.Util.extend(b.prototype,Pusher.EventsDispatcher.prototype);b.prototype.isOnline=function(){return window.navigator.onLine===void 0?!0:window.navigator.onLine};Pusher.NetInfo=b;Pusher.Network=new b}).call(this);
|
92
|
+
(function(){Pusher.Channels=function(){this.channels={}};Pusher.Channels.prototype={add:function(b,a){var d=this.find(b);d||(d=Pusher.Channel.factory(b,a),this.channels[b]=d);return d},find:function(b){return this.channels[b]},remove:function(b){delete this.channels[b]},disconnect:function(){for(var b in this.channels)this.channels[b].disconnect()}};Pusher.Channel=function(b,a){var d=this;Pusher.EventsDispatcher.call(this,function(a){Pusher.debug("No callbacks on "+b+" for "+a)});this.pusher=a;this.name=
|
93
|
+
b;this.subscribed=!1;this.bind("pusher_internal:subscription_succeeded",function(a){d.onSubscriptionSucceeded(a)})};Pusher.Channel.prototype={init:function(){},disconnect:function(){this.subscribed=!1;this.emit("pusher_internal:disconnected")},onSubscriptionSucceeded:function(){this.subscribed=!0;this.emit("pusher:subscription_succeeded")},authorize:function(b,a,d){return d(!1,{})},trigger:function(b,a){return this.pusher.send_event(b,a,this.name)}};Pusher.Util.extend(Pusher.Channel.prototype,Pusher.EventsDispatcher.prototype);
|
94
|
+
Pusher.Channel.PrivateChannel={authorize:function(b,a,d){var h=this;return(new Pusher.Channel.Authorizer(this,Pusher.channel_auth_transport,a)).authorize(b,function(a,b){a||h.emit("pusher_internal:authorized",b);d(a,b)})}};Pusher.Channel.PresenceChannel={init:function(){this.members=new b(this)},onSubscriptionSucceeded:function(){this.subscribed=!0}};var b=function(b){var a=this,d=null,h=function(){a._members_map={};a.count=0;d=a.me=null};h();var e=function(f){a._members_map=f.presence.hash;a.count=
|
95
|
+
f.presence.count;a.me=a.get(d.user_id);b.emit("pusher:subscription_succeeded",a)};b.bind("pusher_internal:authorized",function(a){d=JSON.parse(a.channel_data);b.bind("pusher_internal:subscription_succeeded",e)});b.bind("pusher_internal:member_added",function(d){a.get(d.user_id)===null&&a.count++;a._members_map[d.user_id]=d.user_info;b.emit("pusher:member_added",a.get(d.user_id))});b.bind("pusher_internal:member_removed",function(d){var e=a.get(d.user_id);e&&(delete a._members_map[d.user_id],a.count--,
|
96
|
+
b.emit("pusher:member_removed",e))});b.bind("pusher_internal:disconnected",function(){h();b.unbind("pusher_internal:subscription_succeeded",e)})};b.prototype={each:function(b){for(var a in this._members_map)b(this.get(a))},get:function(b){return this._members_map.hasOwnProperty(b)?{id:b,info:this._members_map[b]}:null}};Pusher.Channel.factory=function(b,a){var d=new Pusher.Channel(b,a);b.indexOf("private-")===0?Pusher.Util.extend(d,Pusher.Channel.PrivateChannel):b.indexOf("presence-")===0&&(Pusher.Util.extend(d,
|
97
|
+
Pusher.Channel.PrivateChannel),Pusher.Util.extend(d,Pusher.Channel.PresenceChannel));d.init();return d}}).call(this);
|
98
|
+
(function(){Pusher.Channel.Authorizer=function(b,c,a){this.channel=b;this.type=c;this.authOptions=(a||{}).auth||{}};Pusher.Channel.Authorizer.prototype={composeQuery:function(b){var b="&socket_id="+encodeURIComponent(b)+"&channel_name="+encodeURIComponent(this.channel.name),c;for(c in this.authOptions.params)b+="&"+encodeURIComponent(c)+"="+encodeURIComponent(this.authOptions.params[c]);return b},authorize:function(b,c){return Pusher.authorizers[this.type].call(this,b,c)}};Pusher.auth_callbacks={};
|
99
|
+
Pusher.authorizers={ajax:function(b,c){var a;a=Pusher.XHR?new Pusher.XHR:window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");a.open("POST",Pusher.channel_auth_endpoint,!0);a.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var d in this.authOptions.headers)a.setRequestHeader(d,this.authOptions.headers[d]);a.onreadystatechange=function(){if(a.readyState==4)if(a.status==200){var b,d=!1;try{b=JSON.parse(a.responseText),d=!0}catch(f){c(!0,"JSON returned from webapp was invalid, yet status code was 200. Data was: "+
|
100
|
+
a.responseText)}d&&c(!1,b)}else Pusher.warn("Couldn't get auth info from your webapp",a.status),c(!0,a.status)};a.send(this.composeQuery(b));return a},jsonp:function(b,c){this.authOptions.headers!==void 0&&Pusher.warn("Warn","To send headers with the auth request, you must use AJAX, rather than JSONP.");var a=document.createElement("script");Pusher.auth_callbacks[this.channel.name]=function(a){c(!1,a)};a.src=Pusher.channel_auth_endpoint+"?callback="+encodeURIComponent("Pusher.auth_callbacks['"+this.channel.name+
|
101
|
+
"']")+this.composeQuery(b);var d=document.getElementsByTagName("head")[0]||document.documentElement;d.insertBefore(a,d.firstChild)}}}).call(this);
|
@@ -0,0 +1,35 @@
|
|
1
|
+
/* Classes
|
2
|
+
-------------------------------------------------------- */
|
3
|
+
|
4
|
+
if(!window.classes) window.classes = {};
|
5
|
+
|
6
|
+
/* Objects
|
7
|
+
-------------------------------------------------------- */
|
8
|
+
|
9
|
+
if(!window.app) window.app = {}
|
10
|
+
|
11
|
+
/* Events
|
12
|
+
-------------------------------------------------------- */
|
13
|
+
|
14
|
+
if(!window.app.events) window.app.events = {};
|
15
|
+
|
16
|
+
_.extend(app.events, {
|
17
|
+
|
18
|
+
FLASH_ERROR : "flash:error",
|
19
|
+
FLASH_WARNING : "flash:warning",
|
20
|
+
FLASH_NOTICE : "flash:notice",
|
21
|
+
FLASH_CLOSE : "flash:close",
|
22
|
+
|
23
|
+
SEARCH_CHANGED : "search:changed",
|
24
|
+
|
25
|
+
SELECT : "select",
|
26
|
+
EDITOR_RESIZE : "editor:resize"
|
27
|
+
|
28
|
+
});
|
29
|
+
|
30
|
+
app.mailman = _.extend({}, Backbone.Events);
|
31
|
+
|
32
|
+
/* CORS
|
33
|
+
-------------------------------------------------------- */
|
34
|
+
|
35
|
+
jQuery.support.cors = true;
|