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