2 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
4 <script type="text/javascript">
7 var plaintext = '{{$editselect}}';
9 function initEditor(cb){
11 $("#profile-jot-text-loading").show();
12 if(plaintext == 'none') {
13 $("#profile-jot-text-loading").hide();
14 //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
15 $("#jot-category").show();
16 $("#jot-category").addClass("jot-category-ex");
17 $("#jot-profile-jot-wrapper").show();
18 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
19 $("#profile-jot-text").bbco_autocomplete('bbcode');
21 $("a#jot-perms-icon").colorbox({
23 'transition' : 'elastic'
25 $(".jothidden").show();
26 if (typeof cb!="undefined") cb();
27 $("#profile-jot-text").keyup(function(){
28 var textlen = $(this).val().length;
29 $('#character-counter').text(textlen);
35 mode : "specific_textareas",
36 editor_selector: {{$editselect}},
37 auto_focus: "profile-jot-text",
38 plugins : "bbcode,paste,autoresize, inlinepopups",
39 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
40 theme_advanced_buttons2 : "",
41 theme_advanced_buttons3 : "",
42 theme_advanced_toolbar_location : "top",
43 theme_advanced_toolbar_align : "center",
44 theme_advanced_blockformats : "blockquote,code",
45 theme_advanced_resizing : true,
46 gecko_spellcheck : true,
47 paste_text_sticky : true,
48 entity_encoding : "raw",
49 add_unload_trigger : false,
50 remove_linebreaks : false,
51 //force_p_newlines : false,
52 //force_br_newlines : true,
53 forced_root_block : 'div',
55 content_css: "{{$baseurl}}/view/custom_tinymce.css",
56 theme_advanced_path : false,
57 file_browser_callback : "fcFileBrowser",
58 setup : function(ed) {
60 ed.onKeyDown.add(function(ed,e) {
65 ed.onKeyUp.add(function(ed, e) {
66 var txt = tinyMCE.activeEditor.getContent();
67 match = txt.match(/@([^ \n]+)$/);
70 cPopup = new ACPopup(this,baseurl+"/acl");
72 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
73 if(! cPopup.ready) cPopup = null;
76 if(cPopup !== null) { cPopup.close(); cPopup = null; }
80 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
81 $('#profile-jot-desc').html(ispublic);
84 $('#profile-jot-desc').html(' ');
90 $('#character-counter').removeClass('red');
91 $('#character-counter').removeClass('orange');
92 $('#character-counter').addClass('grey');
94 if((textlen > 140) && (textlen <= 420)) {
95 $('#character-counter').removeClass('grey');
96 $('#character-counter').removeClass('red');
97 $('#character-counter').addClass('orange');
100 $('#character-counter').removeClass('grey');
101 $('#character-counter').removeClass('orange');
102 $('#character-counter').addClass('red');
104 $('#character-counter').text(textlen);
107 ed.onInit.add(function(ed) {
108 ed.pasteAsPlainText = true;
109 $("#profile-jot-text-loading").hide();
110 $(".jothidden").show();
111 if (typeof cb!="undefined") cb();
120 $("a#jot-perms-icon").colorbox({
122 'transition' : 'elastic'
126 if (typeof cb!="undefined") cb();
130 function enableOnUser(){
137 <script type="text/javascript">
138 var ispublic = '{{$ispublic}}';
141 $(document).ready(function() {
143 /* enable tinymce on focus and click */
144 $("#profile-jot-text").focus(enableOnUser);
145 $("#profile-jot-text").click(enableOnUser);
147 // When clicking on a forum in acl we should remove the profile jot textarea
148 // default value before inserting the forum mention
149 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
150 jotTextOpenUI(document.getElementById("profile-jot-text"));
154 /* show images / file browser window
159 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
160 ///@todo this part isn't ideal and need to be done in a better way
161 jotTextOpenUI(document.getElementById("profile-jot-text"));
163 addeditortext(embedcode);
165 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
166 jotTextOpenUI(document.getElementById("profile-jot-text"));
168 addeditortext(embedcode);
171 $('#wall-image-upload').on('click', function(){
172 Dialog.doImageBrowser("main");
176 $('#wall-file-upload').on('click', function(){
177 Dialog.doFileBrowser("main");
182 var uploader = new window.AjaxUpload(
184 { action: 'wall_upload/{{$nickname}}',
186 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
187 onComplete: function(file,response) {
188 addeditortext(response);
189 $('#profile-rotator').hide();
193 var file_uploader = new window.AjaxUpload(
195 { action: 'wall_attach/{{$nickname}}',
197 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
198 onComplete: function(file,response) {
199 addeditortext(response);
200 $('#profile-rotator').hide();
209 function deleteCheckedItems() {
210 if(confirm('{{$delitems}}')) {
212 var ItemsToDelete = {};
214 $("#item-delete-selected").hide();
215 $('#item-delete-selected-rotator').show();
216 $('body').css('cursor', 'wait');
218 $('.item-select').each( function() {
219 if($(this).is(':checked')) {
220 if(checkedstr.length != 0) {
221 checkedstr = checkedstr + ',' + $(this).val();
222 var deleteItem = this.closest(".wall-item-container");
223 ItemsToDelete[deleteItem.id] = deleteItem;
226 checkedstr = $(this).val();
229 // Get the corresponding item container
230 var deleteItem = this.closest(".wall-item-container");
231 ItemsToDelete[deleteItem.id] = deleteItem;
235 // Fade the the the container from the items we want to delete
236 for(var key in ItemsToDelete) {
237 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
240 $.post('item', { dropitems: checkedstr }, function(data) {
242 // Loop through the ItemsToDelete Object and remove
243 // corresponding item div
244 for(var key in ItemsToDelete) {
245 $(ItemsToDelete[key]).remove();
247 $('body').css('cursor', 'auto');
248 $('#item-delete-selected-rotator').hide();
253 function jotGetLink() {
254 reply = prompt("{{$linkurl}}");
255 if(reply && reply.length) {
256 reply = bin2hex(reply);
257 $('#profile-rotator').show();
258 $.get('parse_url?binurl=' + reply, function(data) {
260 $('#profile-rotator').hide();
265 function jotVideoURL() {
266 reply = prompt("{{$vidurl}}");
267 if(reply && reply.length) {
268 addeditortext('[video]' + reply + '[/video]');
272 function jotAudioURL() {
273 reply = prompt("{{$audurl}}");
274 if(reply && reply.length) {
275 addeditortext('[audio]' + reply + '[/audio]');
280 function jotGetLocation() {
281 reply = prompt("{{$whereareu}}", $('#jot-location').val());
282 if(reply && reply.length) {
283 $('#jot-location').val(reply);
287 function jotShare(id) {
288 $.get('share/' + id, function(data) {
289 // remove the former content of the text input
290 $("#profile-jot-text").val("");
291 initEditor(function(){
298 $("#jot-popup").show();
301 function linkdropper(event) {
302 var linkFound = event.dataTransfer.types.contains("text/uri-list");
304 event.preventDefault();
307 function linkdrop(event) {
308 var reply = event.dataTransfer.getData("text/uri-list");
309 event.target.textContent = reply;
310 event.preventDefault();
311 if(reply && reply.length) {
312 reply = bin2hex(reply);
313 $('#profile-rotator').show();
314 $.get('parse_url?binurl=' + reply, function(data) {
315 if (!editor) $("#profile-jot-text").val("");
316 initEditor(function(){
318 $('#profile-rotator').hide();
324 function itemTag(id) {
325 reply = prompt("{{$term}}");
326 if(reply && reply.length) {
327 reply = reply.replace('#','');
331 $('body').css('cursor', 'wait');
333 $.get('tagger/' + id + '?term=' + reply);
334 if(timer) clearTimeout(timer);
335 timer = setTimeout(NavUpdate,3000);
341 function itemFiler(id) {
343 var bordercolor = $("input").css("border-color");
345 $.get('filer/', function(data){
346 $.colorbox({html:data});
347 $("#id_term").keypress(function(){
348 $(this).css("border-color",bordercolor);
350 $("#select_term").change(function(){
351 $("#id_term").css("border-color",bordercolor);
354 $("#filer_save").click(function(e){
356 reply = $("#id_term").val();
357 if(reply && reply.length) {
359 $('body').css('cursor', 'wait');
360 $.get('filer/' + id + '?term=' + reply, NavUpdate);
361 // if(timer) clearTimeout(timer);
362 // timer = setTimeout(NavUpdate,3000);
366 $("#id_term").css("border-color","#FF0000");
374 function jotClearLocation() {
375 $('#jot-coord').val('');
376 $('#profile-nolocation-wrapper').hide();
379 function addeditortext(data) {
380 if(plaintext == 'none') {
382 var textfield = document.getElementById("profile-jot-text");
383 // check if the textfield does have the default-value
384 jotTextOpenUI(textfield);
385 // save already existent content
386 var currentText = $("#profile-jot-text").val();
387 //insert the data as new value
388 textfield.value = currentText + data;
391 tinyMCE.execCommand('mceInsertRawHTML',false,data);
397 var modal = $('#jot-modal').modal();
398 jotcache = $("#jot-sections");
400 // Auto focus on the first enabled field in the modal
401 modal.on('shown.bs.modal', function (e) {
402 $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
406 .find('#jot-modal-content')
411 // the following functions show/hide the specific jot content
412 // in dependence of the selected nav
413 function aclActive() {
414 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
415 $(".modal-body #profile-jot-acl-wrapper").show();
419 function previewActive() {
420 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
424 function jotActive() {
425 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
426 $(".modal-body #profile-jot-wrapper").show();
428 //make sure jot text does have really the active class (we do this because there are some
429 // other events which trigger jot text
430 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
433 function fbrowserActive() {
434 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
436 $(".modal-body #jot-fbrowser-wrapper").show();
438 $(function() {Dialog.showJot();});