3 {{*<script language="javascript" type="text/javascript">*}}
9 var plaintext = '{{$editselect}}';
11 function initEditor(cb){
13 $("#profile-jot-text-loading").show();
14 if(plaintext == 'none') {
15 $("#profile-jot-text-loading").hide();
16 //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
17 $("#jot-category").show();
18 $("#jot-category").addClass("jot-category-ex");
19 $("#jot-profile-jot-wrapper").show();
20 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
21 $("#profile-jot-text").bbco_autocomplete('bbcode');
23 $("a#jot-perms-icon").colorbox({
25 'transition' : 'elastic'
27 $(".jothidden").show();
28 if (typeof cb!="undefined") cb();
33 mode : "specific_textareas",
34 editor_selector: {{$editselect}},
35 auto_focus: "profile-jot-text",
36 plugins : "bbcode,paste,autoresize, inlinepopups",
37 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
38 theme_advanced_buttons2 : "",
39 theme_advanced_buttons3 : "",
40 theme_advanced_toolbar_location : "top",
41 theme_advanced_toolbar_align : "center",
42 theme_advanced_blockformats : "blockquote,code",
43 theme_advanced_resizing : true,
44 gecko_spellcheck : true,
45 paste_text_sticky : true,
46 entity_encoding : "raw",
47 add_unload_trigger : false,
48 remove_linebreaks : false,
49 //force_p_newlines : false,
50 //force_br_newlines : true,
51 forced_root_block : 'div',
53 content_css: "{{$baseurl}}/view/custom_tinymce.css",
54 theme_advanced_path : false,
55 file_browser_callback : "fcFileBrowser",
56 setup : function(ed) {
58 ed.onKeyDown.add(function(ed,e) {
63 ed.onKeyUp.add(function(ed, e) {
64 var txt = tinyMCE.activeEditor.getContent();
65 match = txt.match(/@([^ \n]+)$/);
68 cPopup = new ACPopup(this,baseurl+"/acl");
70 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
71 if(! cPopup.ready) cPopup = null;
74 if(cPopup !== null) { cPopup.close(); cPopup = null; }
78 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
79 $('#profile-jot-desc').html(ispublic);
82 $('#profile-jot-desc').html(' ');
88 $('#character-counter').removeClass('red');
89 $('#character-counter').removeClass('orange');
90 $('#character-counter').addClass('grey');
92 if((textlen > 140) && (textlen <= 420)) {
93 $('#character-counter').removeClass('grey');
94 $('#character-counter').removeClass('red');
95 $('#character-counter').addClass('orange');
98 $('#character-counter').removeClass('grey');
99 $('#character-counter').removeClass('orange');
100 $('#character-counter').addClass('red');
102 $('#character-counter').text(textlen);
105 ed.onInit.add(function(ed) {
106 ed.pasteAsPlainText = true;
107 $("#profile-jot-text-loading").hide();
108 $(".jothidden").show();
109 if (typeof cb!="undefined") cb();
118 $("a#jot-perms-icon").colorbox({
120 'transition' : 'elastic'
124 if (typeof cb!="undefined") cb();
128 function enableOnUser(){
138 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
140 var ispublic = '{{$ispublic}}';
143 $(document).ready(function() {
145 /* enable tinymce on focus and click */
146 //$("#profile-jot-text").focus(enableOnUser);
147 //$("#profile-jot-text").click(enableOnUser);
149 // When clicking on a forum in acl we should remove the profile jot textarea
150 // default value before inserting the forum mention
151 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
152 jotTextOpenUI(document.getElementById("profile-jot-text"));
156 /* show images / file browser window
161 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
162 ///@todo this part isn't ideal and need to be done in a better way
163 jotTextOpenUI(document.getElementById("profile-jot-text"));
165 addeditortext(embedcode);
167 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
168 jotTextOpenUI(document.getElementById("profile-jot-text"));
170 addeditortext(embedcode);
173 $('#wall-image-upload').on('click', function(){
174 Dialog.doImageBrowser("main");
178 $('#wall-file-upload').on('click', function(){
179 Dialog.doFileBrowser("main");
184 var uploader = new window.AjaxUpload(
186 { action: 'wall_upload/{{$nickname}}',
188 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
189 onComplete: function(file,response) {
190 addeditortext(response);
191 $('#profile-rotator').hide();
195 var file_uploader = new window.AjaxUpload(
197 { action: 'wall_attach/{{$nickname}}',
199 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
200 onComplete: function(file,response) {
201 addeditortext(response);
202 $('#profile-rotator').hide();
211 function deleteCheckedItems() {
212 if(confirm('{{$delitems}}')) {
214 var ItemsToDelete = {};
216 $("#item-delete-selected").hide();
217 $('#item-delete-selected-rotator').show();
218 $('body').css('cursor', 'wait');
220 $('.item-select').each( function() {
221 if($(this).is(':checked')) {
222 if(checkedstr.length != 0) {
223 checkedstr = checkedstr + ',' + $(this).val();
224 var deleteItem = this.closest(".wall-item-container");
225 ItemsToDelete[deleteItem.id] = deleteItem;
228 checkedstr = $(this).val();
231 // Get the corresponding item container
232 var deleteItem = this.closest(".wall-item-container");
233 ItemsToDelete[deleteItem.id] = deleteItem;
237 // Fade the the the container from the items we want to delete
238 for(var key in ItemsToDelete) {
239 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
242 $.post('item', { dropitems: checkedstr }, function(data) {
244 // Loop through the ItemsToDelete Object and remove
245 // corresponding item div
246 for(var key in ItemsToDelete) {
247 $(ItemsToDelete[key]).remove();
249 $('body').css('cursor', 'auto');
250 $('#item-delete-selected-rotator').hide();
255 function jotGetLink() {
256 reply = prompt("{{$linkurl}}");
257 if(reply && reply.length) {
258 reply = bin2hex(reply);
259 $('#profile-rotator').show();
260 $.get('parse_url?binurl=' + reply, function(data) {
262 $('#profile-rotator').hide();
267 function jotVideoURL() {
268 reply = prompt("{{$vidurl}}");
269 if(reply && reply.length) {
270 addeditortext('[video]' + reply + '[/video]');
274 function jotAudioURL() {
275 reply = prompt("{{$audurl}}");
276 if(reply && reply.length) {
277 addeditortext('[audio]' + reply + '[/audio]');
282 function jotGetLocation() {
283 reply = prompt("{{$whereareu}}", $('#jot-location').val());
284 if(reply && reply.length) {
285 $('#jot-location').val(reply);
289 function jotShare(id) {
290 $.get('share/' + id, function(data) {
291 // remove the former content of the text input
292 $("#profile-jot-text").val("");
293 initEditor(function(){
300 $("#jot-popup").show();
303 function linkdropper(event) {
304 var linkFound = event.dataTransfer.types.contains("text/uri-list");
306 event.preventDefault();
309 function linkdrop(event) {
310 var reply = event.dataTransfer.getData("text/uri-list");
311 event.target.textContent = reply;
312 event.preventDefault();
313 if(reply && reply.length) {
314 reply = bin2hex(reply);
315 $('#profile-rotator').show();
316 $.get('parse_url?binurl=' + reply, function(data) {
317 if (!editor) $("#profile-jot-text").val("");
318 initEditor(function(){
320 $('#profile-rotator').hide();
326 function itemTag(id) {
327 reply = prompt("{{$term}}");
328 if(reply && reply.length) {
329 reply = reply.replace('#','');
333 $('body').css('cursor', 'wait');
335 $.get('tagger/' + id + '?term=' + reply);
336 if(timer) clearTimeout(timer);
337 timer = setTimeout(NavUpdate,3000);
343 function itemFiler(id) {
345 var bordercolor = $("input").css("border-color");
347 $.get('filer/', function(data){
348 $.colorbox({html:data});
349 $("#id_term").keypress(function(){
350 $(this).css("border-color",bordercolor);
352 $("#select_term").change(function(){
353 $("#id_term").css("border-color",bordercolor);
356 $("#filer_save").click(function(e){
358 reply = $("#id_term").val();
359 if(reply && reply.length) {
361 $('body').css('cursor', 'wait');
362 $.get('filer/' + id + '?term=' + reply, NavUpdate);
363 // if(timer) clearTimeout(timer);
364 // timer = setTimeout(NavUpdate,3000);
368 $("#id_term").css("border-color","#FF0000");
376 function jotClearLocation() {
377 $('#jot-coord').val('');
378 $('#profile-nolocation-wrapper').hide();
381 function addeditortext(data) {
382 if(plaintext == 'none') {
384 var textfield = document.getElementById("profile-jot-text");
385 // check if the textfield does have the default-value
386 jotTextOpenUI(textfield);
387 // save already existent content
388 var currentText = $("#profile-jot-text").val();
389 //insert the data as new value
390 textfield.value = currentText + data;
393 tinyMCE.execCommand('mceInsertRawHTML',false,data);
399 var modal = $('#jot-modal').modal();
400 jotcache = $("#profile-jot-form");
403 .find('#jot-modal-content')
408 // the following functions show/hide the specific jot content
409 // in dependence of the selected nav
410 function aclActive() {
411 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
412 $(".modal-body #profile-jot-acl-wrapper").show();
416 function previewActive() {
417 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
421 function jotActive() {
422 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
423 $(".modal-body #profile-jot-wrapper").show();
425 //make sure jot text does have really the active class (we do this because there are some
426 // other events which trigger jot text
427 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
430 function fbrowserActive() {
431 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
433 $(".modal-body #jot-fbrowser-wrapper").show();
435 $(function() {Dialog.showJot();});