diff --git a/HELP.md b/HELP.md
index dd71a8b7..970e7a6c 100644
--- a/HELP.md
+++ b/HELP.md
@@ -89,7 +89,7 @@ Hot keys
| `End` | to end of list
| `Space` | select current file (and get size of directory)
| `Insert` | select current file (and move to next)
-| `Shift + F10` | context menu
+| `F9` | context menu
| `~` | console
| `Ctrl + Click` | open file on new tab
@@ -335,7 +335,6 @@ To extend capabilities of file manager next modules used:
- [Diff-Match-Patch] [Diff-Match-PatchURL]
- [Minify] [MinifyURL]
- [FancyBox] [FancyBoxURL]
-- [jQuery-contextMenu] [jQuery-contextMenuURL]
- [jq-console] [jq-consoleURL]
- [github] [githubURL]
- [dropbox-js] [dropbox-jsURL]
@@ -349,7 +348,6 @@ To extend capabilities of file manager next modules used:
[Diff-Match-PatchURL]: https://code.google.com/p/google-diff-match-patch/ "Diff-Match-Patch"
[MinifyURL]: http://coderaiser.github.io/minify "Minify"
[FancyBoxURL]: //github.com/fancyapps/fancyBox "FancyBox"
-[jQuery-contextMenuURL]: //github.com/medialize/jQuery-contextMenu "jQuery-contextMenu"
[jq-consoleURL]: //github.com/replit/jq-console "jq-console"
[githubURL]: //github.com/michael/github "github"
[dropbox-jsURL]: //github.com/dropbox/dropbox-js "dropbox-js"
diff --git a/lib/client/menu.js b/lib/client/menu.js
index e6581b2b..042305c7 100644
--- a/lib/client/menu.js
+++ b/lib/client/menu.js
@@ -1,7 +1,4 @@
-/* object contains jQuery-contextMenu
- * https://github.com/medialize/jQuery-contextMenu
- */
-var CloudCmd, Util, DOM, CloudFunc, $;
+var CloudCmd, Util, DOM, CloudFunc, MenuIO;
(function(CloudCmd, Util, DOM, CloudFunc) {
'use strict';
@@ -11,11 +8,12 @@ var CloudCmd, Util, DOM, CloudFunc, $;
function MenuProto(position) {
var Name = 'Menu',
Info = DOM.CurrentInfo,
- Loading = false,
+ Loading = true,
Key = CloudCmd.Key,
Events = DOM.Events,
MenuSeted = false,
Menu = this,
+ MenuContext,
Position = CloudCmd.MousePosition,
Images = DOM.Images,
UploadToItemNames;
@@ -26,125 +24,113 @@ var CloudCmd, Util, DOM, CloudFunc, $;
Loading = true;
Util.loadOnLoad([
- DOM.jqueryLoad,
load,
- setUploadToItemNames,
+ //setUploadToItemNames,
Menu.show
]);
Events.addKey(listener);
}
- this.show = function() {
- Key.unsetBind();
+ this.hide = function() {
+ MenuContext.hide();
+ };
+
+ this.show = function() {
+ var fm, options, menuData,
+ x = (position || Position).x,
+ y = (position || Position).y;
if (!Loading) {
- if (!MenuSeted) {
- $.contextMenu(getConfig());
- MenuSeted = true;
- }
+ Key.unsetBind();
+ MenuContext.show(x, y);
+ } else {
+ fm = DOM.getFM();
+ options = {
+ icon : true,
+ beforClose : Key.setBind,
+ beforShow : Key.unsetBind
+ };
+ menuData = getMenuData();
+ MenuContext = MenuIO(fm, options, menuData);
- Images.hide();
-
- $('li').contextMenu(position || Position);
- position = null;
+ MenuContext.show(x, y);
+ Loading = false;
+ position = null;
}
};
- /* function read data from modules.json
- * and build array of menu items of "upload to"
- * menu
- */
- function setUploadToItemNames(callback) {
- CloudCmd.getModules(function(pModules) {
- var lStorageObj = Util.findObjByNameInArr( pModules, 'storage' );
- UploadToItemNames = Util.getNamesFromObjArray( lStorageObj ) || [];
+ function getMenuData() {
+ var show = function(name) {
+ CloudCmd[name].show();
+ },
+ menuData = {
+ 'View' : Util.bind(show, 'View'),
+ 'Edit' : Util.bind(show, 'Edit'),
+ 'Rename' : function() {
+ setTimeout(DOM.renameCurrent, 100);
+ },
+ 'Delete' : DOM.promptDelete,
+ '(Un)Select All': DOM.toggleAllSelectedFiles,
+ 'Zip file' : DOM.zipFile,
+ 'Unzip file' : DOM.unzipFile,
+ 'Upload To' : {},
+ 'Download' : download,
+ 'New' : {
+ 'File' : DOM.promptNewFile,
+ 'Directory' : DOM.promptNewDir,
+ 'From FilePicker' : getFromPicker
+ }
+ };
+
+ getUploadTo(function(menuUpload) {
+ menuData['Upload To'] = menuUpload;
+
+ });
+
+ return menuData;
+ }
+
+ function getUploadTo(callback) {
+ CloudCmd.getModules(function(modules) {
+ var menu = {},
+ storage = Util.findObjByNameInArr(modules, 'storage'),
+ items = Util.getNamesFromObjArray(storage) || [];
+
+ items.forEach(function(name) {
+ menu[name] = Util.bind(uploadTo, name);
+ });
- Util.exec(callback);
+ callback(menu);
});
}
- /**
- * function get menu item object for Upload To
- */
- function getUploadToItems(items) {
- var str, func,
- type = Util.getType(name),
- obj = {};
-
- switch(type) {
- case 'array':
- items.forEach(function(item) {
- str = item;
- obj[str] = getUploadToItems(str);
+ function uploadTo(name) {
+ Info.getData(function(data) {
+ var name = Info.name;
+
+ CloudCmd.execFromModule(name, 'uploadFile', {
+ name: name,
+ data: data
});
- break;
-
- case 'string':
- func = function() {
- Info.getData(function(data) {
- var name = Info.name;
-
- CloudCmd.execFromModule(items, 'uploadFile', {
- name: name,
- data: data
- });
- });
+ });
- Util.log('Uploading to ' + name + '...');
- };
- break;
- }
-
- return func || obj;
- }
-
- /**
- * get menu item
- */
- function getItem(name, callback) {
- var ret,
- icon = Util.convertName(name);
-
- ret = {
- name : name,
- icon : icon
- };
-
- if (Util.isFunction(callback))
- ret.callback = callback;
-
- else if (Util.isObject(callback))
- if (callback.name)
- ret.items = callback;
- else
- ret.items = getAllItems(callback);
-
- return ret;
+ Util.log('Uploading to ' + name + '...');
}
- /**
- * get all menu items
- * pItems = [{pName, pFunc}]
- */
- function getAllItems(pItems) {
- var lRet = {},
- lName,
- lFunc;
+ function getFromPicker() {
+ Images.showLoad({
+ top: true
+ });
- if (pItems)
- for (lName in pItems) {
- lFunc = pItems[lName];
- lRet[lName] = getItem(lName, lFunc);
- }
-
- return lRet;
- }
+ CloudCmd.execFromModule('FilePicker', 'saveFile', function(name, data) {
+ var path = DOM.getCurrentDirPath() + name;
+
+ DOM.RESTful.write(path, data, CloudCmd.refresh);
+ });
+ }
- /**
- * download menu item callback
- */
- function downloadFromMenu() {
+ function download() {
var element,
TIME = 1000,
date = Date.now(),
@@ -169,73 +155,6 @@ var CloudCmd, Util, DOM, CloudFunc, $;
}, TIME);
}
- /**
- * function return configureation for menu
- */
- function getConfig () {
- var ret,
- show = function(name) {
- var module = CloudCmd[name],
- ret = Util.exec(module);
-
- if (!ret)
- Util.exec(module.show);
- },
- menuItems = {
- 'View' : Util.bind(show, 'View'),
- 'Edit' : Util.bind(show, 'Edit'),
- 'Rename' : function() {
- setTimeout(DOM.renameCurrent, 100);
- },
- 'Delete' : DOM.promptDelete,
- '(Un)Select All': DOM.toggleAllSelectedFiles,
- 'Zip file' : DOM.zipFile,
- 'Unzip file' : DOM.unzipFile
- };
-
- if (UploadToItemNames.length)
- menuItems['Upload to'] = getUploadToItems(UploadToItemNames);
-
- menuItems.Download = downloadFromMenu;
-
- menuItems.New = {
- 'File' : DOM.promptNewFile,
- 'Directory' : DOM.promptNewDir,
-
- 'From FilePicker' : function() {
- Images.showLoad({
- top: true
- });
-
- CloudCmd.execFromModule('FilePicker', 'saveFile', function(name, data) {
- var path = DOM.getCurrentDirPath() + name;
-
- DOM.RESTful.write(path, data, CloudCmd.refresh);
- });
- }
- };
-
- ret = {
- // define which elements trigger this menu
- selector: 'li',
-
- // define the elements of the menu
- items : getAllItems(menuItems),
- events :{
- hide: function() {
- var event = window.event;
-
- if (!event || !event.keyCode)
- clickProcessing();
- else if (event.keyCode)
- listener(event);
- }
- }
- };
-
- return ret;
- }
-
/** function loads css and js of Menu
* @param callback
*/
@@ -244,68 +163,29 @@ var CloudCmd, Util, DOM, CloudFunc, $;
var dir = CloudCmd.LIBDIRCLIENT + 'menu/',
files = [
- dir + 'contextMenu.js',
- dir + 'contextMenu.css'
+ dir + 'menu-io.js',
+ dir + 'menu-io.css'
];
DOM.anyLoadInParallel(files, function() {
- setCSS();
Util.timeEnd(Name + ' load');
- Loading = false;
+ Images.hide();
Util.exec(callback);
});
}
- function setCSS() {
- DOM.cssSet({
- id : 'menu-css',
- inner: '.context-menu-item.icon-edit {' +
- 'background-image: none;' +
- '}' +
- '.context-menu-item.icon-delete {' +
- 'background-image: none;' +
- '}'
- });
- }
-
- function clickProcessing() {
- var element, isCurrent, parent, name,
- layer = DOM.getById('context-menu-layer');
-
- if (layer) {
- DOM.hide(layer);
-
- element = DOM.getCurrentByPosition(Position);
- if (element) {
- parent = element.parentElement;
- name = parent && parent.getAttribute('data-name');
-
- if (name === 'js-files') {
- isCurrent = DOM.isCurrentFile(element);
-
- if (!isCurrent)
- DOM.setCurrentFile(element);
- }
- }
- }
-
- Key.setBind();
- }
-
function listener(event) {
- var current,
- F9 = Key.F9,
+ var F9 = Key.F9,
ESC = Key.ESC,
key = event.keyCode,
isBind = Key.isBind();
if (isBind && key === F9) {
- current = DOM.getCurrentFile();
- $(current).contextmenu();
+ MenuContext.show(Position);
DOM.preventDefault(event);
} else if (key === ESC)
- Key.setBind();
+ MenuContext.hide();
}
init();
diff --git a/lib/client/menu/README.md b/lib/client/menu/README.md
index c3551ada..75b7afe7 100644
--- a/lib/client/menu/README.md
+++ b/lib/client/menu/README.md
@@ -1,322 +1,69 @@
-# jQuery contextMenu plugin & polyfill #
+Menu [![Build Status][BuildStatusIMGURL]][BuildStatusURL]
+====
+[BuildStatusURL]: https://travis-ci.org/coderaiser/menu-io "Build Status"
+[BuildStatusIMGURL]: https://api.travis-ci.org/coderaiser/menu-io.png?branch=gh-pages
-$.contextMenu is a management facility for - you guessed it - context menus. It was designed for an application where there are hundreds of elements that may show a context menu - so intialization speed and memory usage are kept fairly small. It also allows to register context menus without providing actual markup, as $.contextMenu generates DOMElements as needed.
+Simple css-based context menu made for [Cloud Commander](http://cloudcmd.io).
-[features](http://medialize.github.com/jQuery-contextMenu/index.html) -
-[demo](http://medialize.github.com/jQuery-contextMenu/demo.html) -
-[documentation](http://medialize.github.com/jQuery-contextMenu/docs.html)
+Little bit better then other people do :).
+So to see at work look [here](http://jsfiddle.net/coderaiser/mAUUz/).
+#How come?
-## Dependencies ##
+Tired to use js based libraries which use jquery and `.hover` classes insteed of `:hover` pseudo-selectors.
-* jQuery 1.7 (using new .on().off() event API)
-* jQuery UI position (optional but recommended)
+#Why should I care?
-## Usage ##
+- `1.6kb` min & gzip for js.
+- `1kb` min & gzip for css.
+- no dependencies (just part of [util.io](http://coderaiser.github.io/util.io)).
+- easy to use.
+- easy to extend.
-register contextMenu from javascript:
+#How use?
+Create `html` page with `js` and `css` connected.
-```javascript
-$.contextMenu({
- // define which elements trigger this menu
- selector: ".with-cool-menu",
- // define the elements of the menu
- items: {
- foo: {name: "Foo", callback: function(key, opt){ alert("Foo!"); }},
- bar: {name: "Bar", callback: function(key, opt){ alert("Bar!") }}
+```html
+
+
+```
+
+Add little JavaScript:
+```js
+var menu = Menu({
+ 'item name': function onItemNameClick() {
}
- // there's more, have a look at the demos and docs...
-});
+}
```
-have a look at the [demos](http://medialize.github.com/jQuery-contextMenu/demo.html).
+Look for `examples` directory or copy example from bottom:
-
-## HTML5 Compatibility ##
-
-Firefox 8 implemented contextmenu using the <menuitem> tags for menu-structure. The specs however state that <command> tags should be used for this purpose. $.contextMenu accepts both.
-
-Firefox 8 does not yet fully implement the contextmenu specification ([Ticket #617528](https://bugzilla.mozilla.org/show_bug.cgi?id=617528)). The elements
-[a](http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#using-the-a-element-to-define-a-command),
-[button](http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#using-the-button-element-to-define-a-command),
-[input](http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#using-the-input-element-to-define-a-command) and
-[option](http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html#using-the-option-element-to-define-a-command)
-usable as commands are being ignored altogether. It also doesn't (optically) distinguish between checkbox/radio and regular commands ([Bug #705292](https://bugzilla.mozilla.org/show_bug.cgi?id=705292)).
-
-* [contextmenu specs](http://www.w3.org/TR/html5/interactive-elements.html#context-menus)
-* [command specs](http://www.whatwg.org/specs/web-apps/current-work/multipage/commands.html)
-* [Browser support according to caniuse.com](http://caniuse.com/#search=context%20menu)
-
-Note: While the specs note <option>s to be renderd as regular commands, $.contextMenu will render an actual <select>. import contextMenu from HTML5 <menu>:
-
-```javascript
-$.contextMenu("html5");
+```html
+
+
+
```
-
-## Interaction Principles ##
-
-You're (obviously) able to use the context menu with your mouse. Once it is opened, you can also use the keyboard to (fully) navigate it.
-
-* ↑ (up) previous item in list, will skip disabled elements and wrap around
-* ↓ (down) next item in, will skip disabled elements and wrap around
-* → (right) dive into sub-menu
-* ← (left) rise from sub-menu
-* ↵ (return) invoke command
-* ⇥ (tab) next item or input element, will skip disabled elements and wrap around
-* ⇪ ⇥ (shift tab) previous item or input element, will skip disabled elements and wrap around
-* ⎋ (escape) close menu
-* ⌴ (space) captured and ignore to avoid page scrolling (for consistency with native menus)
-* ⇞ (page up) captured and ignore to avoid page scrolling (for consistency with native menus)
-* ⇟ (page down) captured and ignore to avoid page scrolling (for consistency with native menus)
-* ↖ (home) first item in list, will skip disabled elements
-* ↘ (end) last item in list, will skip disabled elements
-
-Besides the obvious, browser also react to alphanumeric key strokes. Hitting r in a context menu will make Firefox (8) reload the page immediately. Chrome selects the option to see infos on the page, Safari selects the option to print the document. Awesome, right? Until trying the same on Windows I did not realize that the browsers were using the access-key for this. I would've preferred typing the first character of something, say "s" for "save" and then iterate through all the commands beginning with s. But that's me - what do I know about UX? Anyways, $.contextMenu now also supports accesskey handling.
-
-
-## Minify ##
-
-use [Google Closure Compiler](http://closure-compiler.appspot.com/home):
-
-```
-// ==ClosureCompiler==
-// @compilation_level SIMPLE_OPTIMIZATIONS
-// @output_file_name contextMenu.js
-// @code_url http://medialize.github.com/jQuery-contextMenu/jquery-1.8.2.min.js
-// @code_url http://medialize.github.com/jQuery-contextMenu/src/jquery.ui.position.js
-// @code_url http://medialize.github.com/jQuery-contextMenu/src/jquery.contextMenu.js
-// ==/ClosureCompiler==
-```
-
-
-## Authors ##
-
-* [Rodney Rehm](https://github.com/rodneyrehm)
-* [Christiaan Baartse](https://github.com/christiaan) (single callback per menu)
-* [Addy Osmani](https://github.com/addyosmani) (compatibility with native context menu in Firefox 8)
-
-
-## License ##
-
-$.contextMenu is published under the [MIT license](http://www.opensource.org/licenses/mit-license) and [GPL v3](http://opensource.org/licenses/GPL-3.0).
-
-
-## Changelog ##
-
-### 1.6.5 (January 20th 2013) ###
-
-* fixing "opening a second menu can break the layer" - ([Issue #105](https://github.com/medialize/jQuery-contextMenu/issues/105))
-
-### 1.6.4 (January 19th 2013) ###
-
-* fixing [jQuery plugin manifest](https://github.com/medialize/jQuery-contextMenu/commit/413b1ecaba0aeb4e50f97cee35f7c367435e7830#commitcomment-2465216), again. yep. I'm that kind of a guy. :(
-
-### 1.6.3 (January 19th 2013) ###
-
-* fixing [jQuery plugin manifest](https://github.com/medialize/jQuery-contextMenu/commit/413b1ecaba0aeb4e50f97cee35f7c367435e7830#commitcomment-2465216)
-
-### 1.6.2 (January 19th 2013) ###
-
-* fixing "menu won't close" regression introduced by 1.6.1
-
-### 1.6.1 (January 19th 2013) ###
-
-* fixing potential html parsing problem
-* upgrading to jQuery UI position v1.10.0
-* replaced `CRLF` by `LF` (no idea how this happened in the first place...)
-* adding `options.reposition` to dis/allow simply relocating a menu instead of rebuilding it ([Issue #104](https://github.com/medialize/jQuery-contextMenu/issues/104))
-
-### 1.6.0 (December 29th 2012) ###
-
-* adding [DOM Element bound context menus](http://medialize.github.com/jQuery-contextMenu/demo/on-dom-element.html) - ([Issue 88](https://github.com/medialize/jQuery-contextMenu/issues/88))
-* adding class `context-menu-active` to define state on active trigger element - ([Issue 92](https://github.com/medialize/jQuery-contextMenu/issues/92))
-* adding [demo for TouchSwipe](http://medialize.github.com/jQuery-contextMenu/demo/trigger-swipe.html) activation
-* adding export of internal functions and event handlers - ([Issue 101](https://github.com/medialize/jQuery-contextMenu/issues/101))
-* fixing key "watch" might translate to Object.prototype.watch in callbacks map - ([Issue 93](https://github.com/medialize/jQuery-contextMenu/issues/93))
-* fixing menu and submenu width calculation - ([Issue 18](https://github.com/medialize/jQuery-contextMenu/issues/18))
-* fixing unused variables - ([Issue 100](https://github.com/medialize/jQuery-contextMenu/issues/100))
-* fixing iOS "click" compatibility problem - ([Issue 83](https://github.com/medialize/jQuery-contextMenu/issues/83))
-* fixing separators to not be clickable - ([Issue 85](https://github.com/medialize/jQuery-contextMenu/issues/85))
-* fixing issues with fixed positioned triggers ([Issue 95](https://github.com/medialize/jQuery-contextMenu/issues/95))
-* fixing word break problem - ([Issue 80](https://github.com/medialize/jQuery-contextMenu/issues/80))
-
-### 1.5.25 (October 8th 2012) ###
-
-* upgrading to jQuery 1.8.2 ([Issue 78](https://github.com/medialize/jQuery-contextMenu/issues/78))
-* upgrading to jQuery UI position 1.9.0 RC1 ([Issue 78](https://github.com/medialize/jQuery-contextMenu/issues/78))
-
-### 1.5.24 (August 30th 2012) ###
-
-* adding context menu options to input command events ([Issue 72](https://github.com/medialize/jQuery-contextMenu/issues/72), dtex)
-* code cosmetics for JSLint
-
-### 1.5.23 (August 22nd 2012) ###
-
-* fixing reposition/close issue on scrolled documents ([Issue 69](https://github.com/medialize/jQuery-contextMenu/issues/69))
-* fixing jQuery reference ([Issue 68](https://github.com/medialize/jQuery-contextMenu/issues/68))
-
-### 1.5.22 (July 16th 2012) ###
-
-* fixing issue with animation and remove on hide (Issue #64)
-
-### 1.5.21 (July 14th 2012) ###
-
-* fixing backdrop would not remove on destroy (Issue #63)
-
-### 1.5.20 (June 26th 2012) ###
-
-Note: git tag of version is `v1.6.20`?!
-
-* fixing backdrop would not position properly in IE6 (Issue #59)
-* fixing nested input elements not accessible in Chrome / Safari (Issue #58)
-
-### 1.5.19 ###
-
-Note: git tag of version is missing...?!
-
-* fixing sub-menu positioning when `$.ui.position` is not available (Issue #56)
-
-### 1.5.18 ###
-
-Note: git tag of version is missing...?!
-
-* fixing html5 `