PluginProbe
FeedWordPress / 2011.1018
FeedWordPress v2011.1018
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / feedwordpress-elements.js

feedwordpress-elements.js in FeedWordPress 2011.1018, at feedwordpress-elements.js

491 lines 15.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function($) {
2 var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, fwpList;
3
4 fwpList = {
5 settings: {
6 url: ajaxurl, type: 'POST',
7 response: 'ajax-response',
8
9 what: '',
10 alt: 'alternate', altOffset: 0,
11 addColor: null, delColor: null, dimAddColor: null, dimDelColor: null,
12
13 confirm: null,
14 addBefore: null, addAfter: null,
15 delBefore: null, delAfter: null,
16 dimBefore: null, dimAfter: null
17 },
18
19 nonce: function(e,s) {
20 var url = wpAjax.unserialize(e.attr('href'));
21 return s.nonce || url._ajax_nonce || $('#' + s.elementbox + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0;
22 },
23
24 parseClass: function(e,t) {
25 var c = [], cl;
26 try {
27 cl = $(e).attr('class') || '';
28 cl = cl.match(new RegExp(t+':[\\S]+'));
29 if ( cl ) { c = cl[0].split(':'); }
30 } catch(r) {}
31 return c;
32 },
33
34 pre: function(e,s,a) {
35 var bg, r;
36 s = $.extend( {}, this.fwpList.settings, {
37 element: null,
38 nonce: 0,
39 target: e.get(0)
40 }, s || {} );
41 if ( $.isFunction( s.confirm ) ) {
42 if ( 'add' != a ) {
43 bg = $('#' + s.element).css('backgroundColor');
44 $('#' + s.element).css('backgroundColor', '#FF9966');
45 }
46 r = s.confirm.call(this,e,s,a,bg);
47 if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); }
48 if ( !r ) { return false; }
49 }
50 return s;
51 },
52
53 ajaxAdd: function( e, s ) {
54 e = $(e);
55 s = s || {};
56 var list = this, cls = fwpList.parseClass(e,'add'), es, valid, formData;
57 s = fwpList.pre.call( list, e, s, 'add' );
58
59 s.element = cls[2] || e.attr( 'id' ) || s.element || null;
60 if ( cls[3] ) { s.addColor = '#' + cls[3]; }
61 else { s.addColor = s.addColor || '#FFFF33'; }
62
63 if ( !s ) { return false; }
64
65 if ( !e.is('[class^="add:' + list.id + ':"]') ) { return !fwpList.add.call( list, e, s ); }
66
67 if ( !s.element ) { return true; }
68
69 s.action = 'add-' + s.what;
70
71 s.nonce = fwpList.nonce(e,s);
72
73 es = $('#' + s.elementbox + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
74 valid = wpAjax.validateForm( '#' + s.element );
75 if ( !valid ) { return false; }
76
77 s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
78 formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
79 if ( formData ) { s.data += '&' + formData; }
80
81 if ( $.isFunction(s.addBefore) ) {
82 s = s.addBefore( s );
83 if ( !s ) { return true; }
84 }
85 if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; }
86
87 s.success = function(r) {
88 var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
89 if ( !res || res.errors ) { return false; }
90
91 if ( true === res ) { return true; }
92
93 jQuery.each( res.responses, function() {
94 // FIXME: Causes ownerDocument is undefined breakage in WP3.2
95 fwpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue
96 pos: this.position || 0,
97 id: this.id || 0,
98 oldId: this.oldId || null
99 } ) );
100 } );
101
102 if ( $.isFunction(s.addAfter) ) {
103 o = this.complete;
104 this.complete = function(x,st) {
105 var _s = $.extend( { xml: x, status: st, parsed: res }, s );
106 s.addAfter( r, _s );
107 if ( $.isFunction(o) ) { o(x,st); }
108 };
109 }
110 list.fwpList.recolor();
111 $(list).trigger( 'fwpListAddEnd', [ s, list.fwpList ] );
112 fwpList.clear.call(list,'#' + s.element);
113 };
114
115 $.ajax( s );
116 return false;
117 },
118
119 ajaxDel: function( e, s ) {
120 e = $(e); s = s || {};
121 var list = this, cls = fwpList.parseClass(e,'delete'), element;
122 s = fwpList.pre.call( list, e, s, 'delete' );
123
124 s.element = cls[2] || s.element || null;
125 if ( cls[3] ) { s.delColor = '#' + cls[3]; }
126 else { s.delColor = s.delColor || '#faa'; }
127
128 if ( !s || !s.element ) { return false; }
129
130 s.action = 'delete-' + s.what;
131
132 s.nonce = fwpList.nonce(e,s);
133
134 s.data = $.extend(
135 { action: s.action, id: s.element.split('-').pop(), _ajax_nonce: s.nonce },
136 wpAjax.unserialize( cls[4] || '' )
137 );
138
139 if ( $.isFunction(s.delBefore) ) {
140 s = s.delBefore( s, list );
141 if ( !s ) { return true; }
142 }
143 if ( !s.data._ajax_nonce ) { return true; }
144
145 element = $('#' + s.element);
146
147 if ( 'none' != s.delColor ) {
148 element.css( 'backgroundColor', s.delColor ).fadeOut( 350, function(){
149 list.fwpList.recolor();
150 $(list).trigger( 'fwpListDelEnd', [ s, list.fwpList ] );
151 });
152 } else {
153 list.fwpList.recolor();
154 $(list).trigger( 'fwpListDelEnd', [ s, list.fwpList ] );
155 }
156
157 s.success = function(r) {
158 var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
159 if ( !res || res.errors ) {
160 element.stop().stop().css( 'backgroundColor', '#faa' ).show().queue( function() { list.fwpList.recolor(); $(this).dequeue(); } );
161 return false;
162 }
163 if ( $.isFunction(s.delAfter) ) {
164 o = this.complete;
165 this.complete = function(x,st) {
166 element.queue( function() {
167 var _s = $.extend( { xml: x, status: st, parsed: res }, s );
168 s.delAfter( r, _s );
169 if ( $.isFunction(o) ) { o(x,st); }
170 } ).dequeue();
171 };
172 }
173 };
174 $.ajax( s );
175 return false;
176 },
177
178 ajaxDim: function( e, s ) {
179 if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
180 return false;
181 e = $(e); s = s || {};
182 var list = this, cls = fwpList.parseClass(e,'dim'), element, isClass, color, dimColor;
183 s = fwpList.pre.call( list, e, s, 'dim' );
184
185 s.element = cls[2] || s.element || null;
186 s.dimClass = cls[3] || s.dimClass || null;
187 if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; }
188 else { s.dimAddColor = s.dimAddColor || '#FFFF33'; }
189 if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; }
190 else { s.dimDelColor = s.dimDelColor || '#FF3333'; }
191
192 if ( !s || !s.element || !s.dimClass ) { return true; }
193
194 s.action = 'dim-' + s.what;
195
196 s.nonce = fwpList.nonce(e,s);
197
198 s.data = $.extend(
199 { action: s.action, id: s.element.split('-').pop(), dimClass: s.dimClass, _ajax_nonce : s.nonce },
200 wpAjax.unserialize( cls[6] || '' )
201 );
202
203 if ( $.isFunction(s.dimBefore) ) {
204 s = s.dimBefore( s );
205 if ( !s ) { return true; }
206 }
207
208 element = $('#' + s.element);
209 isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
210 color = fwpList.getColor( element );
211 element.toggleClass( s.dimClass )
212 dimColor = isClass ? s.dimAddColor : s.dimDelColor;
213 if ( 'none' != dimColor ) {
214 element
215 .animate( { backgroundColor: dimColor }, 'fast' )
216 .queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
217 .animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); $(list).trigger( 'fwpListDimEnd', [ s, list.fwpList ] ); } } );
218 } else {
219 $(list).trigger( 'fwpListDimEnd', [ s, list.fwpList ] );
220 }
221
222 if ( !s.data._ajax_nonce ) { return true; }
223
224 s.success = function(r) {
225 var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
226 if ( !res || res.errors ) {
227 element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.fwpList.recolor(); $(this).dequeue(); } );
228 return false;
229 }
230 if ( $.isFunction(s.dimAfter) ) {
231 o = this.complete;
232 this.complete = function(x,st) {
233 element.queue( function() {
234 var _s = $.extend( { xml: x, status: st, parsed: res }, s );
235 s.dimAfter( r, _s );
236 if ( $.isFunction(o) ) { o(x,st); }
237 } ).dequeue();
238 };
239 }
240 };
241
242 $.ajax( s );
243 return false;
244 },
245
246 // From jquery.color.js: jQuery Color Animation by John Resig
247 getColor: function( el ) {
248 if ( el.constructor == Object )
249 el = el.get(0);
250 var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" );
251 do {
252 color = jQuery.curCSS(elem, 'backgroundColor');
253 if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") )
254 break;
255 } while ( elem = elem.parentNode );
256 return color || '#ffffff';
257 },
258
259 add: function( e, s ) {
260 e = $(e);
261 var list = $(this),
262 old = false,
263 _s = { pos: 0, id: 0, oldId: null },
264 ba, ref, color;
265
266 if ( 'string' == typeof s ) {
267 s = { what: s };
268 }
269
270 s = $.extend(_s, this.fwpList.settings, s);
271 if ( !e.size() || !s.what ) { return false; }
272 if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); }
273 if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
274
275 if ( old && old.size() ) {
276 old.before(e);
277 old.remove();
278 } else if ( isNaN(s.pos) ) {
279 ba = 'after';
280 if ( '-' == s.pos.substr(0,1) ) {
281 s.pos = s.pos.substr(1);
282 ba = 'before';
283 }
284 ref = list.find( '#' + s.pos );
285 if ( 1 === ref.size() ) { ref[ba](e); }
286 else { list.append(e); }
287 } else if ( s.pos < 0 ) {
288 list.prepend(e);
289 } else {
290 list.append(e);
291 }
292
293 if ( s.alt ) {
294 if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); }
295 else { e.addClass( s.alt ); }
296 }
297
298 if ( 'none' != s.addColor ) {
299 color = fwpList.getColor( e );
300 e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
301 }
302
303 list.each( function() { this.fwpList.process( e ); } );
304 return e;
305 },
306
307 clear: function(e) {
308 var list = this, t, tag;
309 e = $(e);
310 if ( list.fwpList && e.parents( '#' + list.id ).size() ) { return; }
311 e.find(':input').each( function() {
312 if ( $(this).parents('.form-no-clear').size() )
313 return;
314 t = this.type.toLowerCase();
315 tag = this.tagName.toLowerCase();
316 if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; }
317 else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; }
318 else if ( 'select' == tag ) { this.selectedIndex = null; }
319 });
320 },
321
322 process: function(el) {
323 var list = this;
324
325 $('[class^="add:' + list.id + ':"]', el || null)
326 .filter('form').submit( function() { return list.fwpList.add(this); } ).end()
327 .not('form').click( function() { return list.fwpList.add(this); } );
328 $('[class^="delete:' + list.id + ':"]', el || null).click( function() { return list.fwpList.del(this); } );
329 $('[class^="dim:' + list.id + ':"]', el || null).click( function() { return list.fwpList.dim(this); } );
330 },
331
332 recolor: function() {
333 var list = this, items, eo;
334 if ( !list.fwpList.settings.alt ) { return; }
335 items = $('.list-item:visible', list);
336 if ( !items.size() ) { items = $(list).children(':visible'); }
337 eo = [':even',':odd'];
338 if ( list.fwpList.settings.altOffset % 2 ) { eo.reverse(); }
339 items.filter(eo[0]).addClass(list.fwpList.settings.alt).end().filter(eo[1]).removeClass(list.fwpList.settings.alt);
340 },
341
342 init: function() {
343 var lists = this;
344
345 lists.fwpList.process = function(a) {
346 lists.each( function() {
347 this.fwpList.process(a);
348 } );
349 };
350 lists.fwpList.recolor = function() {
351 lists.each( function() {
352 this.fwpList.recolor();
353 } );
354 };
355 }
356 };
357
358 $.fn.fwpList = function( settings ) {
359 this.each( function() {
360 var _this = this;
361 this.fwpList = { settings: $.extend( {}, fwpList.settings, { what: fwpList.parseClass(this,'list')[1] || '' }, settings ) };
362 $.each( fs, function(i,f) { _this.fwpList[i] = function( e, s ) { return fwpList[f].call( _this, e, s ); }; } );
363 } );
364 fwpList.init.call(this);
365 this.fwpList.process();
366 return this;
367 };
368
369 })(jQuery);
370
371 jQuery(document).ready( function($) {
372 // Category boxes
373 $('.feedwordpress-category-div').each( function () {
374 var this_id = $(this).attr('id');
375 var catAddBefore, catAddAfter;
376 var taxonomyParts, taxonomy, settingName;
377
378 taxonomyParts = this_id.split('-');
379 taxonomyParts.shift(); taxonomyParts.shift();
380 taxonomy = taxonomyParts.join('-');
381
382 settingName = taxonomy + '_tab';
383 if ( taxonomy == 'category' )
384 settingName = 'cats';
385
386 // No need to worry about tab stuff for our purposes
387
388 // Ajax Cat
389 var containerId = $(this).attr('id');
390 var checkboxId = $(this).find('.categorychecklist').attr('id');
391 var newCatId = $(this).find('.new'+taxonomy).attr('id');
392 var responseId = $(this).find('.'+taxonomy+'-ajax-response').attr('id');
393 var taxAdderId = $(this).find('.'+taxonomy+'-adder').attr('id');
394
395 $(this).find('.new'+taxonomy).one( 'focus', function () { $(this).val('').removeClass('form-input-tip'); } );
396 $(this).find('.add-categorychecklist-category-add').click( function() {
397 $(this).parent().children('.new'+taxonomy).focus();
398 } );
399
400 catAddBefore = function (s) {
401 if ( !$('#'+newCatId).val() )
402 return false;
403 s.data += '&' + $( ':checked', '#'+checkboxId ).serialize();
404 return s;
405 }
406 catAddAfter = function (r, s) {
407 // Clear out input box
408 $('.new' + taxonomy, '#'+this_id).val('');
409
410 // Clear out parent dropbox
411 var sup, drop = $('.new' + taxonomy + '-parent', '#'+this_id);
412 var keep = $('.new' + taxonomy, '#'+this_id);
413
414 if ( 'undefined' != s.parsed.responses[0] && (sup = s.parsed.responses[0].supplemental.newcat_parent) ) {
415 sup = sup.replace(/id=['"]new[^'"]*_parent['"]/g, 'id="' + keep.attr('id') + '-parent"');
416 drop.before(sup);
417 $('#'+keep.attr('id')+'-parent').addClass('new' + taxonomy + '-parent');
418 drop.remove();
419 }
420 };
421
422 $('#' + checkboxId).fwpList({
423 alt: '',
424 elementbox: taxAdderId,
425 response: responseId,
426 addBefore: catAddBefore,
427 addAfter: catAddAfter
428 });
429
430 $(this).find('.category-add-toggle').click( function () {
431 $('#' + taxAdderId).toggleClass('wp-hidden-children');
432 $('#' + newCatId).focus();
433 return false;
434 } ); /* $(this).find('.category-add-toggle').click() */
435
436 } ); /* $('.feedwordpress-category-div').each() */
437 } ); /* jQuery(document).ready() */
438
439 jQuery(document).ready(function($){
440 if ( $('.jaxtag').length ) {
441 tagBox.init();
442 }
443
444 $('.fwpfs').toggle(
445 function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
446 function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
447 );
448 $('.fwpfs').bind(
449 'change',
450 function () { this.form.submit(); }
451 );
452 $('#fwpfs-button').css( 'display', 'none' );
453
454 $('table.twofer td.active input[type="radio"], table.twofer td.inactive input[type="radio"]').each( function () {
455 $(this).click( function () {
456 var name = $(this).attr('name');
457 var table = $(this).closest('table');
458 table.find('td').removeClass('active').addClass('inactive');
459 table.find('td:has(input[name="'+name+'"]:checked)').removeClass('inactive').addClass('active');
460 } );
461
462 var name = $(this).attr('name');
463 var table = $(this).closest('table');
464 table.find('td').removeClass('active').addClass('inactive');
465 table.find('td:has(input[name="'+name+'"]:checked)').removeClass('inactive').addClass('active');
466 } );
467
468 $('#turn-on-multiple-sources').click ( function () {
469 $('#add-single-uri').hide();
470 $('#add-multiple-uri').show(600);
471 return false;
472 ;
473 } );
474 $('#turn-off-multiple-sources').click ( function () {
475 $('#add-multiple-uri').hide(600);
476 $('#add-single-uri').show();
477 return false;
478 } );
479 $('#turn-on-opml-upload').click ( function () {
480 $('#add-single-uri').hide();
481 $('#upload-opml').show(600);
482 return false;
483 } );
484 $('#turn-off-opml-upload').click ( function () {
485 $('#upload-opml').hide(600);
486 $('#add-single-uri').show();
487 return false;
488 } );
489 });
490
491