3 <script language="javascript" type="text/javascript">
7 var plaintext = '{{$editselect}}';
9 function initEditor(cb){
11 var colorbox_options = {
12 {{if $APP->is_mobile}}
17 'transition' : 'elastic'
22 $("#profile-jot-text-loading").show();
23 if(plaintext == 'none') {
24 $("#profile-jot-text-loading").hide();
25 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
26 $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
28 $("a#jot-perms-icon").colorbox(colorbox_options);
29 $(".jothidden").show();
30 if (typeof cb!="undefined") cb();
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();
118 $("a#jot-perms-icon").colorbox(colorbox_options);
120 if (typeof cb!="undefined") cb();
124 function enableOnUser(){
131 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
133 var ispublic = '{{$ispublic}}';
136 $(document).ready(function() {
138 /* enable tinymce on focus and click */
139 $("#profile-jot-text").focus(enableOnUser);
140 $("#profile-jot-text").click(enableOnUser);
145 /* show images / file browser window
150 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
152 addeditortext(embedcode);
154 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
156 addeditortext(embedcode);
159 $('#wall-image-upload').on('click', function(){
160 Dialog.doImageBrowser("main");
163 $('#wall-file-upload').on('click', function(){
164 Dialog.doFileBrowser("main");
168 var uploader = new window.AjaxUpload(
170 { action: 'wall_upload/{{$nickname}}',
172 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
173 onComplete: function(file,response) {
174 addeditortext(response);
175 $('#profile-rotator').hide();
179 var file_uploader = new window.AjaxUpload(
181 { action: 'wall_attach/{{$nickname}}',
183 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
184 onComplete: function(file,response) {
185 addeditortext(response);
186 $('#profile-rotator').hide();
196 function deleteCheckedItems() {
197 if(confirm('{{$delitems}}')) {
200 $("#item-delete-selected").hide();
201 $('#item-delete-selected-rotator').show();
203 $('.item-select').each( function() {
204 if($(this).is(':checked')) {
205 if(checkedstr.length != 0) {
206 checkedstr = checkedstr + ',' + $(this).val();
209 checkedstr = $(this).val();
213 $.post('item', { dropitems: checkedstr }, function(data) {
214 window.location.reload();
219 function jotGetLink() {
220 reply = prompt("{{$linkurl}}");
221 if(reply && reply.length) {
222 reply = bin2hex(reply);
223 $('#profile-rotator').show();
224 $.get('parse_url?binurl=' + reply, function(data) {
226 $('#profile-rotator').hide();
231 function jotVideoURL() {
232 reply = prompt("{{$vidurl}}");
233 if(reply && reply.length) {
234 addeditortext('[video]' + reply + '[/video]');
238 function jotAudioURL() {
239 reply = prompt("{{$audurl}}");
240 if(reply && reply.length) {
241 addeditortext('[audio]' + reply + '[/audio]');
246 function jotGetLocation() {
247 reply = prompt("{{$whereareu}}", $('#jot-location').val());
248 if(reply && reply.length) {
249 $('#jot-location').val(reply);
253 function jotShare(id) {
254 if ($('#jot-popup').length != 0) $('#jot-popup').show();
256 $('#like-rotator-' + id).show();
257 $.get('share/' + id, function(data) {
258 if (!editor) $("#profile-jot-text").val("");
259 initEditor(function(){
261 $('#like-rotator-' + id).hide();
262 $(window).scrollTop(0);
268 function linkdropper(event) {
269 var linkFound = event.dataTransfer.types.contains("text/uri-list");
271 event.preventDefault();
274 function linkdrop(event) {
275 var reply = event.dataTransfer.getData("text/uri-list");
276 event.target.textContent = reply;
277 event.preventDefault();
278 if(reply && reply.length) {
279 reply = bin2hex(reply);
280 $('#profile-rotator').show();
281 $.get('parse_url?binurl=' + reply, function(data) {
282 if (!editor) $("#profile-jot-text").val("");
283 initEditor(function(){
285 $('#profile-rotator').hide();
291 function itemTag(id) {
292 reply = prompt("{{$term}}");
293 if(reply && reply.length) {
294 reply = reply.replace('#','');
298 $('body').css('cursor', 'wait');
300 $.get('tagger/' + id + '?term=' + reply);
301 if(timer) clearTimeout(timer);
302 timer = setTimeout(NavUpdate,3000);
308 function itemFiler(id) {
310 var bordercolor = $("input").css("border-color");
312 $.get('filer/', function(data){
313 $.colorbox({html:data});
314 $("#id_term").keypress(function(){
315 $(this).css("border-color",bordercolor);
317 $("#select_term").change(function(){
318 $("#id_term").css("border-color",bordercolor);
321 $("#filer_save").click(function(e){
323 reply = $("#id_term").val();
324 if(reply && reply.length) {
326 $('body').css('cursor', 'wait');
327 $.get('filer/' + id + '?term=' + reply, NavUpdate);
328 // if(timer) clearTimeout(timer);
329 // timer = setTimeout(NavUpdate,3000);
333 $("#id_term").css("border-color","#FF0000");
341 function jotClearLocation() {
342 $('#jot-coord').val('');
343 $('#profile-nolocation-wrapper').hide();
346 function addeditortext(data) {
347 if(plaintext == 'none') {
348 var currentText = $("#profile-jot-text").val();
349 $("#profile-jot-text").val(currentText + data);
352 tinyMCE.execCommand('mceInsertRawHTML',false,data);