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