mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(bower) menu v1.0.0
This commit is contained in:
parent
8cf54b7e04
commit
fb42ab8113
9 changed files with 55 additions and 19 deletions
|
|
@ -33,13 +33,13 @@
|
|||
"fancybox": "~2.1.5",
|
||||
"format-io": "~0.9.6",
|
||||
"jquery": "~2.1.4",
|
||||
"menu": "~0.7.9",
|
||||
"rendy": "~1.1.0",
|
||||
"execon": "~1.2.8",
|
||||
"emitify": "~2.0.0",
|
||||
"findit": "~1.1.4",
|
||||
"philip": "~1.3.2",
|
||||
"smalltalk": "~1.6.5",
|
||||
"promise-polyfill": "~3.1.0"
|
||||
"promise-polyfill": "~3.1.0",
|
||||
"menu": "~1.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@
|
|||
]
|
||||
}, {
|
||||
"name": "menu",
|
||||
"version": "0.7.9",
|
||||
"version": "1.0.0",
|
||||
"local": [
|
||||
"/modules/menu/menu-io.css",
|
||||
"/modules/menu/menu-io.js"
|
||||
"/modules/menu/menu-io.min.css",
|
||||
"/modules/menu/menu-io.min.js"
|
||||
],
|
||||
"remote": [
|
||||
"//cdn.jsdelivr.net/menu-io/{{ version }}/menu-io.min.js",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "menu",
|
||||
"version": "0.7.9",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/coderaiser/menu-io",
|
||||
"authors": [
|
||||
"coderaiser <mnemonic.enemy@gmail.com>"
|
||||
|
|
@ -20,14 +20,14 @@
|
|||
"gulpfile.js",
|
||||
"node_modules"
|
||||
],
|
||||
"_release": "0.7.9",
|
||||
"_release": "1.0.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v0.7.9",
|
||||
"commit": "272a723bfa7a02755dc53a96c1219571aea4fef3"
|
||||
"tag": "v1.0.0",
|
||||
"commit": "044d5045e6849290d2a1a8c8d041a88d887bd0c2"
|
||||
},
|
||||
"_source": "git://github.com/coderaiser/menu-io.git",
|
||||
"_target": "~0.7.9",
|
||||
"_target": "~1.0.0",
|
||||
"_originalSource": "menu",
|
||||
"_direct": true
|
||||
}
|
||||
|
|
@ -1,3 +1,13 @@
|
|||
2016.02.05, v1.0.0
|
||||
|
||||
fix:
|
||||
- (menu) menu cut on small screen
|
||||
|
||||
feature:
|
||||
- (package) add wisdom
|
||||
- (package) add branch
|
||||
|
||||
|
||||
2015.07.22, v0.7.9
|
||||
|
||||
feature:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Tired to use js based libraries which use jquery and `.hover` classes insteed of
|
|||
|
||||
- `1.6kb` min & gzip for js.
|
||||
- `1kb` min & gzip for css.
|
||||
- no dependencies (just part of [util-io](http://coderaiser.github.io/util-io)).
|
||||
- no dependencies.
|
||||
- easy to use.
|
||||
- easy to extend.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "menu",
|
||||
"version": "0.7.9",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/coderaiser/menu-io",
|
||||
"authors": [
|
||||
"coderaiser <mnemonic.enemy@gmail.com>"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ var MenuIO;
|
|||
Options = {},
|
||||
ElementFuncs = new ElementFuncsProto(),
|
||||
ElementHeight,
|
||||
ElementWidth,
|
||||
ElementEvent,
|
||||
MenuFuncs = {},
|
||||
TEMPLATE = {
|
||||
|
|
@ -206,10 +207,19 @@ var MenuIO;
|
|||
var isNumberX = typeof x === 'number',
|
||||
isNumberY = typeof y === 'number',
|
||||
heightMenu = getMenuHeight(),
|
||||
heightInner = window.innerHeight;
|
||||
widthMenu = getMenuWidth(),
|
||||
heightInner = window.innerHeight,
|
||||
widthInner = window.innerWidth;
|
||||
|
||||
if (heightInner < heightMenu + y)
|
||||
if (widthInner < widthMenu + x)
|
||||
x -= widthMenu;
|
||||
|
||||
if (heightInner < heightMenu + y) {
|
||||
y -= heightMenu;
|
||||
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
}
|
||||
|
||||
if (isNumberX)
|
||||
ElementMenu.style.left = x + 'px';
|
||||
|
|
@ -262,12 +272,26 @@ var MenuIO;
|
|||
if (!ElementHeight) {
|
||||
styleComputed = getComputedStyle(ElementMenu);
|
||||
height = styleComputed.height;
|
||||
|
||||
ElementHeight = parseInt(height, 10);
|
||||
}
|
||||
|
||||
|
||||
return ElementHeight;
|
||||
}
|
||||
|
||||
function getMenuWidth() {
|
||||
var styleComputed, width;
|
||||
|
||||
if (!ElementWidth) {
|
||||
styleComputed = getComputedStyle(ElementMenu);
|
||||
width = styleComputed.width;
|
||||
|
||||
ElementWidth = parseInt(width, 10);
|
||||
}
|
||||
|
||||
return ElementWidth;
|
||||
}
|
||||
|
||||
init();
|
||||
};
|
||||
|
||||
|
|
|
|||
2
modules/menu/menu-io.min.js
vendored
2
modules/menu/menu-io.min.js
vendored
|
|
@ -1 +1 @@
|
|||
var MenuIO;!function(e){"use strict";function t(){function e(e){var t;return e&&(t=n(e),t&&(e=e.parentElement)),e}function t(e){var t;return e&&(t=n(e),t||(e=e.querySelector("[data-menu-path]"))),e}function n(e){var t;return e&&(t=e.hasAttribute("data-menu-path")),t}function a(e){var t=r(e,"js-menu-item");return t}function u(e){var t=r(e,"js-menu");return t}function r(e,t,n){var a,u;return n||(n="data-name"),e&&(u=e.getAttribute(n),u===t&&(a=!0)),a}function i(t){var n,a,u="data-menu",i="js-submenu";return a=e(t),n=r(a,i,u)}this.getItem=e,this.getName=t,this.isName=n,this.isItem=a,this.isMenu=u,this.isSubMenu=i}function n(e){var t,n=[].slice.call(arguments,1);return"function"==typeof e&&(t=e.apply(null,n)),t}function a(e,t){var n=e;return u(e,t),Object.keys(t).forEach(function(e){for(var a="{{ "+e+" }}",u=t[e];~n.indexOf(a);)n=n.replace(a,u)}),~n.indexOf("{{")&&(n=n.replace(/{{.*?}}/g,"")),n}function u(e,t){if("string"!=typeof e)throw Error("template should be string!");if("object"!=typeof t)throw Error("data should be object!")}MenuIO=function(u,r,i){function s(){var e,t="object"==typeof i;t||(e=i,i={},i[e]=null),v=m(i),I.addEventListener("click",c),I.addEventListener("contextmenu",f)}function m(e){var t,n="",u=function(e,t){var n='data-menu="js-submenu"',r="data-key=",i="";return t?t+=".":t="",Object.keys(e).forEach(function(s){var m,o="",c="",f="",l="",d=t+s,b=e[s],h="object"==typeof b;h?(c=a(E.MAIN,{items:u(b,d)}),f=" menu-submenu",l=" "+n):x[d]=b,j.icon&&(m=s.replace(/\(|\)/g,"").replace(/\s/g,"-").toLowerCase(),f+=" icon icon-"+m),j.keys&&(o=j.keys[s],o&&(l=" "+r+o)),i+=a(E.ITEM,{name:s,subitems:c,className:f,attribute:l,path:d})}),i};return n=u(e),t=document.createElement("ul"),t.setAttribute("data-name","js-menu"),t.className="menu menu-hidden",t.innerHTML=n,y.appendChild(t),t}function o(e,t){var n,a=M.getItem(e),u=M.isName(a),r=M.isItem(a),i=M.isSubMenu(a);return u&&r||(a=document.elementFromPoint(t.x,t.y),i=M.isSubMenu(a),u=M.isName(a),r=M.isItem(a)),n={name:u,item:r,sub:i}}function c(e,t){var a,u,r=j.afterClick,i=j.beforeClick,s=j.name,m=e.target,c=t||o(m,{x:e.clientX,y:e.clientY});u=n(i,s),c.sub?e.preventDefault():(b(),u||!c.name&&!c.item||(a=h(m),n(a),n(r)))}function f(e){var t=e.target,n=e.clientX,a=e.clientY,u=o(t,{x:n,y:a});u.name||u.item||u.sub?c(e,u):(b(),d(n,a)),e.preventDefault()}function l(t,n){var a="number"==typeof t,u="number"==typeof n,r=p(),i=e.innerHeight;r+n>i&&(n-=r),a&&(v.style.left=t+"px"),u&&(v.style.top=n-14+"px")}function d(e,t){var a=j.beforeShow,u=j.name,r={x:e,y:t,name:u},i=n(a,r);i||(v.classList.remove("menu-hidden"),l(r.x,r.y))}function b(){var e=n(j.beforeClose);e||v.classList.add("menu-hidden")}function h(e){var t,n;return e=M.getName(e),e&&(t=e.getAttribute("data-menu-path")),n=x[t]}function p(){var e,t;return g||(e=getComputedStyle(v),t=e.height,g=parseInt(t,10)),g}if(!(this instanceof MenuIO))return new MenuIO(u,r,i);var v,y,g,I,j={},M=new t,x={},E={MAIN:'<ul data-name="js-menu" class="menu menu-hidden">{{ items }}</ul>',ITEM:'<li data-name="js-menu-item" class="menu-item{{ className }}"{{ attribute }}><label data-menu-path="{{ path }}">{{ name }}</label>{{ subitems }}</li>'};i?(y=I=u,j=r):r?(y=I=u,i=r):(y=document.body,I=e,i=u),this.show=d,this.hide=b,s()}}(window);
|
||||
var MenuIO;!function(e){"use strict";function t(){function e(e){var t;return e&&(t=n(e),t&&(e=e.parentElement)),e}function t(e){var t;return e&&(t=n(e),t||(e=e.querySelector("[data-menu-path]"))),e}function n(e){var t;return e&&(t=e.hasAttribute("data-menu-path")),t}function a(e){var t=r(e,"js-menu-item");return t}function u(e){var t=r(e,"js-menu");return t}function r(e,t,n){var a,u;return n||(n="data-name"),e&&(u=e.getAttribute(n),u===t&&(a=!0)),a}function i(t){var n,a,u="data-menu",i="js-submenu";return a=e(t),n=r(a,i,u)}this.getItem=e,this.getName=t,this.isName=n,this.isItem=a,this.isMenu=u,this.isSubMenu=i}function n(e){var t,n=[].slice.call(arguments,1);return"function"==typeof e&&(t=e.apply(null,n)),t}function a(e,t){var n=e;return u(e,t),Object.keys(t).forEach(function(e){for(var a="{{ "+e+" }}",u=t[e];~n.indexOf(a);)n=n.replace(a,u)}),~n.indexOf("{{")&&(n=n.replace(/{{.*?}}/g,"")),n}function u(e,t){if("string"!=typeof e)throw Error("template should be string!");if("object"!=typeof t)throw Error("data should be object!")}MenuIO=function(u,r,i){function s(){var e,t="object"==typeof i;t||(e=i,i={},i[e]=null),y=o(i),M.addEventListener("click",c),M.addEventListener("contextmenu",f)}function o(e){var t,n="",u=function(e,t){var n='data-menu="js-submenu"',r="data-key=",i="";return t?t+=".":t="",Object.keys(e).forEach(function(s){var o,m="",c="",f="",l="",d=t+s,h=e[s],b="object"==typeof h;b?(c=a(N.MAIN,{items:u(h,d)}),f=" menu-submenu",l=" "+n):E[d]=h,w.icon&&(o=s.replace(/\(|\)/g,"").replace(/\s/g,"-").toLowerCase(),f+=" icon icon-"+o),w.keys&&(m=w.keys[s],m&&(l=" "+r+m)),i+=a(N.ITEM,{name:s,subitems:c,className:f,attribute:l,path:d})}),i};return n=u(e),t=document.createElement("ul"),t.setAttribute("data-name","js-menu"),t.className="menu menu-hidden",t.innerHTML=n,g.appendChild(t),t}function m(e,t){var n,a=x.getItem(e),u=x.isName(a),r=x.isItem(a),i=x.isSubMenu(a);return u&&r||(a=document.elementFromPoint(t.x,t.y),i=x.isSubMenu(a),u=x.isName(a),r=x.isItem(a)),n={name:u,item:r,sub:i}}function c(e,t){var a,u,r=w.afterClick,i=w.beforeClick,s=w.name,o=e.target,c=t||m(o,{x:e.clientX,y:e.clientY});u=n(i,s),c.sub?e.preventDefault():(h(),u||!c.name&&!c.item||(a=b(o),n(a),n(r)))}function f(e){var t=e.target,n=e.clientX,a=e.clientY,u=m(t,{x:n,y:a});u.name||u.item||u.sub?c(e,u):(h(),d(n,a)),e.preventDefault()}function l(t,n){var a="number"==typeof t,u="number"==typeof n,r=p(),i=v(),s=e.innerHeight,o=e.innerWidth;i+t>o&&(t-=i),r+n>s&&(n-=r,0>n&&(n=0)),a&&(y.style.left=t+"px"),u&&(y.style.top=n-14+"px")}function d(e,t){var a=w.beforeShow,u=w.name,r={x:e,y:t,name:u},i=n(a,r);i||(y.classList.remove("menu-hidden"),l(r.x,r.y))}function h(){var e=n(w.beforeClose);e||y.classList.add("menu-hidden")}function b(e){var t,n;return e=x.getName(e),e&&(t=e.getAttribute("data-menu-path")),n=E[t]}function p(){var e,t;return I||(e=getComputedStyle(y),t=e.height,I=parseInt(t,10)),I}function v(){var e,t;return j||(e=getComputedStyle(y),t=e.width,j=parseInt(t,10)),j}if(!(this instanceof MenuIO))return new MenuIO(u,r,i);var y,g,I,j,M,w={},x=new t,E={},N={MAIN:'<ul data-name="js-menu" class="menu menu-hidden">{{ items }}</ul>',ITEM:'<li data-name="js-menu-item" class="menu-item{{ className }}"{{ attribute }}><label data-menu-path="{{ path }}">{{ name }}</label>{{ subitems }}</li>'};i?(g=M=u,w=r):r?(g=M=u,i=r):(g=document.body,M=e,i=u),this.show=d,this.hide=h,s()}}(window);
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"name": "menu",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"version": "0.7.9",
|
||||
"branch": "gh-pages",
|
||||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
||||
"description": "Simple css-based multillevel context menu",
|
||||
"homepage": "http://coderaiser.github.io/menu",
|
||||
|
|
@ -10,7 +11,8 @@
|
|||
"url": "git://github.com/coderaiser/menu-io.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "gulp default"
|
||||
"test": "gulp default",
|
||||
"wisdom": "npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "~3.8.8",
|
||||
|
|
@ -23,6 +25,6 @@
|
|||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.4.x"
|
||||
"node": ">=0.12"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue