From fb42ab8113aa673f3be67a85a3c30919d3f0ac64 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 5 Feb 2016 06:59:06 -0500 Subject: [PATCH] feature(bower) menu v1.0.0 --- bower.json | 4 ++-- json/modules.json | 6 +++--- modules/menu/.bower.json | 10 +++++----- modules/menu/ChangeLog | 10 ++++++++++ modules/menu/README.md | 2 +- modules/menu/bower.json | 2 +- modules/menu/menu-io.js | 30 +++++++++++++++++++++++++++--- modules/menu/menu-io.min.js | 2 +- modules/menu/package.json | 8 +++++--- 9 files changed, 55 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index b7fae827..27a01963 100644 --- a/bower.json +++ b/bower.json @@ -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" } } diff --git a/json/modules.json b/json/modules.json index 24b5b4b8..1735428b 100644 --- a/json/modules.json +++ b/json/modules.json @@ -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", diff --git a/modules/menu/.bower.json b/modules/menu/.bower.json index 3f302f2c..dd056906 100644 --- a/modules/menu/.bower.json +++ b/modules/menu/.bower.json @@ -1,6 +1,6 @@ { "name": "menu", - "version": "0.7.9", + "version": "1.0.0", "homepage": "https://github.com/coderaiser/menu-io", "authors": [ "coderaiser " @@ -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 } \ No newline at end of file diff --git a/modules/menu/ChangeLog b/modules/menu/ChangeLog index d987a622..559eec75 100644 --- a/modules/menu/ChangeLog +++ b/modules/menu/ChangeLog @@ -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: diff --git a/modules/menu/README.md b/modules/menu/README.md index e50dda15..02d755e8 100644 --- a/modules/menu/README.md +++ b/modules/menu/README.md @@ -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. diff --git a/modules/menu/bower.json b/modules/menu/bower.json index 38c08096..00bc138c 100644 --- a/modules/menu/bower.json +++ b/modules/menu/bower.json @@ -1,6 +1,6 @@ { "name": "menu", - "version": "0.7.9", + "version": "1.0.0", "homepage": "https://github.com/coderaiser/menu-io", "authors": [ "coderaiser " diff --git a/modules/menu/menu-io.js b/modules/menu/menu-io.js index d5f56851..4ec06f94 100644 --- a/modules/menu/menu-io.js +++ b/modules/menu/menu-io.js @@ -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(); }; diff --git a/modules/menu/menu-io.min.js b/modules/menu/menu-io.min.js index 2c9c0d6d..852ce149 100755 --- a/modules/menu/menu-io.min.js +++ b/modules/menu/menu-io.min.js @@ -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:'',ITEM:''};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); \ No newline at end of file +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:'',ITEM:''};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); \ No newline at end of file diff --git a/modules/menu/package.json b/modules/menu/package.json index 9ec5ba8d..dc894283 100644 --- a/modules/menu/package.json +++ b/modules/menu/package.json @@ -1,7 +1,8 @@ { "name": "menu", + "version": "1.0.0", "private": true, - "version": "0.7.9", + "branch": "gh-pages", "author": "coderaiser (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" } }