diff --git a/templates/files.html b/templates/files.html index ab06378..fc0f84d 100644 --- a/templates/files.html +++ b/templates/files.html @@ -1,14 +1,5 @@ {% extends "base.html" %} {% block main_content %} - -
@@ -163,7 +154,7 @@ {% endif %} {% if obj.type.name != "Directory" %} {% if (not folders) or ((obj.in_dir.in_path.path_prefix+'/'+obj.in_dir.rel_path+'/'+obj.name) | TopLevelFolderOf(cwd)) %} -
+
{% if obj.type.name=="Image" %}
@@ -226,8 +217,17 @@ function GetSelnAsDiv() return '
'+seln+'
' } +function GetSelnAsData() +{ + to_del='' + $('.highlight').each(function( index ) { to_del+='&eid-'+index+'='+$(this).attr('id') } ) + return to_del +} + function DelDBox() { + to_del = GetSelnAsData() + console.log(to_del) $('#dbox-title').html('Delete Selected File(s)') div =`
@@ -237,7 +237,9 @@ function DelDBox() div+=`
- +
` $('#dbox-content').html(div) @@ -266,7 +268,7 @@ function MoveDBox()
- +
` @@ -316,79 +318,41 @@ function DoSel(e, el) $('.figure').click( function(e) { DoSel(e, this ); return false; }); $(document).on('click', function(e) { $('.highlight').removeClass('highlight') }); -(function ($, window) { - - $.fn.contextMenu = function (settings) { - - return this.each(function () { - - // Open context menu - $(this).on("contextmenu", function (e) { - // return native menu if pressing control - if (e.ctrlKey) return; - - fd=$(e.target).closest(".figure").attr('details') - $('#dd_file_details').text(fd) - //open menu - var $menu = $(settings.menuSelector) - .data("invokedOn", $(e.target)) - .show() - .css({ - position: "absolute", - left: getMenuPosition(e.clientX, 'width', 'scrollLeft'), - top: getMenuPosition(e.clientY, 'height', 'scrollTop') - }) - .off('click') - .on('click', 'a', function (e) { - $menu.hide(); - var $invokedOn = $menu.data("invokedOn"); - var $selectedMenu = $(e.target); - settings.menuSelected.call(this, $invokedOn, $selectedMenu); - }); - return false; - }); - - //make sure menu closes on any click - $('body').click(function () { - $(settings.menuSelector).hide(); - }); - }); - - function getMenuPosition(mouse, direction, scrollDir) { - var win = $(window)[direction](), - scroll = $(window)[scrollDir](), - menu = $(settings.menuSelector)[direction](), - position = mouse + scroll; - // opening menu would pass the side of the page - if (mouse + menu > win && menu < mouse) - position -= menu; - return position; +$.contextMenu({ + selector: '.figure', + build: function($triggerElement, e){ + if (e.currentTarget.getAttribute('path_type') == 'Bin' ) { + item_list = { + details: { name: "Details..." }, + view: { name: "View File" }, + sep: "---", + move: { name: "Move selected file(s) to new storage folder" }, + undel: { name: "Undelete Selected file(s)" } + } + } else { + item_list = { + details: { name: "Details..." }, + view: { name: "View File" }, + sep: "---", + move: { name: "Move selected file(s) to new storage folder" }, + del: { name: "Delete Selected file(s)" } + } } - }; -})(jQuery, window); - -{# for now if we have no data, dont peak inside the first element to see if we are viewing the Bin folder and then swich the context menu #} -{% if entry_data|length > 0 %} - if( "{{entry_data[0].in_dir.in_path.type.name}}" == "Bin" ) { - $('#dd_del').hide() - } else { - $('#dd_undel').hide() - } -{% endif %} - -$(".figure").contextMenu({ - menuSelector: "#contextMenu", - menuSelected: function (invokedOn, selectedMenu) { - var msg = "You selected the menu item '" + selectedMenu.text() + - "' on the file id: " + $(invokedOn).parent().parent().parent().attr('id') - console.log(msg); - if ( "View File" == selectedMenu.text() ) { - document.location.href = $(invokedOn).parent().attr('href') - } + return { + callback: function( key, options) { + console.log( $(this).attr('id') ) + console.log( $(this).attr('path_type') ) + if( key == "view" ) { + document.location.href = $(this).find('a').attr('href'); + } + }, + items: item_list + }; } }); + $(document).ready(function() { if( {{offset}} == 0 ) {