From 9c231ad7edc548d778cf1bb065b9b2c98394839d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 22 Jul 2015 10:35:00 -0400 Subject: [PATCH] feature(bower) menu-io v0.7.9 --- bower.json | 4 ++-- json/modules.json | 2 +- modules/menu/.bower.json | 13 +++++++------ modules/menu/ChangeLog | 6 ++++++ modules/menu/bower.json | 2 +- modules/menu/menu-io.js | 35 ++++++++++++++++++++++++++++------- modules/menu/menu-io.min.js | 2 +- modules/menu/package.json | 2 +- 8 files changed, 47 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index 34b3ce14..4732e3f3 100644 --- a/bower.json +++ b/bower.json @@ -23,7 +23,6 @@ "dependencies": { "fancybox": "~2.1.5", "jquery": "~2.1.4", - "menu": "~0.7.8", "format-io": "~0.9.6", "rendy": "~1.1.0", "github": "~0.10.6", @@ -31,6 +30,7 @@ "domtokenlist-shim": "~1.1.0", "promise-polyfill": "~2.1.0", "emitify": "~1.2.0", - "philip": "~1.3.0" + "philip": "~1.3.0", + "menu": "~0.7.9" } } diff --git a/json/modules.json b/json/modules.json index 7430a30b..e4e6a3e3 100644 --- a/json/modules.json +++ b/json/modules.json @@ -33,7 +33,7 @@ ] }, { "name": "menu", - "version": "0.7.8", + "version": "0.7.9", "local": [ "/modules/menu/menu-io.css", "/modules/menu/menu-io.js" diff --git a/modules/menu/.bower.json b/modules/menu/.bower.json index e90c58bb..3f302f2c 100644 --- a/modules/menu/.bower.json +++ b/modules/menu/.bower.json @@ -1,6 +1,6 @@ { "name": "menu", - "version": "0.7.8", + "version": "0.7.9", "homepage": "https://github.com/coderaiser/menu-io", "authors": [ "coderaiser " @@ -20,13 +20,14 @@ "gulpfile.js", "node_modules" ], - "_release": "0.7.8", + "_release": "0.7.9", "_resolution": { "type": "version", - "tag": "v0.7.8", - "commit": "cc27e55d884962ed21e7eb3abedebe01acec7311" + "tag": "v0.7.9", + "commit": "272a723bfa7a02755dc53a96c1219571aea4fef3" }, "_source": "git://github.com/coderaiser/menu-io.git", - "_target": "~0.7.8", - "_originalSource": "menu" + "_target": "~0.7.9", + "_originalSource": "menu", + "_direct": true } \ No newline at end of file diff --git a/modules/menu/ChangeLog b/modules/menu/ChangeLog index aef2f073..d987a622 100644 --- a/modules/menu/ChangeLog +++ b/modules/menu/ChangeLog @@ -1,3 +1,9 @@ +2015.07.22, v0.7.9 + +feature: +- (menu) rendy v1.1.0 + + 2015.02.20, v0.7.8 feature: diff --git a/modules/menu/bower.json b/modules/menu/bower.json index 12a3292b..38c08096 100644 --- a/modules/menu/bower.json +++ b/modules/menu/bower.json @@ -1,6 +1,6 @@ { "name": "menu", - "version": "0.7.8", + "version": "0.7.9", "homepage": "https://github.com/coderaiser/menu-io", "authors": [ "coderaiser " diff --git a/modules/menu/menu-io.js b/modules/menu/menu-io.js index a4b1242d..d5f56851 100644 --- a/modules/menu/menu-io.js +++ b/modules/menu/menu-io.js @@ -364,22 +364,43 @@ var MenuIO; return ret; } + /* + * rendy v1.1.0 + * https://github.com/coderaiser/rendy + */ + + /** + * render template with data + * + * @param templ + * @param data + */ function rendy(templ, data) { - var str, regExp, expr, - result = templ; + var result = templ; + + check(templ, data); Object .keys(data) .forEach(function(param) { - str = data[param]; - expr = '{{\\s' + param + '\\s}}'; - regExp = RegExp(expr, 'g'); - result = result.replace(regExp, str); + var name = '{{ ' + param + ' }}', + str = data[param]; + + while(~result.indexOf(name)) + result = result.replace(name, str); }); if (~result.indexOf('{{')) - result = result.replace(/{{\s.*\s}}/, ''); + result = result.replace(/{{.*?}}/g, ''); return result; } + + function check(templ, data) { + if (typeof templ !== 'string') + throw(Error('template should be string!')); + + if (typeof data !== 'object') + throw(Error('data should be object!')); + } })(window); diff --git a/modules/menu/menu-io.min.js b/modules/menu/menu-io.min.js index fe29bbdb..2c9c0d6d 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=i(e,"js-menu-item");return t}function u(e){var t=i(e,"js-menu");return t}function i(e,t,n){var a,u;return n||(n="data-name"),e&&(u=e.getAttribute(n),u===t&&(a=!0)),a}function r(t){var n,a,u="data-menu",r="js-submenu";return a=e(t),n=i(a,r,u)}this.getItem=e,this.getName=t,this.isName=n,this.isItem=a,this.isMenu=u,this.isSubMenu=r}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,a,u,i=e;return Object.keys(t).forEach(function(e){n=t[e],u="{{\\s"+e+"\\s}}",a=RegExp(u,"g"),i=i.replace(a,n)}),~i.indexOf("{{")&&(i=i.replace(/{{\s.*\s}}/,"")),i}MenuIO=function(u,i,r){function s(){var e,t="object"==typeof r;t||(e=r,r={},r[e]=null),v=m(r),I.addEventListener("click",o),I.addEventListener("contextmenu",l)}function m(e){var t,n="",u=function(e,t){var n='data-menu="js-submenu"',i="data-key=",r="";return t?t+=".":t="",Object.keys(e).forEach(function(s){var m,c="",o="",l="",f="",d=t+s,b=e[s],h="object"==typeof b;h?(o=a(N.MAIN,{items:u(b,d)}),l=" menu-submenu",f=" "+n):x[d]=b,M.icon&&(m=s.replace(/\(|\)/g,"").replace(/\s/g,"-").toLowerCase(),l+=" icon icon-"+m),M.keys&&(c=M.keys[s],c&&(f=" "+i+c)),r+=a(N.ITEM,{name:s,subitems:o,className:l,attribute:f,path:d})}),r};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 c(e,t){var n,a=j.getItem(e),u=j.isName(a),i=j.isItem(a),r=j.isSubMenu(a);return u&&i||(a=document.elementFromPoint(t.x,t.y),r=j.isSubMenu(a),u=j.isName(a),i=j.isItem(a)),n={name:u,item:i,sub:r}}function o(e,t){var a,u,i=M.afterClick,r=M.beforeClick,s=M.name,m=e.target,o=t||c(m,{x:e.clientX,y:e.clientY});u=n(r,s),o.sub?e.preventDefault():(b(),u||!o.name&&!o.item||(a=h(m),n(a),n(i)))}function l(e){var t=e.target,n=e.clientX,a=e.clientY,u=c(t,{x:n,y:a});u.name||u.item||u.sub?o(e,u):(b(),d(n,a)),e.preventDefault()}function f(t,n){var a="number"==typeof t,u="number"==typeof n,i=p(),r=e.innerHeight;i+n>r&&(n-=i),a&&(v.style.left=t+"px"),u&&(v.style.top=n-14+"px")}function d(e,t){var a=M.beforeShow,u=M.name,i={x:e,y:t,name:u},r=n(a,i);r||(v.classList.remove("menu-hidden"),f(i.x,i.y))}function b(){var e=n(M.beforeClose);e||v.classList.add("menu-hidden")}function h(e){var t,n;return e=j.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,i,r);var v,y,g,I,M={},j=new t,x={},N={MAIN:'',ITEM:''};r?(y=I=u,M=i):i?(y=I=u,r=i):(y=document.body,I=e,r=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),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 diff --git a/modules/menu/package.json b/modules/menu/package.json index c386c3eb..9ec5ba8d 100644 --- a/modules/menu/package.json +++ b/modules/menu/package.json @@ -1,7 +1,7 @@ { "name": "menu", "private": true, - "version": "0.7.8", + "version": "0.7.9", "author": "coderaiser (https://github.com/coderaiser)", "description": "Simple css-based multillevel context menu", "homepage": "http://coderaiser.github.io/menu",