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