2 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js" ></script>
4 <script type="text/javascript">
8 function initEditor(callback) {
10 $("#profile-jot-text-loading").show();
11 $("#profile-jot-text-loading").hide();
12 //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
13 $("#jot-category").show();
14 $("#jot-category").addClass("jot-category-ex");
15 $("#jot-profile-jot-wrapper").show();
16 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
17 $("#profile-jot-text").bbco_autocomplete('bbcode');
18 $("a#jot-perms-icon").colorbox({
20 'transition' : 'elastic'
22 $(".jothidden").show();
23 $("#profile-jot-text").keyup(function(){
24 var textlen = $(this).val().length;
25 $('#character-counter').text(textlen);
30 if (typeof callback != "undefined") {
35 function enableOnUser(){
40 <script type="text/javascript">
41 var ispublic = '{{$ispublic}}';
44 $(document).ready(function() {
46 /* enable editor on focus and click */
47 $("#profile-jot-text").focus(enableOnUser);
48 $("#profile-jot-text").click(enableOnUser);
50 // When clicking on a forum in acl we should remove the profile jot textarea
51 // default value before inserting the forum mention
52 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
53 jotTextOpenUI(document.getElementById("profile-jot-text"));
57 /* show images / file browser window
62 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
63 ///@todo this part isn't ideal and need to be done in a better way
64 jotTextOpenUI(document.getElementById("profile-jot-text"));
66 addeditortext(embedcode);
68 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
69 jotTextOpenUI(document.getElementById("profile-jot-text"));
71 addeditortext(embedcode);
74 $('#wall-image-upload').on('click', function(){
75 Dialog.doImageBrowser("main");
79 $('#wall-file-upload').on('click', function(){
80 Dialog.doFileBrowser("main");
85 function deleteCheckedItems() {
86 if(confirm('{{$delitems}}')) {
88 var ItemsToDelete = {};
90 $("#item-delete-selected").hide();
91 $('#item-delete-selected-rotator').show();
92 $('body').css('cursor', 'wait');
94 $('.item-select').each( function() {
95 if($(this).is(':checked')) {
96 if(checkedstr.length != 0) {
97 checkedstr = checkedstr + ',' + $(this).val();
98 var deleteItem = this.closest(".wall-item-container");
99 ItemsToDelete[deleteItem.id] = deleteItem;
102 checkedstr = $(this).val();
105 // Get the corresponding item container
106 var deleteItem = this.closest(".wall-item-container");
107 ItemsToDelete[deleteItem.id] = deleteItem;
111 // Fade the the the container from the items we want to delete
112 for(var key in ItemsToDelete) {
113 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
116 $.post('item', { dropitems: checkedstr }, function(data) {
118 // Loop through the ItemsToDelete Object and remove
119 // corresponding item div
120 for(var key in ItemsToDelete) {
121 $(ItemsToDelete[key]).remove();
123 $('body').css('cursor', 'auto');
124 $('#item-delete-selected-rotator').hide();
129 function jotGetLink() {
130 reply = prompt("{{$linkurl}}");
131 if(reply && reply.length) {
132 reply = bin2hex(reply);
133 $('#profile-rotator').show();
134 $.get('parse_url?binurl=' + reply, function(data) {
136 $('#profile-rotator').hide();
141 function jotVideoURL() {
142 reply = prompt("{{$vidurl}}");
143 if(reply && reply.length) {
144 addeditortext('[video]' + reply + '[/video]');
148 function jotAudioURL() {
149 reply = prompt("{{$audurl}}");
150 if(reply && reply.length) {
151 addeditortext('[audio]' + reply + '[/audio]');
156 function jotGetLocation() {
157 reply = prompt("{{$whereareu}}", $('#jot-location').val());
158 if(reply && reply.length) {
159 $('#jot-location').val(reply);
163 function jotShare(id) {
164 $.get('share/' + id, function(data) {
165 // remove the former content of the text input
166 $("#profile-jot-text").val("");
167 initEditor(function(){
174 $("#jot-popup").show();
177 function linkdropper(event) {
178 var linkFound = event.dataTransfer.types.contains("text/uri-list");
180 event.preventDefault();
183 function linkdrop(event) {
184 var reply = event.dataTransfer.getData("text/uri-list");
185 event.target.textContent = reply;
186 event.preventDefault();
187 if(reply && reply.length) {
188 reply = bin2hex(reply);
189 $('#profile-rotator').show();
190 $.get('parse_url?binurl=' + reply, function(data) {
191 if (!editor) $("#profile-jot-text").val("");
192 initEditor(function(){
194 $('#profile-rotator').hide();
200 function itemTag(id) {
201 reply = prompt("{{$term}}");
202 if(reply && reply.length) {
203 reply = reply.replace('#','');
207 $('body').css('cursor', 'wait');
209 $.get('tagger/' + id + '?term=' + reply);
210 if(timer) clearTimeout(timer);
211 timer = setTimeout(NavUpdate,3000);
217 function itemFiler(id) {
219 var bordercolor = $("input").css("border-color");
221 $.get('filer/', function(data){
222 $.colorbox({html:data});
223 $("#id_term").keypress(function(){
224 $(this).css("border-color",bordercolor);
226 $("#select_term").change(function(){
227 $("#id_term").css("border-color",bordercolor);
230 $("#filer_save").click(function(e){
232 reply = $("#id_term").val();
233 if(reply && reply.length) {
235 $('body').css('cursor', 'wait');
236 $.get('filer/' + id + '?term=' + reply, NavUpdate);
237 // if(timer) clearTimeout(timer);
238 // timer = setTimeout(NavUpdate,3000);
242 $("#id_term").css("border-color","#FF0000");
250 function jotClearLocation() {
251 $('#jot-coord').val('');
252 $('#profile-nolocation-wrapper').hide();
255 function addeditortext(data) {
257 var textfield = document.getElementById("profile-jot-text");
258 // check if the textfield does have the default-value
259 jotTextOpenUI(textfield);
260 // save already existent content
261 var currentText = $("#profile-jot-text").val();
262 //insert the data as new value
263 textfield.value = currentText + data;
269 var modal = $('#jot-modal').modal();
270 jotcache = $("#jot-sections");
272 // Auto focus on the first enabled field in the modal
273 modal.on('shown.bs.modal', function (e) {
274 $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
278 .find('#jot-modal-content')
283 // Activate the jot text section in the jot modal
284 function jotActive() {
285 // Make sure jot text does have really the active class (we do this because there are some
286 // other events which trigger jot text (we need to do this for the desktop and mobile
288 var elem = $("#jot-modal .jot-nav #jot-text-lnk");
289 var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
290 toggleJotNav(elem[0]);
291 toggleJotNav(elemMobile[0]);