From c90b5f2d99b74c3f48f43edf1742db2ebf23da7f Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 24 Aug 2014 22:10:21 +0200 Subject: [PATCH] Added select all --- assets/js/init.js | 4 ++ assets/js/multiselect.js | 83 +++++++++++++++++++++++++++++----------- assets/min/main.js | 12 +++--- 3 files changed, 70 insertions(+), 29 deletions(-) diff --git a/assets/js/init.js b/assets/js/init.js index 531a423..88288ee 100755 --- a/assets/js/init.js +++ b/assets/js/init.js @@ -104,6 +104,10 @@ $(document).ready(function(){ .bind(['command+backspace', 'ctrl+backspace'], function() { if (visible.photo()&&!visible.message()) photo.delete([photo.getID()]); else if (visible.album()&&!visible.message()) album.delete([album.getID()]); + }) + .bind(['command+a', 'ctrl+a'], function() { + if (visible.album()&&!visible.message()) multiselect.selectAll(); + else if (visible.albums()&&!visible.message()) multiselect.selectAll(); }); Mousetrap.bindGlobal('enter', function() { diff --git a/assets/js/multiselect.js b/assets/js/multiselect.js index cca4ad1..c76068c 100644 --- a/assets/js/multiselect.js +++ b/assets/js/multiselect.js @@ -9,31 +9,68 @@ multiselect = { position: { - top: null, - right: null, - bottom: null, - left: null + top: null, + right: null, + bottom: null, + left: null }, show: function(e) { - if (mobileBrowser()) return false; - if (lychee.publicMode) return false; - if (visible.search()) return false; - if ($('.album:hover, .photo:hover').length!==0) return false; - if (visible.multiselect()) $('#multiselect').remove(); + if (mobileBrowser()) return false; + if (lychee.publicMode) return false; + if (visible.search()) return false; + if (visible.infobox()) return false; + if (!visible.albums()&&!visible.album) return false; + if ($('.album:hover, .photo:hover').length!==0) return false; + if (visible.multiselect()) $('#multiselect').remove(); - multiselect.position.top = e.pageY; - multiselect.position.right = -1 * (e.pageX - $(document).width()); - multiselect.position.bottom = -1 * (multiselect.position.top - $(window).height()); - multiselect.position.left = e.pageX; + multiselect.position.top = e.pageY; + multiselect.position.right = -1 * (e.pageX - $(document).width()); + multiselect.position.bottom = -1 * (multiselect.position.top - $(window).height()); + multiselect.position.left = e.pageX; $('body').append(build.multiselect(multiselect.position.top, multiselect.position.left)); $(document).on('mousemove', multiselect.resize); }, + selectAll: function() { + + var e; + + if (mobileBrowser()) return false; + if (lychee.publicMode) return false; + if (visible.search()) return false; + if (visible.infobox()) return false; + if (!visible.albums()&&!visible.album) return false; + if (visible.multiselect()) $('#multiselect').remove(); + + multiselect.position.top = 70; + multiselect.position.right = 40; + multiselect.position.bottom = 90; + multiselect.position.left = 20; + + $('body').append(build.multiselect(multiselect.position.top, multiselect.position.left)); + + newWidth = $(document).width() - multiselect.position.right + 2; + newHeight = $(document).height() - multiselect.position.bottom; + + $('#multiselect').css({ + width: newWidth, + height: newHeight + }); + + e = { + pageX: $(document).width() - (multiselect.position.right / 2), + pageY: $(document).height() - multiselect.position.bottom + } + + multiselect.getSelection(e); + + }, + resize: function(e) { var mouse_x = e.pageX, @@ -49,7 +86,7 @@ multiselect = { if (mouse_y>=multiselect.position.top) { // Do not leave the screen - newHeight = e.pageY - multiselect.position.top; + newHeight = mouse_y - multiselect.position.top; if ((multiselect.position.top+newHeight)>=$(document).height()) newHeight -= (multiselect.position.top + newHeight) - $(document).height() + 2; @@ -72,7 +109,7 @@ multiselect = { if (mouse_x>=multiselect.position.left) { // Do not leave the screen - newWidth = e.pageX - multiselect.position.left; + newWidth = mouse_x - multiselect.position.left; if ((multiselect.position.left+newWidth)>=$(document).width()) newWidth -= (multiselect.position.left + newWidth) - $(document).width() + 2; @@ -105,10 +142,10 @@ multiselect = { if (!visible.multiselect()) return false; return { - top: $('#multiselect').offset().top, - left: $('#multiselect').offset().left, - width: parseInt($('#multiselect').css('width').replace('px', '')), - height: parseInt($('#multiselect').css('height').replace('px', '')) + top: $('#multiselect').offset().top, + left: $('#multiselect').offset().left, + width: parseInt($('#multiselect').css('width').replace('px', '')), + height: parseInt($('#multiselect').css('height').replace('px', '')) }; }, @@ -156,10 +193,10 @@ multiselect = { multiselect.stopResize(); - multiselect.position.top = null; - multiselect.position.right = null; - multiselect.position.bottom = null; - multiselect.position.left = null; + multiselect.position.top = null; + multiselect.position.right = null; + multiselect.position.bottom = null; + multiselect.position.left = null; lychee.animate('#multiselect', 'fadeOut'); setTimeout(function() { diff --git a/assets/min/main.js b/assets/min/main.js index 63323db..6d7bc41 100644 --- a/assets/min/main.js +++ b/assets/min/main.js @@ -1,6 +1,6 @@ -function mobileBrowser(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)?!0:!1}function gup(e){e=e.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var t="[\\?&]"+e+"=([^&#]*)",n=new RegExp(t),o=n.exec(window.location.href);return null===o?"":o[1]}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=J.type(e);return"function"===n||J.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function o(e,t,n){if(J.isFunction(t))return J.grep(e,function(e,o){return!!t.call(e,o,e)!==n});if(t.nodeType)return J.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return J.filter(t,e,n);t=J.filter(t,e)}return J.grep(e,function(e){return z.call(t,e)>=0!==n})}function i(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function a(e){var t=ft[e]={};return J.each(e.match(ht)||[],function(e,n){t[n]=!0}),t}function r(){Q.removeEventListener("DOMContentLoaded",r,!1),e.removeEventListener("load",r,!1),J.ready()}function s(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=J.expando+Math.random()}function l(e,t,n){var o;if(void 0===n&&1===e.nodeType)if(o="data-"+t.replace(wt,"-$1").toLowerCase(),n=e.getAttribute(o),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:yt.test(n)?J.parseJSON(n):n}catch(i){}bt.set(e,t,n)}else n=void 0;return n}function u(){return!0}function c(){return!1}function d(){try{return Q.activeElement}catch(e){}}function p(e,t){return J.nodeName(e,"table")&&J.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function h(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function f(e){var t=Lt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n=0,o=e.length;o>n;n++)vt.set(e[n],"globalEval",!t||vt.get(t[n],"globalEval"))}function g(e,t){var n,o,i,a,r,s,l,u;if(1===t.nodeType){if(vt.hasData(e)&&(a=vt.access(e),r=vt.set(t,a),u=a.events)){delete r.handle,r.events={};for(i in u)for(n=0,o=u[i].length;o>n;n++)J.event.add(t,i,u[i][n])}bt.hasData(e)&&(s=bt.access(e),l=J.extend({},s),bt.set(t,l))}}function v(e,t){var n=e.getElementsByTagName?e.getElementsByTagName(t||"*"):e.querySelectorAll?e.querySelectorAll(t||"*"):[];return void 0===t||t&&J.nodeName(e,t)?J.merge([e],n):n}function b(e,t){var n=t.nodeName.toLowerCase();"input"===n&&kt.test(e.type)?t.checked=e.checked:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}function y(t,n){var o,i=J(n.createElement(t)).appendTo(n.body),a=e.getDefaultComputedStyle&&(o=e.getDefaultComputedStyle(i[0]))?o.display:J.css(i[0],"display");return i.detach(),a}function w(e){var t=Q,n=Rt[e];return n||(n=y(e,t),"none"!==n&&n||(qt=(qt||J("