added context menu on shift+f10
109
lib/client/menu.js
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
var CloudCommander, CloudFunc, $;
|
||||
/* object contains jQuery-contextMenu
|
||||
* https://github.com/medialize/jQuery-contextMenu
|
||||
*/
|
||||
CloudCommander.Menu = new CloudCommander.Util();
|
||||
|
||||
CloudCommander.Menu.dir = {
|
||||
dir : './lib/client/menu/'
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* function return configureation
|
||||
* for FancyBox open and
|
||||
* onclick (it shoud be
|
||||
* different objects)
|
||||
*/
|
||||
CloudCommander.Menu.getConfig = (function(){
|
||||
return{
|
||||
// define which elements trigger this menu
|
||||
selector: CloudCommander.CURRENT_FILE,
|
||||
// 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!"); }}
|
||||
}
|
||||
// there's more, have a look at the demos and docs...
|
||||
};
|
||||
});
|
||||
|
||||
/* function loads css and js of FancyBox
|
||||
* @pParent - this
|
||||
* @pCallBack - executes, when everything loaded
|
||||
*/
|
||||
CloudCommander.Menu.load = (function(pParent, pCallBack){
|
||||
return function(){
|
||||
var ljsLoad_f = function(){
|
||||
var lMenuSrc = pParent.dir + 'jquery.contextMenu.js';
|
||||
|
||||
pParent.jsload(lMenuSrc,{
|
||||
onload: pCallBack
|
||||
});
|
||||
};
|
||||
|
||||
var lSrc = pParent.dir +'jquery.contextMenu.css';
|
||||
|
||||
pParent.cssLoad({
|
||||
src : lSrc,
|
||||
func : {
|
||||
onload: ljsLoad_f
|
||||
}
|
||||
});
|
||||
}();
|
||||
});
|
||||
|
||||
CloudCommander.Menu.set = (function(){
|
||||
if(!this.setted){
|
||||
$.contextMenu(this.getConfig());
|
||||
this.setted = true;
|
||||
}
|
||||
});
|
||||
CloudCommander.Menu.seted = false;
|
||||
|
||||
CloudCommander.Menu.show = (function(pParent){
|
||||
pParent.set();
|
||||
$(CloudCommander.CURRENT_FILE).contextMenu();
|
||||
});
|
||||
|
||||
CloudCommander.Menu.Keys = (function(){
|
||||
"use strict";
|
||||
|
||||
var lCallBack_f = (function(){
|
||||
var key_event = (function(){
|
||||
return function(event){
|
||||
/* если клавиши можно обрабатывать */
|
||||
if(CloudCommander.keyBinded)
|
||||
/* if shift + F10 pressed */
|
||||
if(event.keyCode === CloudCommander.KEY.F10 &&
|
||||
event.shiftKey){
|
||||
CloudCommander.Menu.show();
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
if (document.addEventListener)
|
||||
document.addEventListener('keydown', key_event(),false);
|
||||
|
||||
else{
|
||||
var lFunc;
|
||||
if(typeof document.onkeydown === 'function')
|
||||
lFunc = document.onkeydown;
|
||||
|
||||
document.onkeydown = function(){
|
||||
if(lFunc)
|
||||
lFunc();
|
||||
|
||||
key_event();
|
||||
};
|
||||
}
|
||||
|
||||
/* showing context menu preview*/
|
||||
CloudCommander.Menu.show();
|
||||
});
|
||||
|
||||
CloudCommander.Menu.load(this, lCallBack_f);
|
||||
});
|
||||
264
lib/client/menu/README.md
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
# jQuery contextMenu plugin & polyfill #
|
||||
|
||||
$.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.
|
||||
|
||||
[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)
|
||||
|
||||
|
||||
## Dependencies ##
|
||||
|
||||
* jQuery 1.7 (using new .on().off() event API)
|
||||
* jQuery UI position (optional but recommended)
|
||||
|
||||
## Usage ##
|
||||
|
||||
register contextMenu from javascript:
|
||||
|
||||
```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!") }}
|
||||
}
|
||||
// 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).
|
||||
|
||||
|
||||
## 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");
|
||||
```
|
||||
|
||||
## 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, will skip disabled elements
|
||||
|
||||
Besides the obvious, browser also react to alphanumeric key strokes. Hitting <code>r</code> 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.7.1.min.js
|
||||
// @code_url http://medialize.github.com/jQuery-contextMenu/jquery.ui.position.js
|
||||
// @code_url http://medialize.github.com/jQuery-contextMenu/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.5.22 ###
|
||||
|
||||
* Fixing issue with animation and remove on hide (Issue #64)
|
||||
|
||||
### 1.5.21 ###
|
||||
|
||||
* Fixing backdrop would not remove on destroy (Issue #63)
|
||||
|
||||
### 1.5.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 ###
|
||||
|
||||
* fixing sub-menu positioning when `$.ui.position` is not available (Issue #56)
|
||||
|
||||
### 1.5.18 ###
|
||||
|
||||
* fixing html5 `<menu>` import (Issue #53)
|
||||
|
||||
### 1.5.17 ###
|
||||
|
||||
* fixing `options` to default to `options.trigger = "right"`
|
||||
* fixing variable name typo (Within Issue #51)
|
||||
* fixing menu not closing while opening other menu (Within Issue #51)
|
||||
* adding workaround for `contextmenu`-bug in Firefox 12 (Within Issue #51)
|
||||
|
||||
### 1.5.16 ###
|
||||
|
||||
* added vendor-prefixed user-select to CSS
|
||||
* fixed issue with z-indexing when `<body>` is used as a trigger (Issue #49)
|
||||
|
||||
### 1.5.15 ###
|
||||
|
||||
* allowing to directly open another element's menu while a menu is shown (Issue #48)
|
||||
* fixing autohide option that would not properly hide the menu
|
||||
|
||||
### 1.5.14 ###
|
||||
|
||||
* options.build() would break default options (Issue #47)
|
||||
* $.contextMenu('destroy') would not remove backdrop
|
||||
|
||||
### 1.5.13 ###
|
||||
|
||||
* exposing $trigger to dynamically built custom menu-item types (Issue #42)
|
||||
* fixing repositioning of open menu (formerly accidental re-open)
|
||||
* adding asynchronous example
|
||||
* dropping ignoreRightClick in favor of proper event-type detection
|
||||
|
||||
### 1.5.12 ###
|
||||
|
||||
* prevent invoking callback of first item of a sub-menu when clicking on the sub-menu-item (Issue #41)
|
||||
|
||||
### 1.5.11 ###
|
||||
|
||||
* providing `opt.$trigger` to show event (Issue #39)
|
||||
|
||||
### 1.5.10 ###
|
||||
|
||||
* ignoreRightClick would not prevent right click when menu is already open (Issue #38)
|
||||
|
||||
### 1.5.9 ###
|
||||
|
||||
* If build() did not return any items, an empty menu was shown (Issue #33)
|
||||
|
||||
### 1.5.8 ###
|
||||
|
||||
* Capturing Page Up and Page Down keys to ignore like space (Issue #30)
|
||||
* Added Home / End keys to jump to first / last command of menu (Issue #29)
|
||||
* Bug hitting enter in an <input> would yield an error (Issue #28)
|
||||
|
||||
### 1.5.7 ###
|
||||
|
||||
* Non-ASCII character in jquery.contextMenu.js caused compatibility issues in Rails (Issue #27)
|
||||
|
||||
### 1.5.6 ###
|
||||
|
||||
* Bug contextmenu event was not passed to build() callback (Issue #24)
|
||||
* Bug sub-menu markers would not display properly in Safari and Chrome (Issue #25)
|
||||
|
||||
### 1.5.5 ###
|
||||
|
||||
* Bug Internet Explorer would not close menu when giving input elements focus (Issue #23)
|
||||
|
||||
### 1.5.4 ###
|
||||
|
||||
* Bug not set z-index of sub-menus might not overlap the main menu correctly (Issue #22)
|
||||
|
||||
### 1.5.3 ###
|
||||
|
||||
* Bug `console.log is undefined`
|
||||
|
||||
### 1.5.2 ###
|
||||
|
||||
* Bug sub-menus would not properly update their disabled states (Issue #16) [again…]
|
||||
* Bug sub-menus would not properly adjust width accoring to min-width and max-width (Issue #18)
|
||||
|
||||
### 1.5.1 ###
|
||||
|
||||
* Bug sub-menus would not properly update their disabled states (Issue #16)
|
||||
|
||||
### 1.5 ###
|
||||
|
||||
* Added [dynamic menu creation](http://medialize.github.com/jQuery-contextMenu/demo/dynamic-create.html) (Issue #15)
|
||||
|
||||
### 1.4.4 ###
|
||||
|
||||
* Bug positioning <menu> when trigger element is `position:fixed` (Issue #14)
|
||||
|
||||
### 1.4.3 ###
|
||||
|
||||
* Bug key handler would caputure all key strokes while menu was visible (essentially disabling F5 and co.)
|
||||
|
||||
### 1.4.2 ###
|
||||
|
||||
* Bug opt.$trigger was not available to disabled callbacks
|
||||
* jQuery bumped to 1.7.1
|
||||
|
||||
### 1.4.1 ###
|
||||
|
||||
* Bug where <menu> imports would not pass action (click event) properly
|
||||
|
||||
### 1.4 ###
|
||||
|
||||
* Upgraded to jQuery 1.7 (changed dependecy!)
|
||||
* Added internal events `contextmenu:focus`, `contextmenu:blur` and `contextmenu:hide`
|
||||
* Added custom <command> types
|
||||
* Bug where `className` wasn't properly set on <menu>
|
||||
|
||||
### 1.3 ###
|
||||
|
||||
* Added support for accesskeys
|
||||
* Bug where two sub-menus could be open simultaneously
|
||||
|
||||
### 1.2.2 ###
|
||||
|
||||
* Bug in HTML5 import
|
||||
|
||||
### 1.2.1 ###
|
||||
|
||||
* Bug in HTML5 detection
|
||||
|
||||
### 1.2 ###
|
||||
|
||||
* Added compatibility to <menuitem> for Firefox 8
|
||||
* Upgraded to jQuery 1.6.2
|
||||
|
||||
### 1.1 ###
|
||||
|
||||
* Bug #1 TypeError on HTML5 action passthru
|
||||
* Bug #2 disbaled callback not invoked properly
|
||||
* Feature #3 auto-hide option for hover trigger
|
||||
* Feature #4 option to use a single callback for all commands, rather than registering the same function for each item
|
||||
* Option to ignore right-click (original "contextmenu" event trigger) for non-right-click triggers
|
||||
|
||||
### 1.0 ###
|
||||
|
||||
* Initial $.contextMenu handler
|
||||
BIN
lib/client/menu/images/cut.png
Normal file
|
After Width: | Height: | Size: 648 B |
BIN
lib/client/menu/images/door.png
Normal file
|
After Width: | Height: | Size: 412 B |
BIN
lib/client/menu/images/page_white_add.png
Normal file
|
After Width: | Height: | Size: 442 B |
BIN
lib/client/menu/images/page_white_copy.png
Normal file
|
After Width: | Height: | Size: 309 B |
BIN
lib/client/menu/images/page_white_delete.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
lib/client/menu/images/page_white_edit.png
Normal file
|
After Width: | Height: | Size: 618 B |
BIN
lib/client/menu/images/page_white_paste.png
Normal file
|
After Width: | Height: | Size: 620 B |
142
lib/client/menu/jquery.contextMenu.css
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*!
|
||||
* jQuery contextMenu - Plugin for simple contextMenu handling
|
||||
*
|
||||
* Version: 1.5.22
|
||||
*
|
||||
* Authors: Rodney Rehm, Addy Osmani (patches for FF)
|
||||
* Web: http://medialize.github.com/jQuery-contextMenu/
|
||||
*
|
||||
* Licensed under
|
||||
* MIT License http://www.opensource.org/licenses/mit-license
|
||||
* GPL v3 http://opensource.org/licenses/GPL-3.0
|
||||
*
|
||||
*/
|
||||
|
||||
.context-menu-list {
|
||||
margin:0;
|
||||
padding:0;
|
||||
|
||||
min-width: 120px;
|
||||
max-width: 250px;
|
||||
display: inline-block;
|
||||
position: absolute;
|
||||
list-style-type: none;
|
||||
|
||||
border: 1px solid #DDD;
|
||||
background: #EEE;
|
||||
|
||||
-webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
|
||||
-moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
|
||||
-ms-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
|
||||
-o-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
|
||||
|
||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.context-menu-item {
|
||||
padding: 2px 2px 2px 24px;
|
||||
background-color: #EEE;
|
||||
position: relative;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: -moz-none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.context-menu-separator {
|
||||
padding-bottom:0;
|
||||
border-bottom: 1px solid #DDD;
|
||||
}
|
||||
|
||||
.context-menu-item > label > input,
|
||||
.context-menu-item > label > textarea {
|
||||
-webkit-user-select: text;
|
||||
-moz-user-select: text;
|
||||
-ms-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
.context-menu-item.hover {
|
||||
cursor: pointer;
|
||||
background-color: #39F;
|
||||
}
|
||||
|
||||
.context-menu-item.disabled {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.context-menu-input.hover,
|
||||
.context-menu-item.disabled.hover {
|
||||
cursor: default;
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
.context-menu-submenu:after {
|
||||
content: ">";
|
||||
color: #666;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 3px;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* icons
|
||||
#protip:
|
||||
In case you want to use sprites for icons (which I would suggest you do) have a look at
|
||||
http://css-tricks.com/13224-pseudo-spriting/ to get an idea of how to implement
|
||||
.context-menu-item.icon:before {}
|
||||
*/
|
||||
.context-menu-item.icon { min-height: 18px; background-repeat: no-repeat; background-position: 4px 2px; }
|
||||
.context-menu-item.icon-edit { background-image: url(images/page_white_edit.png); }
|
||||
.context-menu-item.icon-cut { background-image: url(images/cut.png); }
|
||||
.context-menu-item.icon-copy { background-image: url(images/page_white_copy.png); }
|
||||
.context-menu-item.icon-paste { background-image: url(images/page_white_paste.png); }
|
||||
.context-menu-item.icon-delete { background-image: url(images/page_white_delete.png); }
|
||||
.context-menu-item.icon-add { background-image: url(images/page_white_add.png); }
|
||||
.context-menu-item.icon-quit { background-image: url(images/door.png); }
|
||||
|
||||
/* vertically align inside labels */
|
||||
.context-menu-input > label > * { vertical-align: top; }
|
||||
|
||||
/* position checkboxes and radios as icons */
|
||||
.context-menu-input > label > input[type="checkbox"],
|
||||
.context-menu-input > label > input[type="radio"] {
|
||||
margin-left: -17px;
|
||||
}
|
||||
.context-menu-input > label > span {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.context-menu-input > label,
|
||||
.context-menu-input > label > input[type="text"],
|
||||
.context-menu-input > label > textarea,
|
||||
.context-menu-input > label > select {
|
||||
display: block;
|
||||
width: 100%;
|
||||
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
-o-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.context-menu-input > label > textarea {
|
||||
height: 100px;
|
||||
}
|
||||
.context-menu-item > .context-menu-list {
|
||||
display: none;
|
||||
/* re-positioned by js */
|
||||
right: -5px;
|
||||
top: 5px;
|
||||
}
|
||||
|
||||
.context-menu-item.hover > .context-menu-list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.context-menu-accesskey {
|
||||
text-decoration: underline;
|
||||
}
|
||||
1585
lib/client/menu/jquery.contextMenu.js
Normal file
252
lib/client/menu/jquery.ui.position.js
vendored
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
/*!
|
||||
* jQuery UI Position 1.8.13
|
||||
*
|
||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* http://docs.jquery.com/UI/Position
|
||||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
$.ui = $.ui || {};
|
||||
|
||||
var horizontalPositions = /left|center|right/,
|
||||
verticalPositions = /top|center|bottom/,
|
||||
center = "center",
|
||||
_position = $.fn.position,
|
||||
_offset = $.fn.offset;
|
||||
|
||||
$.fn.position = function( options ) {
|
||||
if ( !options || !options.of ) {
|
||||
return _position.apply( this, arguments );
|
||||
}
|
||||
|
||||
// make a copy, we don't want to modify arguments
|
||||
options = $.extend( {}, options );
|
||||
|
||||
var target = $( options.of ),
|
||||
targetElem = target[0],
|
||||
collision = ( options.collision || "flip" ).split( " " ),
|
||||
offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
|
||||
targetWidth,
|
||||
targetHeight,
|
||||
basePosition;
|
||||
|
||||
if ( targetElem.nodeType === 9 ) {
|
||||
targetWidth = target.width();
|
||||
targetHeight = target.height();
|
||||
basePosition = { top: 0, left: 0 };
|
||||
// TODO: use $.isWindow() in 1.9
|
||||
} else if ( targetElem.setTimeout ) {
|
||||
targetWidth = target.width();
|
||||
targetHeight = target.height();
|
||||
basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
|
||||
} else if ( targetElem.preventDefault ) {
|
||||
// force left top to allow flipping
|
||||
options.at = "left top";
|
||||
targetWidth = targetHeight = 0;
|
||||
basePosition = { top: options.of.pageY, left: options.of.pageX };
|
||||
} else {
|
||||
targetWidth = target.outerWidth();
|
||||
targetHeight = target.outerHeight();
|
||||
basePosition = target.offset();
|
||||
}
|
||||
|
||||
// force my and at to have valid horizontal and veritcal positions
|
||||
// if a value is missing or invalid, it will be converted to center
|
||||
$.each( [ "my", "at" ], function() {
|
||||
var pos = ( options[this] || "" ).split( " " );
|
||||
if ( pos.length === 1) {
|
||||
pos = horizontalPositions.test( pos[0] ) ?
|
||||
pos.concat( [center] ) :
|
||||
verticalPositions.test( pos[0] ) ?
|
||||
[ center ].concat( pos ) :
|
||||
[ center, center ];
|
||||
}
|
||||
pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
|
||||
pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
|
||||
options[ this ] = pos;
|
||||
});
|
||||
|
||||
// normalize collision option
|
||||
if ( collision.length === 1 ) {
|
||||
collision[ 1 ] = collision[ 0 ];
|
||||
}
|
||||
|
||||
// normalize offset option
|
||||
offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
|
||||
if ( offset.length === 1 ) {
|
||||
offset[ 1 ] = offset[ 0 ];
|
||||
}
|
||||
offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
|
||||
|
||||
if ( options.at[0] === "right" ) {
|
||||
basePosition.left += targetWidth;
|
||||
} else if ( options.at[0] === center ) {
|
||||
basePosition.left += targetWidth / 2;
|
||||
}
|
||||
|
||||
if ( options.at[1] === "bottom" ) {
|
||||
basePosition.top += targetHeight;
|
||||
} else if ( options.at[1] === center ) {
|
||||
basePosition.top += targetHeight / 2;
|
||||
}
|
||||
|
||||
basePosition.left += offset[ 0 ];
|
||||
basePosition.top += offset[ 1 ];
|
||||
|
||||
return this.each(function() {
|
||||
var elem = $( this ),
|
||||
elemWidth = elem.outerWidth(),
|
||||
elemHeight = elem.outerHeight(),
|
||||
marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
|
||||
marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
|
||||
collisionWidth = elemWidth + marginLeft +
|
||||
( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
|
||||
collisionHeight = elemHeight + marginTop +
|
||||
( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
|
||||
position = $.extend( {}, basePosition ),
|
||||
collisionPosition;
|
||||
|
||||
if ( options.my[0] === "right" ) {
|
||||
position.left -= elemWidth;
|
||||
} else if ( options.my[0] === center ) {
|
||||
position.left -= elemWidth / 2;
|
||||
}
|
||||
|
||||
if ( options.my[1] === "bottom" ) {
|
||||
position.top -= elemHeight;
|
||||
} else if ( options.my[1] === center ) {
|
||||
position.top -= elemHeight / 2;
|
||||
}
|
||||
|
||||
// prevent fractions (see #5280)
|
||||
position.left = Math.round( position.left );
|
||||
position.top = Math.round( position.top );
|
||||
|
||||
collisionPosition = {
|
||||
left: position.left - marginLeft,
|
||||
top: position.top - marginTop
|
||||
};
|
||||
|
||||
$.each( [ "left", "top" ], function( i, dir ) {
|
||||
if ( $.ui.position[ collision[i] ] ) {
|
||||
$.ui.position[ collision[i] ][ dir ]( position, {
|
||||
targetWidth: targetWidth,
|
||||
targetHeight: targetHeight,
|
||||
elemWidth: elemWidth,
|
||||
elemHeight: elemHeight,
|
||||
collisionPosition: collisionPosition,
|
||||
collisionWidth: collisionWidth,
|
||||
collisionHeight: collisionHeight,
|
||||
offset: offset,
|
||||
my: options.my,
|
||||
at: options.at
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if ( $.fn.bgiframe ) {
|
||||
elem.bgiframe();
|
||||
}
|
||||
elem.offset( $.extend( position, { using: options.using } ) );
|
||||
});
|
||||
};
|
||||
|
||||
$.ui.position = {
|
||||
fit: {
|
||||
left: function( position, data ) {
|
||||
var win = $( window ),
|
||||
over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
|
||||
position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
|
||||
},
|
||||
top: function( position, data ) {
|
||||
var win = $( window ),
|
||||
over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
|
||||
position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
|
||||
}
|
||||
},
|
||||
|
||||
flip: {
|
||||
left: function( position, data ) {
|
||||
if ( data.at[0] === center ) {
|
||||
return;
|
||||
}
|
||||
var win = $( window ),
|
||||
over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
|
||||
myOffset = data.my[ 0 ] === "left" ?
|
||||
-data.elemWidth :
|
||||
data.my[ 0 ] === "right" ?
|
||||
data.elemWidth :
|
||||
0,
|
||||
atOffset = data.at[ 0 ] === "left" ?
|
||||
data.targetWidth :
|
||||
-data.targetWidth,
|
||||
offset = -2 * data.offset[ 0 ];
|
||||
position.left += data.collisionPosition.left < 0 ?
|
||||
myOffset + atOffset + offset :
|
||||
over > 0 ?
|
||||
myOffset + atOffset + offset :
|
||||
0;
|
||||
},
|
||||
top: function( position, data ) {
|
||||
if ( data.at[1] === center ) {
|
||||
return;
|
||||
}
|
||||
var win = $( window ),
|
||||
over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
|
||||
myOffset = data.my[ 1 ] === "top" ?
|
||||
-data.elemHeight :
|
||||
data.my[ 1 ] === "bottom" ?
|
||||
data.elemHeight :
|
||||
0,
|
||||
atOffset = data.at[ 1 ] === "top" ?
|
||||
data.targetHeight :
|
||||
-data.targetHeight,
|
||||
offset = -2 * data.offset[ 1 ];
|
||||
position.top += data.collisionPosition.top < 0 ?
|
||||
myOffset + atOffset + offset :
|
||||
over > 0 ?
|
||||
myOffset + atOffset + offset :
|
||||
0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// offset setter from jQuery 1.4
|
||||
if ( !$.offset.setOffset ) {
|
||||
$.offset.setOffset = function( elem, options ) {
|
||||
// set position first, in-case top/left are set even on static elem
|
||||
if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
|
||||
elem.style.position = "relative";
|
||||
}
|
||||
var curElem = $( elem ),
|
||||
curOffset = curElem.offset(),
|
||||
curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
|
||||
curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
|
||||
props = {
|
||||
top: (options.top - curOffset.top) + curTop,
|
||||
left: (options.left - curOffset.left) + curLeft
|
||||
};
|
||||
|
||||
if ( 'using' in options ) {
|
||||
options.using.call( elem, props );
|
||||
} else {
|
||||
curElem.css( props );
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.offset = function( options ) {
|
||||
var elem = this[ 0 ];
|
||||
if ( !elem || !elem.ownerDocument ) { return null; }
|
||||
if ( options ) {
|
||||
return this.each(function() {
|
||||
$.offset.setOffset( this, options );
|
||||
});
|
||||
}
|
||||
return _offset.call( this );
|
||||
};
|
||||
}
|
||||
|
||||
}( jQuery ));
|
||||
49
lib/client/menu/package.json
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "jQuery contextMenu",
|
||||
"version": "1.5.22",
|
||||
"title": "jQuery.contextMenu()",
|
||||
"author": {
|
||||
"name": "Rodney Rehm",
|
||||
"url": "http://rodneyrehm.de"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license"
|
||||
},
|
||||
{
|
||||
"type": "GPL",
|
||||
"url": "http://opensource.org/licenses/GPL-3.0"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.7.0"
|
||||
},
|
||||
"description": "Management facility for context menus. Developed for a large number of triggering objects. HTML5 Polyfill",
|
||||
"keywords": [
|
||||
"contextmenu",
|
||||
"context menu",
|
||||
"context-menu",
|
||||
"menu",
|
||||
"html5 menu",
|
||||
"html5 contextmenu",
|
||||
"html5 context menu",
|
||||
"html5 context-menu"
|
||||
],
|
||||
"homepage": "http://medialize.github.com/jQuery-contextMenu/",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Addy Osmani",
|
||||
"url": "https://github.com/addyosmani"
|
||||
},
|
||||
{
|
||||
"name": "Christiaan Baartse",
|
||||
"url": "https://github.com/christiaan"
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"src/jquery.contextMenu.js",
|
||||
"src/jquery.contextMenu.css",
|
||||
"src/jquery.ui.position.js"
|
||||
]
|
||||
}
|
||||
28
lib/client/polyfills.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* object contain poyfills of functions */
|
||||
var CloudCommander;
|
||||
|
||||
var PolyFills = (function(){
|
||||
document.head = document.getElementsByTagName("head")[0];
|
||||
|
||||
document.getElementsByClassName = function(pClassName){
|
||||
return window.jQuery('.'+pClassName)[0];
|
||||
};
|
||||
|
||||
/*
|
||||
{name: '', src: ' ',func: '', style: '', id: '', parent: '',
|
||||
async: false, inner: 'id{color:red, }, class:'', not_append: false}
|
||||
*/
|
||||
this.cssSet = function(pParams_o){
|
||||
var lElement = '<style ';
|
||||
|
||||
if (pParams_o.id) lElement += 'id=' + pParams_o.id + ' ';
|
||||
if (pParams_o.style) lElement += 'style=' + pParams_o.style + ' ';
|
||||
if (pParams_o.className) lElement += 'class=' + pParams_o.className;
|
||||
if (pParams_o.inner)lElement += '>' + pParams_o.inner;
|
||||
|
||||
lElement +='</style>';
|
||||
return $(lElement)
|
||||
.appendTo(pParams_o.parent || document.head);
|
||||
|
||||
},
|
||||
});
|
||||