facebooker 1.0.68 → 1.0.69

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,332 +1,93 @@
1
- function $(element) {
2
- if (typeof element == "string") {
3
- element=document.getElementById(element);
4
- }
5
- if (element)
6
- extendInstance(element,Element);
7
- return element;
8
- }
9
-
10
- function getElementsByName(elementName) {
11
- var matcher = function(element) {
12
- return (element.getName() === elementName);
13
- };
14
- return domCollect(document.getRootElement(), matcher);
15
- }
16
- function getElementsByClass(classname) {
17
- var matcher = function(element) {
18
- return (element.getClassName() === classname);
19
- };
20
- return domCollect(document.getRootElement(), matcher);
21
- }
22
- //function getElementsByTagName(tagName) -> native to FJBS
23
-
24
- extendInstance(Ajax, { //Extends the native Facebook Ajax object
25
- /*
26
- * Make a request to a remote server. Call the 'success' callback with the result.
27
- * Ex: Ajax.Load('JSON','http://...',{ success: function(result){console.log(result.toSource())} }, {'json':test_content})
28
- */
29
- Load: function(response_type, action_path, callbacks, post_parameters) {
30
- callbacks = Ajax.checkCallbacks(callbacks);
31
- var ajax = new Ajax();
32
- switch(response_type) {
33
- case 'FBML':
34
- ajax.responseType = Ajax.FBML;
35
- break;
36
- case 'JSON':
37
- ajax.responseType = Ajax.JSON;
38
- break;
39
- case 'RAW':
40
- ajax.responseType = Ajax.RAW;
41
- break;
42
- default:
43
- console.error("Unknow respons format requested. You supplied %s. Supported: 'FBML', 'RAW'", response_type);
44
- return;
45
- }
46
- ajax.ondone = function(result){
47
- callbacks.success(result);
48
- callbacks.complete();
49
- }
50
- ajax.onerror = function(error_string) {
51
- callbacks.failure(error_string);
52
- callbacks.complete();
53
- }
54
-
55
- post_parameters = post_parameters || {}
56
- post_parameters['authenticity_token'] = _token;
57
-
58
- if(action_path.indexOf('http') == -1) {
59
- action_path = _hostname + action_path;
60
- }
61
-
62
- callbacks.begin();
63
- ajax.post(action_path,post_parameters);
64
- },
65
- /*
66
- * Make a request to a remote server. Update target_element with result. Calls the 'success' callback with the result
67
- * Ex: Ajax.Update('test1', 'FBML', 'http://...',{ success: function(result){console.log(result)} })
68
- */
69
- Update: function(target_element, response_type, action_path, callbacks, post_parameters) {
70
- callbacks = Ajax.checkCallbacks(callbacks);
71
- var update_element = function(content) {
72
- switch(response_type) {
73
- case 'FBML':
74
- $(target_element).setInnerFBML(content);
75
- break;
76
- case 'RAW':
77
- $(target_element).setTextValue(content);
78
- break;
79
- default:
80
- console.log("Unsupported response type "+response_type);
81
- break;
82
- }
83
- };
84
1
 
85
- var onsuccess = (callbacks.success == null)?
86
- update_element :
87
- chainMethods([update_element,callbacks.success]);
88
-
89
- callbacks.success = onsuccess;
90
- Ajax.Load(response_type, action_path, callbacks, post_parameters);
91
- },
92
-
93
-
94
- InPlaceInputEditor: function(target_element, action_path, post_parameters) {
95
- var classname = $(target_element).getClassName() || "";
96
-
97
- this.edit = function() {
98
- var target = $(target_element);
99
- var wrapper = target.getParentNode();
100
- var dimensions = $(target_element).getDimensions();
101
- var value = $(target_element+'__value').getValue();
102
-
103
- var editArea = document.createElement('input');
104
- editArea.setType($(target_element+'__value').getType());
105
- editArea.setId(target_element+"__editor");
106
- editArea.setValue(value);
107
- //editArea.focus();
108
- //editArea.setStyle("width",dimensions.width+"px");
109
- //editArea.setStyle("height", dimensions.height+'px');
110
-
111
- $(target_element+'__value').remove();
112
- wrapper.removeChild(target);
113
- wrapper.appendChild(editArea);
114
- }
115
- this.save = function(callbacks){
116
- var newValue = $(target_element + "__editor").getValue();
117
- var wrapper = $(target_element + "__editor").getParentNode();
118
- callbacks = Ajax.checkCallbacks(callbacks);
119
- Ajax.Load("RAW", action_path + "?raw=" + escape(newValue), {
120
- success: chainMethods([
121
- callbacks.success,
122
- function(result){
123
- wrapper.setInnerXHTML('<span>'+
124
- '<input id="'+target_element+'__value" name="'+target_element+'__value" style="display:none;" type="text" value="'+unescape(result)+'" />'+
125
- '<span><span id="'+target_element+'" class="'+classname+'" type="text">'+unescape(result)+'</span></span></span>');
126
- }
127
- ])
128
- }, post_parameters)
129
- };
130
- },
131
- InPlaceTextAreaEditor: function(target_element, action_path, post_parameters) {
132
- var classname = $(target_element).getClassName() || "";
133
-
134
- this.edit = function() {
135
- var target = $(target_element);
136
- var wrapper = target.getParentNode();
137
- var dimensions = $(target_element).getDimensions();
138
- var value = $(target_element+'__value').getValue();
139
-
140
- var editArea = document.createElement('textarea');
141
- editArea.setId(target_element+"__editor");
142
- editArea.setValue(value.replace(/<br \/>|<br\/>/g,'\n').replace(/<p>|<\/p>/g,''));
143
- editArea.addEventListener('keyup', function() {
144
- autoExpandTextarea(editArea);
145
- });
146
- //editArea.focus();
147
- editArea.setStyle("width",dimensions.width+"px");
148
- //editArea.setStyle("height", dimensions.height+'px');
149
-
150
- $(target_element+'__value').remove();
151
- wrapper.removeChild(target);
152
- wrapper.appendChild(editArea);
153
- autoExpandTextarea(editArea);
154
- }
155
- this.save = function(callbacks){
156
- var newValue = $(target_element + "__editor").getValue();
157
- var wrapper = $(target_element + "__editor").getParentNode();
158
- callbacks = Ajax.checkCallbacks(callbacks);
159
- Ajax.Load("RAW", action_path + "?raw=" + escape(newValue), {
160
- success: chainMethods([
161
- callbacks.success,
162
- function(result){
163
- wrapper.setInnerXHTML('<span>'+
164
- '<textarea id="'+target_element+'__value" name="'+target_element+'__value" style="display:none;">'+unescape(result.replace(/<br \/>|<br\/>/g,'\n').replace(/<p>|<\/p>/g,''))+'</textarea>'+
165
- '<div><div id="'+target_element+'" class="'+classname+'" type="text">'+unescape(result)+'</div></div></span>');
166
- }
167
- ])
168
- }, post_parameters)
169
- };
170
- },
171
- /*
172
- * Pass the data inside of a form to a target url and place the result inside target_element.
173
- * Calls the 'success' callback with the result
174
- */
175
- UpdateRemoteForm: function(form_element, target_element, response_type, target_action, callbacks) {
176
- callbacks = callbacks || {};
177
- Ajax.Update(target_element, response_type, target_action, callbacks, $(form_element).serialize());
178
- },
179
- checkCallbacks:function(callbacks) {
180
- callbacks = callbacks || {};
181
- var donothing = function(){};
182
- return callbacks = {
183
- success: callbacks.success || donothing,
184
- failure: callbacks.failure || donothing,
185
- begin: callbacks.begin || donothing,
186
- complete: callbacks.complete || donothing
187
- };
188
- }
189
- });
190
-
191
- /*
192
- * Displays a confirmation dialog. If the user clicks "continue" then callback will be evaluated.
193
- * title and message can be strings or fb:js-string objects
194
- */
195
- function confirm(title,message,callback) {
196
- dialog = new Dialog(Dialog.DIALOG_POP);
197
-
198
- dialog.showChoice(
199
- title,
200
- message, // Content
201
- 'Continue',
202
- 'Cancel');
203
-
204
- dialog.onconfirm = function() {
205
- callback();
206
- };
207
- }
208
-
209
- function chainMethods(callbacks) {
210
- return function(par1,par2,par3,par4,par5,par6) {
211
- for (var i = 0, l = callbacks.length; i < l; i++) {
212
- callbacks[i](par1, par2, par3, par4, par5, par6);
213
- }
214
- }
2
+ function $(element) {
3
+ if (typeof element == "string") {
4
+ element=document.getElementById(element);
5
+ }
6
+ if (element)
7
+ extend_instance(element,Element);
8
+ return element;
215
9
  }
216
10
 
217
- function extendInstance(instance,hash) {
218
- for (var name in hash) {
219
- instance[name] = hash[name];
220
- }
11
+ function extend_instance(instance,hash) {
12
+ for (var name in hash) {
13
+ instance[name] = hash[name];
14
+ }
221
15
  }
222
16
 
223
17
  var Element = {
224
- visible: function() {
225
- return (this.getStyle('display') != 'none');
226
- },
227
- toggle: function() {
228
- if (this.visible()) {
229
- this.hide();
230
- } else {
231
- this.show();
232
- }
233
- },
234
- hide: function() {
235
- this.setStyle({
236
- display:'none'
237
- });
238
- return this;
239
- },
240
- show: function(element) {
241
- this.setStyle({
242
- display:''
243
- });
244
- return this;
245
- },
246
- remove: function() {
247
- this.getParentNode().removeChild(this);
248
- return null;
249
- },
250
- /*
251
- * Returns calculated element size
252
- */
253
- getDimensions: function() {
254
- var display = this.getStyle('display');
255
- if (display != 'none' && display != null) // Safari bug
256
- return {
257
- width: this.getOffsetWidth(),
258
- height: this.getOffsetHeight()
259
- };
260
-
261
- // All *Width and *Height properties give 0 on elements with display none,
262
- // so enable the element temporarily
263
- var originalVisibility = this.getStyle("visibility");
264
- var originalDisplay = this.getStyle("display");
265
- var originalPosition = this.getStyle("position");
266
- this.setStyle('visibility','none');
267
- this.setStyle('display','block');
268
- this.setStyle('position','absolute');
269
- var originalWidth = this.getClientWidth();
270
- var originalHeight = this.getClientHeight();
271
- this.setStyle('visibility',originalVisibility);
272
- this.setStyle('display',originalDisplay);
273
- this.setStyle('position',originalPosition);
274
-
275
- return {
276
- width: originalWidth,
277
- height: originalHeight
278
- };
18
+ "hide": function () {
19
+ this.setStyle("display","none")
20
+ },
21
+ "show": function () {
22
+ this.setStyle("display","block")
23
+ },
24
+ "visible": function () {
25
+ return (this.getStyle("display") != "none");
26
+ },
27
+ "toggle": function () {
28
+ if (this.visible) {
29
+ this.hide();
30
+ } else {
31
+ this.show();
279
32
  }
280
- }
33
+ }
34
+ };
281
35
 
282
36
  function encodeURIComponent(str) {
283
- if (typeof(str) == "string") {
284
- return str.replace(/=/g,'%3D').replace(/&/g,'%26');
37
+ if (typeof(str) == "string") {
38
+ return str.replace(/=/g,'%3D').replace(/&/g,'%26');
39
+ }
40
+ //checkboxes and radio buttons return objects instead of a string
41
+ else if(typeof(str) == "object"){
42
+ for (prop in str)
43
+ {
44
+ return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
285
45
  }
286
- //checkboxes and radio buttons return objects instead of a string
287
- else if(typeof(str) == "object"){
288
- for (prop in str)
289
- {
290
- return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
291
- }
292
- }
293
- return "";
294
- }
295
-
296
- /*
297
- * Applies block to all elements of an array. Return the array itself.
298
- */
299
- function map(array, block){
300
- results = [];
301
- for (var i=0,l=array.length;i<l;i++){
302
- results.push(block(array[i]));
46
+ }
47
+ };
48
+
49
+ var Form = {};
50
+ Form.serialize = function(form_element) {
51
+ return $(form_element).serialize();
52
+ };
53
+
54
+ Ajax.Updater = function (container,url,options) {
55
+ this.container = container;
56
+ this.url=url;
57
+ this.ajax = new Ajax();
58
+ this.ajax.requireLogin = 1;
59
+ if (options["onSuccess"]) {
60
+ this.ajax.responseType = Ajax.JSON;
61
+ this.ajax.ondone = options["onSuccess"];
62
+ } else {
63
+ this.ajax.responseType = Ajax.FBML;
64
+ this.ajax.ondone = function(data) {
65
+ $(container).setInnerFBML(data);
303
66
  }
304
- return results;
305
- }
306
-
307
- /*
308
- * Collects all elements within the 'element' tree that 'matcher' returns true for
309
- * For an example, see selectElementsByClass
310
- */
311
- function domCollect(element, matcher) {
312
- collection = [];
313
- var recurse = function(subelement){
314
- var nodes = subelement.getChildNodes();
315
- map(nodes, function(node){
316
- if (matcher(node)) {
317
- extendInstance(node,Element)
318
- collection.push(node);
319
- }
320
- if (node.getFirstChild()) {
321
- recurse(node);
322
- }
323
- });
324
- };
325
- recurse(element);
326
- return collection;
327
- }
67
+ }
68
+ if (options["onFailure"]) {
69
+ this.ajax.onerror = options["onFailure"];
70
+ }
71
+
72
+ if (!options['parameters']) {
73
+ options['parameters'] = {}
74
+ }
75
+
76
+ // simulate other verbs over post
77
+ if (options['method']) {
78
+ options['parameters']['_method'] = options['method'];
79
+ }
80
+
81
+ this.ajax.post(url,options['parameters']);
82
+ if (options["onLoading"]) {
83
+ options["onLoading"].call()
84
+ }
85
+ };
86
+ Ajax.Request = function(url,options) {
87
+ Ajax.Updater('unused',url,options);
88
+ };
328
89
 
329
90
  PeriodicalExecuter = function (callback, frequency) {
330
91
  setTimeout(callback, frequency *1000);
331
92
  setTimeout(function() { new PeriodicalExecuter(callback,frequency); }, frequency*1000);
332
- };
93
+ };
@@ -2,7 +2,7 @@ module Facebooker #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 68
5
+ TINY = 69
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.68
4
+ version: 1.0.69
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-23 00:00:00 -04:00
17
+ date: 2010-04-28 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency