diff options
Diffstat (limited to 'view/js')
-rw-r--r-- | view/js/acl.js | 95 | ||||
-rw-r--r-- | view/js/main.js | 2 | ||||
-rw-r--r-- | view/js/mod_cloud.js | 216 | ||||
-rw-r--r-- | view/js/mod_filestorage.js | 15 | ||||
-rw-r--r-- | view/js/mod_photos.js | 16 | ||||
-rw-r--r-- | view/js/mod_webpages.js | 15 |
6 files changed, 63 insertions, 296 deletions
diff --git a/view/js/acl.js b/view/js/acl.js index 411190ac9..79699c589 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -1,17 +1,15 @@ -function ACL(backend_url) { +function ACL(backend_url, preset) { that = this; that.url = backend_url; that.kp_timer = null; - that.self = []; - - that.allow_cid = []; - that.allow_gid = []; - that.deny_cid = []; - that.deny_gid = []; - + if (preset === undefined) preset = []; + that.allow_cid = (preset[0] || []); + that.allow_gid = (preset[1] || []); + that.deny_cid = (preset[2] || []); + that.deny_gid = (preset[3] || []); that.group_uids = []; that.info = $("#acl-info"); @@ -23,8 +21,11 @@ function ACL(backend_url) { that.showlimited = $("#acl-showlimited"); that.acl_select = $("#acl-select"); + that.preset = preset; + that.self = []; + // set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes. - //that.on_submit(); + that.on_submit(); /*events*/ @@ -46,10 +47,6 @@ function ACL(backend_url) { } }); - $(document).on('focus', '.acl-form', that.get_form_data); - $(document).on('click', '.acl-form', that.get_form_data); - $(document).on('click', '.acl-form-trigger', that.get_form_data); - $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); @@ -57,50 +54,29 @@ function ACL(backend_url) { /* startup! */ that.get(0,15000); - //that.on_submit(); - }); -} - - -ACL.prototype.get_form_data = function(event) { - - form_id = $(this).data('form_id'); - that.form_id = $('#' + form_id); - - that.allow_cid = (that.form_id.data('allow_cid') || []); - that.allow_gid = (that.form_id.data('allow_gid') || []); - that.deny_cid = (that.form_id.data('deny_cid') || []); - that.deny_gid = (that.form_id.data('deny_gid') || []); - - that.update_view(); that.on_submit(); - + }); } // no longer called only on submit - call to update whenever a change occurs to the acl list. -ACL.prototype.on_submit = function() { - - $('.acl-field').remove(); +ACL.prototype.on_submit = function() { + aclfields = $("#acl-fields").html(""); $(that.allow_gid).each(function(i,v) { - that.form_id.append("<input class='acl-field' type='hidden' name='group_allow[]' value='"+v+"'>"); + aclfields.append("<input type='hidden' name='group_allow[]' value='"+v+"'>"); }); $(that.allow_cid).each(function(i,v) { - that.form_id.append("<input class='acl-field' type='hidden' name='contact_allow[]' value='"+v+"'>"); + aclfields.append("<input type='hidden' name='contact_allow[]' value='"+v+"'>"); }); $(that.deny_gid).each(function(i,v) { - that.form_id.append("<input class='acl-field' type='hidden' name='group_deny[]' value='"+v+"'>"); + aclfields.append("<input type='hidden' name='group_deny[]' value='"+v+"'>"); }); $(that.deny_cid).each(function(i,v) { - that.form_id.append("<input class='acl-field' type='hidden' name='contact_deny[]' value='"+v+"'>"); - }); - - var formfields = $('.profile-jot-net input').serializeArray(); - - $.each(formfields, function(i, field) { - that.form_id.append("<input class='acl-field' type='hidden' name='"+field.name+"' value='"+field.value+"'>"); + aclfields.append("<input type='hidden' name='contact_deny[]' value='"+v+"'>"); }); + //areYouSure jquery plugin: recheck the form here + $('form').trigger('checkform.areYouSure'); }; ACL.prototype.search = function() { @@ -125,7 +101,6 @@ ACL.prototype.on_onlyme = function(event) { that.deny_cid = []; that.deny_gid = []; - that.update_view(event.target.value); that.on_submit(); @@ -151,14 +126,14 @@ ACL.prototype.on_showlimited = function(event) { // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton event.stopPropagation(); - if(that.allow_cid.length === 0 && that.allow_gid.length === 0 && that.deny_cid.length === 0 && that.deny_gid.length === 0) { - that.allow_cid = [that.self[0]]; + if(that.preset[0].length === 0 && that.preset[1].length === 0 && that.preset[2].length === 0 && that.preset[3].length === 0) { + that.preset[0] = [that.self[0]]; } - that.allow_cid = (that.allow_cid || []); - that.allow_gid = (that.allow_gid || []); - that.deny_cid = (that.deny_cid || []); - that.deny_gid = (that.deny_gid || []); + that.allow_cid = (that.preset[0] || []); + that.allow_gid = (that.preset[1] || []); + that.deny_cid = (that.preset[2] || []); + that.deny_gid = (that.preset[3] || []); that.update_view(event.target.value); that.on_submit(); @@ -264,19 +239,13 @@ ACL.prototype.set_deny = function(itemid) { that.update_view(); }; -ACL.prototype.update_select = function(set) { - that.showall.prop('selected', set === 'public'); - that.onlyme.prop('selected', set === 'onlyme'); - that.showlimited.prop('selected', set === 'limited'); +ACL.prototype.update_select = function(preset) { + that.showall.prop('selected', preset === 'public'); + that.onlyme.prop('selected', preset === 'onlyme'); + that.showlimited.prop('selected', preset === 'limited'); }; ACL.prototype.update_view = function(value) { - if(that.form_id) { - that.form_id.data('allow_cid', that.allow_cid); - that.form_id.data('allow_gid', that.allow_gid); - that.form_id.data('deny_cid', that.deny_cid); - that.form_id.data('deny_gid', that.deny_gid); - } if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { that.list.hide(); //hide acl-list @@ -290,8 +259,8 @@ ACL.prototype.update_view = function(value) { } // if value != 'onlyme' we should fall through this one - else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value !== 'limited') { - that.list.hide(); //hide acl-list + else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'onlyme') { + that.list.hide(); //hide acl-list if that.info.hide(); //show acl-info that.update_select('onlyme'); @@ -394,5 +363,5 @@ ACL.prototype.populate = function(data) { $(el).attr('src', $(el).data("src")); $(el).removeAttr("data-src"); }); - //that.update_view(); + that.update_view(); }; diff --git a/view/js/main.js b/view/js/main.js index c80163e72..a288f98f5 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1015,6 +1015,8 @@ function filestorage(event, nick, id) { $('#cloud-index-' + last_filestorage_id).removeClass('cloud-index-active'); $('#perms-panel-' + last_filestorage_id).hide().html(''); $('#file-edit-' + id).spin('tiny'); + // What for do we need this here? + delete acl; $.get('filestorage/' + nick + '/' + id + '/edit', function(data) { $('#cloud-index-' + id).addClass('cloud-index-active'); $('#perms-panel-' + id).html(data).show(); diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js deleted file mode 100644 index 8b8a3ba3f..000000000 --- a/view/js/mod_cloud.js +++ /dev/null @@ -1,216 +0,0 @@ -/** - * JavaScript for mod/cloud - */ - -$(document).ready(function () { - // call initialization file - if (window.File && window.FileList && window.FileReader) { - UploadInit(); - } -}); - -// -// initialize -function UploadInit() { - - var fileselect = $("#files-upload"); - var filedrag = $("#cloud-drag-area"); - var submit = $("#upload-submit"); - - // is XHR2 available? - var xhr = new XMLHttpRequest(); - if (xhr.upload) { - - // file select - fileselect.attr("multiple", 'multiple'); - fileselect.on("change", UploadFileSelectHandler); - - // file submit - submit.on("click", fileselect, UploadFileSelectHandler); - - // file drop - filedrag.on("dragover", DragDropUploadFileHover); - filedrag.on("dragleave", DragDropUploadFileHover); - filedrag.on("drop", DragDropUploadFileSelectHandler); - } - - window.filesToUpload = 0; - window.fileUploadsCompleted = 0; -} - -// file drag hover -function DragDropUploadFileHover(e) { - e.stopPropagation(); - e.preventDefault(); - e.currentTarget.className = (e.type == "dragover" ? "hover" : ""); -} - -// file selection via drag/drop -function DragDropUploadFileSelectHandler(e) { - // cancel event and hover styling - DragDropUploadFileHover(e); - - // fetch FileList object - var files = e.target.files || e.originalEvent.dataTransfer.files; - - $('.new-upload').remove(); - - // process all File objects - for (var i = 0, f; f = files[i]; i++) { - prepareHtml(f, i); - UploadFile(f, i); - } -} - -// file selection via input -function UploadFileSelectHandler(e) { - // fetch FileList object - if(e.target.id === 'upload-submit') { - e.preventDefault(); - var files = e.data[0].files; - } - if(e.target.id === 'files-upload') { - $('.new-upload').remove(); - var files = e.target.files; - } - - // process all File objects - for (var i = 0, f; f = files[i]; i++) { - if(e.target.id === 'files-upload') - prepareHtml(f, i); - if(e.target.id === 'upload-submit') { - UploadFile(f, i); - } - } -} - -function prepareHtml(f, i) { - var num = i - 1; - $('#cloud-index #new-upload-progress-bar-' + num.toString()).after( - '<tr id="new-upload-' + i + '" class="new-upload">' + - '<td><i class="fa ' + getIconFromType(f.type) + '" title="' + f.type + '"></i></td>' + - '<td>' + f.name + '</td>' + - '<td id="upload-progress-' + i + '"></td><td></td><td></td><td></td><td></td>' + - '<td class="hidden-xs">' + formatSizeUnits(f.size) + '</td><td class="hidden-xs"></td>' + - '</tr>' + - '<tr id="new-upload-progress-bar-' + i + '" class="new-upload">' + - '<td id="upload-progress-bar-' + i + '" colspan="9" class="upload-progress-bar"></td>' + - '</tr>' - ); -} - -function formatSizeUnits(bytes){ - if (bytes>=1000000000) {bytes=(bytes/1000000000).toFixed(2)+' GB';} - else if (bytes>=1000000) {bytes=(bytes/1000000).toFixed(2)+' MB';} - else if (bytes>=1000) {bytes=(bytes/1000).toFixed(2)+' KB';} - else if (bytes>1) {bytes=bytes+' bytes';} - else if (bytes==1) {bytes=bytes+' byte';} - else {bytes='0 byte';} - return bytes; -} - -// this is basically a js port of include/text.php getIconFromType() function -function getIconFromType(type) { - var map = { - //Common file - 'application/octet-stream': 'fa-file-o', - //Text - 'text/plain': 'fa-file-text-o', - 'application/msword': 'fa-file-word-o', - 'application/pdf': 'fa-file-pdf-o', - 'application/vnd.oasis.opendocument.text': 'fa-file-word-o', - 'application/epub+zip': 'fa-book', - //Spreadsheet - 'application/vnd.oasis.opendocument.spreadsheet': 'fa-file-excel-o', - 'application/vnd.ms-excel': 'fa-file-excel-o', - //Image - 'image/jpeg': 'fa-picture-o', - 'image/png': 'fa-picture-o', - 'image/gif': 'fa-picture-o', - 'image/svg+xml': 'fa-picture-o', - //Archive - 'application/zip': 'fa-file-archive-o', - 'application/x-rar-compressed': 'fa-file-archive-o', - //Audio - 'audio/mpeg': 'fa-file-audio-o', - 'audio/mp3': 'fa-file-audio-o', //webkit browsers need that - 'audio/wav': 'fa-file-audio-o', - 'application/ogg': 'fa-file-audio-o', - 'audio/ogg': 'fa-file-audio-o', - 'audio/webm': 'fa-file-audio-o', - 'audio/mp4': 'fa-file-audio-o', - //Video - 'video/quicktime': 'fa-file-video-o', - 'video/webm': 'fa-file-video-o', - 'video/mp4': 'fa-file-video-o', - 'video/x-matroska': 'fa-file-video-o' - }; - - var iconFromType = 'fa-file-o'; - - if (type in map) { - iconFromType = map[type]; - } - - return iconFromType; -} - -// upload files -function UploadFile(file, idx) { - - window.filesToUpload = window.filesToUpload + 1; - - var xhr = new XMLHttpRequest(); - - xhr.withCredentials = true; // Include the SESSION cookie info for authentication - - (xhr.upload || xhr).addEventListener('progress', function (e) { - - var done = e.position || e.loaded; - var total = e.totalSize || e.total; - // Dynamically update the percentage complete displayed in the file upload list - $('#upload-progress-' + idx).html(Math.round(done / total * 100) + '%'); - $('#upload-progress-bar-' + idx).css('background-size', Math.round(done / total * 100) + '%'); - - if(done == total) { - $('#upload-progress-' + idx).html('Processing...'); - } - - }); - - - xhr.addEventListener('load', function (e) { - //we could possibly turn the filenames to real links here and add the delete and edit buttons to avoid page reload... - $('#upload-progress-' + idx).html('Ready!'); - - //console.log('xhr upload complete', e); - window.fileUploadsCompleted = window.fileUploadsCompleted + 1; - - // When all the uploads have completed, refresh the page - if (window.filesToUpload > 0 && window.fileUploadsCompleted === window.filesToUpload) { - - window.fileUploadsCompleted = window.filesToUpload = 0; - - // After uploads complete, refresh browser window to display new files - window.location.href = window.location.href; - } - }); - - - xhr.addEventListener('error', function (e) { - $('#upload-progress-' + idx).html('<span style="color: red;">ERROR</span>'); - }); - - // POST to the entire cloud path - xhr.open('post', 'file_upload', true); - - var formfields = $("#ajax-upload-files").serializeArray(); - - var data = new FormData(); - $.each(formfields, function(i, field) { - data.append(field.name, field.value); - }); - data.append('userfile', file); - - xhr.send(data); -} diff --git a/view/js/mod_filestorage.js b/view/js/mod_filestorage.js index 4f58af9d5..c0620c928 100644 --- a/view/js/mod_filestorage.js +++ b/view/js/mod_filestorage.js @@ -1,4 +1,17 @@ /** * JavaScript used by mod/filestorage */ - +$(document).ready(function() { + $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { + var selstr; + $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { + selstr = $(this).text(); + $('#jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); + $('#jot-public').hide(); + }); + if(selstr === null) { + $('#jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); + $('#jot-public').show(); + } + }).trigger('change'); +});
\ No newline at end of file diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index cbc1d8fa1..e3df3ca68 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -7,7 +7,21 @@ $(document).ready(function() { $("#photo-edit-newtag").val('@' + data.name); }); - $('textarea').bbco_autocomplete('bbcode'); + $('#id_body').bbco_autocomplete('bbcode'); + + $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { + var selstr; + $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { + selstr = $(this).text(); + $('#jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); + $('#jot-public').hide(); + }); + if(selstr === null) { + $('#jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); + $('#jot-public').show(); + } + }).trigger('change'); + showHideBodyTextarea(); }); diff --git a/view/js/mod_webpages.js b/view/js/mod_webpages.js deleted file mode 100644 index 7cfe297e1..000000000 --- a/view/js/mod_webpages.js +++ /dev/null @@ -1,15 +0,0 @@ -$(document).ready(function() { - $("input[type=\"checkbox\"]").hide(); -}); - -window.isChecked = true; - -function checkedAll(isChecked) { - window.isChecked = !window.isChecked ; - var c = document.getElementsByTagName('input'); - for (var i = 0; i < c.length; i++){ - if (c[i].type == 'checkbox'){ - c[i].checked = isChecked; - } - } -}
\ No newline at end of file |