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