]> git.mxchange.org Git - friendica.git/blob - view/theme/frost/js/main.js
4aaa7ddb74062b277d5f91783101c549348be9c2
[friendica.git] / view / theme / frost / js / main.js
1
2         function openClose(listID) {
3 /*              if(document.getElementById(theID).style.display == "block") { 
4                         document.getElementById(theID).style.display = "none" 
5                 }
6                 else { 
7                         document.getElementById(theID).style.display = "block" 
8                 }*/
9                 listID = "#" + listID.replace(/:/g, "\\:");
10                 listID = listID.replace(/\./g, "\\.");
11                 listID = listID.replace(/@/g, "\\@");
12
13                 if($j(listID).is(":visible")) {
14                         $j(listID).hide();
15                         $j(listID+"-wrapper").show();
16                 }
17                 else {
18                         $j(listID).show();
19                         $j(listID+"-wrapper").hide();
20                 }
21         }
22
23         function openMenu(theID) {
24                 document.getElementById(theID).style.display = "block" 
25         }
26
27         function closeMenu(theID) {
28                 document.getElementById(theID).style.display = "none" 
29         }
30
31
32
33         var src = null;
34         var prev = null;
35         var livetime = null;
36         var msie = false;
37         var stopped = false;
38         var totStopped = false;
39         var timer = null;
40         var pr = 0;
41         var liking = 0;
42         var in_progress = false;
43         var langSelect = false;
44         var commentBusy = false;
45         var last_popup_menu = null;
46         var last_popup_button = null;
47
48         $j(function() {
49                 $j.ajaxSetup({cache: false});
50
51                 msie = $j.browser.msie ;
52                 
53                 collapseHeight();
54                 
55                 /* setup tooltips *//*
56                 $j("a,.tt").each(function(){
57                         var e = $j(this);
58                         var pos="bottom";
59                         if (e.hasClass("tttop")) pos="top";
60                         if (e.hasClass("ttbottom")) pos="bottom";
61                         if (e.hasClass("ttleft")) pos="left";
62                         if (e.hasClass("ttright")) pos="right";
63                         e.tipTip({defaultPosition: pos, edgeOffset: 8});
64                 });*/
65                 
66                 
67                 
68                 /* setup onoff widgets */
69                 $j(".onoff input").each(function(){
70                         val = $j(this).val();
71                         id = $j(this).attr("id");
72                         $j("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
73                         
74                 });
75                 $j(".onoff > a").click(function(event){
76                         event.preventDefault(); 
77                         var input = $j(this).siblings("input");
78                         var val = 1-input.val();
79                         var id = input.attr("id");
80                         $j("#"+id+"_onoff ."+ (val==0?"on":"off")).addClass("hidden");
81                         $j("#"+id+"_onoff ."+ (val==1?"on":"off")).removeClass("hidden");
82                         input.val(val);
83                         //console.log(id);
84                 });
85                 
86                 /* setup field_richtext */
87                 setupFieldRichtext();
88
89                 /* popup menus */
90                 function close_last_popup_menu(e) {
91
92                         if( last_popup_menu ) {
93                                 if( '#' + last_popup_menu.attr('id') !== $j(e.target).attr('rel')) {
94                                         last_popup_menu.hide();
95                                         last_popup_button.removeClass("selected");
96                                         last_popup_menu = null;
97                                         last_popup_button = null;
98                                 }
99                         }
100                 }
101                 $j('a[rel^=#]').click(function(e){
102
103                         close_last_popup_menu(e);
104                         menu = $j( $j(this).attr('rel') );
105                         e.preventDefault();
106                         e.stopPropagation();
107
108                         if (menu.attr('popup')=="false") return false;
109
110                         $j(this).parent().toggleClass("selected");
111                         menu.slideToggle('fast');
112
113                         if (menu.css("display") == "none") {
114                                 last_popup_menu = null;
115                                 last_popup_button = null;
116                         } else {
117                                 last_popup_menu = menu;
118                                 last_popup_button = $j(this).parent();
119                         }
120                         return false;
121                 });
122                 $j('html').click(function(e) {
123                         close_last_popup_menu(e);
124                 });
125                 
126                 // fancyboxes
127                 $j("a.popupbox").fancybox({
128                         'transitionIn' : 'none',
129                         'transitionOut' : 'none'
130                 });
131                 
132
133                 /* notifications template */
134                 var notifications_tpl= unescape($j("#nav-notifications-template[rel=template]").html());
135                 var notifications_all = unescape($j('<div>').append( $j("#nav-notifications-see-all").clone() ).html()); //outerHtml hack
136                 var notifications_mark = unescape($j('<div>').append( $j("#nav-notifications-mark-all").clone() ).html()); //outerHtml hack
137                 var notifications_empty = unescape($j("#nav-notifications-menu").html());
138                 
139                 /* nav update event  */
140                 $j('nav').bind('nav-update', function(e,data){;
141                         var invalid = $j(data).find('invalid').text();
142                         if(invalid == 1) { window.location.href=window.location.href }
143
144                         var net = $j(data).find('net').text();
145                         if(net == 0) { net = ''; $j('#net-update').removeClass('show') } else { $j('#net-update').addClass('show') }
146                         $j('#net-update').html(net);
147
148                         var home = $j(data).find('home').text();
149                         if(home == 0) { home = '';  $j('#home-update').removeClass('show') } else { $j('#home-update').addClass('show') }
150                         $j('#home-update').html(home);
151                         
152                         var intro = $j(data).find('intro').text();
153                         if(intro == 0) { intro = '';  $j('#intro-update').removeClass('show') } else { $j('#intro-update').addClass('show') }
154                         $j('#intro-update').html(intro);
155
156                         var mail = $j(data).find('mail').text();
157                         if(mail == 0) { mail = '';  $j('#mail-update').removeClass('show') } else { $j('#mail-update').addClass('show') }
158                         $j('#mail-update').html(mail);
159                         
160                         var intro = $j(data).find('intro').text();
161                         if(intro == 0) { intro = '';  $j('#intro-update-li').removeClass('show') } else { $j('#intro-update-li').addClass('show') }
162                         $j('#intro-update-li').html(intro);
163
164                         var mail = $j(data).find('mail').text();
165                         if(mail == 0) { mail = '';  $j('#mail-update-li').removeClass('show') } else { $j('#mail-update-li').addClass('show') }
166                         $j('#mail-update-li').html(mail);
167
168                         var eNotif = $j(data).find('notif')
169                         
170                         if (eNotif.children("note").length==0){
171                                 $j("#nav-notifications-menu").html(notifications_empty);
172                         } else {
173                                 nnm = $j("#nav-notifications-menu");
174                                 nnm.html(notifications_all + notifications_mark);
175                                 //nnm.attr('popup','true');
176                                 eNotif.children("note").each(function(){
177                                         e = $j(this);
178                                         text = e.text().format("<span class='contactname'>"+e.attr('name')+"</span>");
179                                         html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen'));
180                                         nnm.append(html);
181                                 });
182                         }
183                         notif = eNotif.attr('count');
184                         if (notif>0){
185                                 $j("#nav-notifications-linkmenu").addClass("on");
186                         } else {
187                                 $j("#nav-notifications-linkmenu").removeClass("on");
188                         }
189                         if(notif == 0) { notif = ''; $j('#notify-update').removeClass('show') } else { $j('#notify-update').addClass('show') }
190                         $j('#notify-update').html(notif);
191                         
192                         var eSysmsg = $j(data).find('sysmsgs');
193                         eSysmsg.children("notice").each(function(){
194                                 text = $j(this).text();
195                                 $j.jGrowl(text, { sticky: false, theme: 'notice', life: 3000 }); // originally: sticky: true,
196                         });
197                         eSysmsg.children("info").each(function(){
198                                 text = $j(this).text();
199                                 $j.jGrowl(text, { sticky: false, theme: 'info', life: 1000 });
200                         });
201                         
202                 });
203                 
204                 
205                 NavUpdate(); 
206                 // Allow folks to stop the ajax page updates with the pause/break key
207                 $j(document).keydown(function(event) {
208                         if(event.keyCode == '8') {
209                                 var target = event.target || event.srcElement;
210                                 if (!/input|textarea/i.test(target.nodeName)) {
211                                         return false;
212                                 }
213                         }
214                         if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) {
215                                 event.preventDefault();
216                                 if(stopped == false) {
217                                         stopped = true;
218                                         if (event.ctrlKey) {
219                                                 totStopped = true;
220                                         }
221                                         $j('#pause').html('<img src="images/pause.gif" alt="pause" style="border: 1px solid black;" />');
222                                 } else {
223                                         unpause();
224                                 }
225                         } else {
226                                 if (!totStopped) {
227                                         unpause();
228                                 }
229                         }
230                 });
231                 
232                 
233         });
234
235         function NavUpdate() {
236
237                 if(! stopped) {
238                         var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
239                         $j.get(pingCmd,function(data) {
240                                 $j(data).find('result').each(function() {
241                                         // send nav-update event
242                                         $j('nav').trigger('nav-update', this);
243                                         
244                                         
245                                         // start live update
246
247                                         
248
249                                         if($j('#live-network').length)   { src = 'network'; liveUpdate(); }
250                                         if($j('#live-profile').length)   { src = 'profile'; liveUpdate(); }
251                                         if($j('#live-community').length) { src = 'community'; liveUpdate(); }
252                                         if($j('#live-notes').length)     { src = 'notes'; liveUpdate(); }
253                                         if($j('#live-display').length) { src = 'display'; liveUpdate(); }
254                                         /*if($j('#live-display').length) {
255                                                 if(liking) {
256                                                         liking = 0;
257                                                         window.location.href=window.location.href 
258                                                 }
259                                         }*/
260                                         if($j('#live-photos').length) {
261                                                 if(liking) {
262                                                         liking = 0;
263                                                         window.location.href=window.location.href 
264                                                 }
265                                         }
266
267                                         
268                                         
269                                         
270                                 });
271                         }) ;
272                 }
273                 timer = setTimeout(NavUpdate,updateInterval);
274         }
275
276         function liveUpdate() {
277                 if((src == null) || (stopped) || (! profile_uid)) { $j('.like-rotator').hide(); return; }
278                 if(($j('.comment-edit-text-full').length) || (in_progress)) {
279                         if(livetime) {
280                                 clearTimeout(livetime);
281                         }
282                         livetime = setTimeout(liveUpdate, 10000);
283                         return;
284                 }
285                 if(livetime != null)
286                         livetime = null;
287
288                 prev = 'live-' + src;
289
290                 in_progress = true;
291                 var udargs = ((netargs.length) ? '/' + netargs : '');
292                 var update_url = 'update_' + src + udargs + '&p=' + profile_uid + '&page=' + profile_page + '&msie=' + ((msie) ? 1 : 0);
293
294                 $j.get(update_url,function(data) {
295                         in_progress = false;
296                         //                      $j('.collapsed-comments',data).each(function() {
297                         //      var ident = $j(this).attr('id');
298                         //      var is_hidden = $j('#' + ident).is(':hidden');
299                         //      if($j('#' + ident).length) {
300                         //              $j('#' + ident).replaceWith($j(this));
301                         //              if(is_hidden)
302                         //                      $j('#' + ident).hide();
303                         //      }
304                         //});
305
306                         // add a new thread
307
308                         $j('.toplevel_item',data).each(function() {
309                                 var ident = $j(this).attr('id');
310
311                                 if($j('#' + ident).length == 0 && profile_page == 1) {
312                                         $j('img',this).each(function() {
313                                                 $j(this).attr('src',$j(this).attr('dst'));
314                                         });
315                                         $j('#' + prev).after($j(this));
316                                 }
317                                 else {
318                                         // Find out if the hidden comments are open, so we can keep it that way
319                                         // if a new comment has been posted
320                                         var id = $j('.hide-comments-total', this).attr('id');
321                                         if(typeof id != 'undefined') {
322                                                 id = id.split('-')[3];
323                                                 var commentsOpen = $j("#collapsed-comments-" + id).is(":visible");
324                                         }
325
326                                         $j('img',this).each(function() {
327                                                 $j(this).attr('src',$j(this).attr('dst'));
328                                         });
329                                         //vScroll = $j(document).scrollTop();
330                                         $j('html').height($j('html').height());
331                                         $j('#' + ident).replaceWith($j(this));
332
333                                         if(typeof id != 'undefined') {
334                                                 if(commentsOpen) showHideComments(id);
335                                         }
336                                         $j('html').height('auto');
337                                         //$j(document).scrollTop(vScroll);
338                                 }
339                                 prev = ident;
340                         });
341
342                         // reset vars for inserting individual items
343
344                         /*prev = 'live-' + src;
345
346                         $j('.wall-item-outside-wrapper',data).each(function() {
347                                 var ident = $j(this).attr('id');
348
349                                 if($j('#' + ident).length == 0 && prev != 'live-' + src) {
350                                                 $j('img',this).each(function() {
351                                                         $j(this).attr('src',$j(this).attr('dst'));
352                                                 });
353                                                 $j('#' + prev).after($j(this));
354                                 }
355                                 else { 
356                                         $j('#' + ident + ' ' + '.wall-item-ago').replaceWith($j(this).find('.wall-item-ago')); 
357                                         if($j('#' + ident + ' ' + '.comment-edit-text-empty').length)
358                                                 $j('#' + ident + ' ' + '.wall-item-comment-wrapper').replaceWith($j(this).find('.wall-item-comment-wrapper'));
359                                         $j('#' + ident + ' ' + '.hide-comments-total').replaceWith($j(this).find('.hide-comments-total'));
360                                         $j('#' + ident + ' ' + '.wall-item-like').replaceWith($j(this).find('.wall-item-like'));
361                                         $j('#' + ident + ' ' + '.wall-item-dislike').replaceWith($j(this).find('.wall-item-dislike'));
362                                         $j('#' + ident + ' ' + '.my-comment-photo').each(function() {
363                                                 $j(this).attr('src',$j(this).attr('dst'));
364                                         });
365                                 }
366                                 prev = ident; 
367                         });*/
368                         
369                         $j('.like-rotator').hide();
370                         if(commentBusy) {
371                                 commentBusy = false;
372                                 $j('body').css('cursor', 'auto');
373                         }
374                         /* autocomplete @nicknames */
375                         $j(".comment-edit-form  textarea").contact_autocomplete(baseurl+"/acl");
376                 
377                         collapseHeight();
378
379                 });
380         }
381
382         function collapseHeight(elems) {
383                 var elemName = '.wall-item-body:not(.divmore)';
384                 if(typeof elems != 'undefined') {
385                         elemName = elems + ' ' + elemName;
386                 }
387                 $j(elemName).each(function() {
388                         if($j(this).height() > 450) {
389                                 $j('html').height($j('html').height());
390                                 $j(this).divgrow({ initialHeight: 400, showBrackets: false, speed: 0 });
391                                 $j(this).addClass('divmore');
392                                 $j('html').height('auto');
393                         }                                       
394                 });
395         }
396
397         function imgbright(node) {
398                 $j(node).removeClass("drophide").addClass("drop");
399         }
400
401         function imgdull(node) {
402                 $j(node).removeClass("drop").addClass("drophide");
403         }
404
405         // Since our ajax calls are asynchronous, we will give a few 
406         // seconds for the first ajax call (setting like/dislike), then 
407         // run the updater to pick up any changes and display on the page.
408         // The updater will turn any rotators off when it's done. 
409         // This function will have returned long before any of these
410         // events have completed and therefore there won't be any
411         // visible feedback that anything changed without all this
412         // trickery. This still could cause confusion if the "like" ajax call
413         // is delayed and NavUpdate runs before it completes.
414
415         function dolike(ident,verb) {
416                 unpause();
417                 $j('#like-rotator-' + ident.toString()).show();
418                 $j.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
419 //              if(timer) clearTimeout(timer);
420 //              timer = setTimeout(NavUpdate,3000);
421                 liking = 1;
422         }
423
424         function dostar(ident) {
425                 ident = ident.toString();
426 //              $j('#like-rotator-' + ident).show();
427                 $j.get('starred/' + ident, function(data) {
428                         if(data.match(/1/)) {
429                                 $j('#starred-' + ident).addClass('starred');
430                                 $j('#starred-' + ident).removeClass('unstarred');
431                                 $j('#star-' + ident).addClass('hidden');
432                                 $j('#unstar-' + ident).removeClass('hidden');
433                         }
434                         else {                  
435                                 $j('#starred-' + ident).addClass('unstarred');
436                                 $j('#starred-' + ident).removeClass('starred');
437                                 $j('#star-' + ident).removeClass('hidden');
438                                 $j('#unstar-' + ident).addClass('hidden');
439                         }
440 //                      $j('#like-rotator-' + ident).hide();    
441                 });
442         }
443
444         function getPosition(e) {
445                 var cursor = {x:0, y:0};
446                 if ( e.pageX || e.pageY  ) {
447                         cursor.x = e.pageX;
448                         cursor.y = e.pageY;
449                 }
450                 else {
451                         if( e.clientX || e.clientY ) {
452                                 cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
453                                 cursor.y = e.clientY + (document.documentElement.scrollTop  || document.body.scrollTop)  - document.documentElement.clientTop;
454                         }
455                         else {
456                                 if( e.x || e.y ) {
457                                         cursor.x = e.x;
458                                         cursor.y = e.y;
459                                 }
460                         }
461                 }
462                 return cursor;
463         }
464
465         var lockvisible = false;
466
467         function lockview(event,id) {
468                 event = event || window.event;
469                 cursor = getPosition(event);
470                 if(lockvisible) {
471                         lockviewhide();
472                 }
473                 else {
474                         lockvisible = true;
475                         $j.get('lockview/' + id, function(data) {
476                                 $j('#panel').html(data);
477                                 $j('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
478                                 $j('#panel').show();
479                         });
480                 }
481         }
482
483         function lockviewhide() {
484                 lockvisible = false;
485                 $j('#panel').hide();
486         }
487
488         function post_comment(id) {
489                 unpause();
490                 commentBusy = true;
491                 $j('body').css('cursor', 'wait');
492                 $j("#comment-preview-inp-" + id).val("0");
493                 $j.post(  
494              "item",  
495              $j("#comment-edit-form-" + id).serialize(),
496                         function(data) {
497                                 if(data.success) {
498                                         $j("#comment-edit-wrapper-" + id).hide();
499                                         $j("#comment-edit-text-" + id).val('');
500                                 var tarea = document.getElementById("comment-edit-text-" + id);
501                                         if(tarea)
502                                                 commentClose(tarea,id);
503                                         if(timer) clearTimeout(timer);
504                                         timer = setTimeout(NavUpdate,10);
505                                 }
506                                 if(data.reload) {
507                                         window.location.href=data.reload;
508                                 }
509                         },
510                         "json"  
511          );  
512          return false;  
513         }
514
515
516         function preview_comment(id) {
517                 $j("#comment-preview-inp-" + id).val("1");
518                 $j("#comment-edit-preview-" + id).show();
519                 $j.post(  
520              "item",  
521              $j("#comment-edit-form-" + id).serialize(),
522                         function(data) {
523                                 if(data.preview) {
524                                                 
525                                         $j("#comment-edit-preview-" + id).html(data.preview);
526                                         $j("#comment-edit-preview-" + id + " a").click(function() { return false; });
527                                 }
528                         },
529                         "json"  
530          );  
531          return true;  
532         }
533
534
535         function showHideComments(id) {
536                 if( $j("#collapsed-comments-" + id).is(":visible")) {
537                         $j("#collapsed-comments-" + id).hide();
538                         $j("#hide-comments-" + id).html(window.showMore);
539                 }
540                 else {
541                         $j("#collapsed-comments-" + id).show();
542                         $j("#hide-comments-" + id).html(window.showFewer);
543                         collapseHeight("#collapsed-comments-" + id);
544                 }
545         }
546
547
548         function preview_post() {
549                 $j("#jot-preview").val("1");
550                 $j("#jot-preview-content").show();
551                 tinyMCE.triggerSave();
552                 $j.post(  
553                         "item",  
554                         $j("#profile-jot-form").serialize(),
555                         function(data) {
556                                 if(data.preview) {                      
557                                         $j("#jot-preview-content").html(data.preview);
558                                         $j("#jot-preview-content" + " a").click(function() { return false; });
559                                 }
560                         },
561                         "json"  
562                 );  
563                 $j("#jot-preview").val("0");
564                 return true;  
565         }
566
567
568         function unpause() {
569                 // unpause auto reloads if they are currently stopped
570                 totStopped = false;
571                 stopped = false;
572             $j('#pause').html('');
573         }
574                 
575
576     function bin2hex(s){  
577         // Converts the binary representation of data to hex    
578         //   
579         // version: 812.316  
580         // discuss at: http://phpjs.org/functions/bin2hex  
581         // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)  
582         // +   bugfixed by: Onno Marsman  
583         // +   bugfixed by: Linuxworld  
584         // *     example 1: bin2hex('Kev');  
585         // *     returns 1: '4b6576'  
586         // *     example 2: bin2hex(String.fromCharCode(0x00));  
587         // *     returns 2: '00'  
588         var v,i, f = 0, a = [];  
589         s += '';  
590         f = s.length;  
591           
592         for (i = 0; i<f; i++) {  
593             a[i] = s.charCodeAt(i).toString(16).replace(/^([\da-f])$/,"0$1");  
594         }  
595           
596         return a.join('');  
597     }  
598
599         function groupChangeMember(gid, cid, sec_token) {
600                 $j('body .fakelink').css('cursor', 'wait');
601                 $j.get('group/' + gid + '/' + cid + "?t=" + sec_token, function(data) {
602                                 $j('#group-update-wrapper').html(data);
603                                 $j('body .fakelink').css('cursor', 'auto');                             
604                 });
605         }
606
607         function profChangeMember(gid,cid) {
608                 $j('body .fakelink').css('cursor', 'wait');
609                 $j.get('profperm/' + gid + '/' + cid, function(data) {
610                                 $j('#prof-update-wrapper').html(data);
611                                 $j('body .fakelink').css('cursor', 'auto');                             
612                 });
613         }
614
615         function contactgroupChangeMember(gid,cid) {
616                 $j('body').css('cursor', 'wait');
617                 $j.get('contactgroup/' + gid + '/' + cid, function(data) {
618                                 $j('body').css('cursor', 'auto');
619                 });
620         }
621
622
623 function checkboxhighlight(box) {
624   if($j(box).is(':checked')) {
625         $j(box).addClass('checkeditem');
626   }
627   else {
628         $j(box).removeClass('checkeditem');
629   }
630 }
631
632 function notifyMarkAll() {
633         $j.get('notify/mark/all', function(data) {
634                 if(timer) clearTimeout(timer);
635                 timer = setTimeout(NavUpdate,1000);
636         });
637 }
638
639
640 // code from http://www.tinymce.com/wiki.php/How-to_implement_a_custom_file_browser
641 function fcFileBrowser (field_name, url, type, win) {
642     /* TODO: If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
643        the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
644        These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */
645
646
647     var cmsURL = baseurl+"/fbrowser/"+type+"/";
648
649     tinyMCE.activeEditor.windowManager.open({
650         file : cmsURL,
651         title : 'File Browser',
652         width : 420,  // Your dimensions may differ - toy around with them!
653         height : 400,
654         resizable : "yes",
655         inline : "yes",  // This parameter only has an effect if you use the inlinepopups plugin!
656         close_previous : "no"
657     }, {
658         window : win,
659         input : field_name
660     });
661     return false;
662   }
663
664 function setupFieldRichtext(){
665         tinyMCE.init({
666                 theme : "advanced",
667                 mode : "specific_textareas",
668                 editor_selector: "fieldRichtext",
669                 plugins : "bbcode,paste, inlinepopups",
670                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
671                 theme_advanced_buttons2 : "",
672                 theme_advanced_buttons3 : "",
673                 theme_advanced_toolbar_location : "top",
674                 theme_advanced_toolbar_align : "center",
675                 theme_advanced_blockformats : "blockquote,code",
676                 paste_text_sticky : true,
677                 entity_encoding : "raw",
678                 add_unload_trigger : false,
679                 remove_linebreaks : false,
680                 force_p_newlines : false,
681                 force_br_newlines : true,
682                 forced_root_block : '',
683                 convert_urls: false,
684                 content_css: baseurl+"/view/custom_tinymce.css",
685                 theme_advanced_path : false,
686                 file_browser_callback : "fcFileBrowser",
687         });
688 }
689
690
691 /** 
692  * sprintf in javascript 
693  *      "{0} and {1}".format('zero','uno'); 
694  **/
695 String.prototype.format = function() {
696     var formatted = this;
697     for (var i = 0; i < arguments.length; i++) {
698         var regexp = new RegExp('\\{'+i+'\\}', 'gi');
699         formatted = formatted.replace(regexp, arguments[i]);
700     }
701     return formatted;
702 };
703 // Array Remove
704 Array.prototype.remove = function(item) {
705   to=undefined; from=this.indexOf(item);
706   var rest = this.slice((to || from) + 1 || this.length);
707   this.length = from < 0 ? this.length + from : from;
708   return this.push.apply(this, rest);
709 };
710
711 function previewTheme(elm) {
712         theme = $j(elm).val();
713         $j.getJSON('pretheme?f=&theme=' + theme,function(data) {
714                         $j('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
715         });
716
717 }