1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-21 08:51:34 +02:00
invoiceninja/public/js/ninja.js
David Bomba fa83ce10a3
Implement Typescript (#2514)
* Add contact

* Saving client and contacts

* working on ts implementation

* Need to pass  into TS

* client_edit.ts

* Need to pass  into TS

* declare variables
2018-11-22 22:12:41 +11:00

2 lines
9.9 KiB
JavaScript
Vendored

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jquery"),require("perfect-scrollbar")):"function"==typeof define&&define.amd?define(["exports","jquery","perfect-scrollbar"],t):t(e.coreui={},e.jQuery,e.PerfectScrollbar)}(this,function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}t=t&&t.hasOwnProperty("default")?t.default:t,n=n&&n.hasOwnProperty("default")?n.default:n;var a=function(e){var t="ajaxLoad",n=e.fn[t],r={ACTIVE:"active",NAV_PILLS:"nav-pills",NAV_TABS:"nav-tabs",OPEN:"open",VIEW_SCRIPT:"view-script"},a={CLICK:"click"},i={HEAD:"head",NAV_DROPDOWN:".sidebar-nav .nav-dropdown",NAV_LINK:".sidebar-nav .nav-link",NAV_ITEM:".sidebar-nav .nav-item",VIEW_SCRIPT:".view-script"},s={defaultPage:"main.html",errorPage:"404.html",subpagesDirectory:"views/"},c=function(){function t(e,t){this._config=this._getConfig(t),this._element=e;var n=location.hash.replace(/^#/,"");""!==n?this.setUpUrl(n):this.setUpUrl(this._config.defaultPage),this._addEventListeners()}var n=t.prototype;return n.loadPage=function(t){var n=this._element,o=this._config,a=function e(t,n){void 0===n&&(n=0);var o=document.createElement("script");o.type="text/javascript",o.src=t[n],o.className=r.VIEW_SCRIPT,o.onload=o.onreadystatechange=function(){this.readyState&&"complete"!==this.readyState||t.length>n+1&&e(t,n+1)},document.getElementsByTagName("body")[0].appendChild(o)};e.ajax({type:"GET",url:o.subpagesDirectory+t,dataType:"html",beforeSend:function(){e(i.VIEW_SCRIPT).remove()},success:function(r){var o=document.createElement("div");o.innerHTML=r;var i=Array.from(o.querySelectorAll("script")).map(function(e){return e.attributes.getNamedItem("src").nodeValue});o.querySelectorAll("script").forEach(function(e){return e.parentNode.removeChild(e)}),e("body").animate({scrollTop:0},0),e(n).html(o),i.length&&a(i),window.location.hash=t},error:function(){window.location.href=o.errorPage}})},n.setUpUrl=function(t){e(i.NAV_LINK).removeClass(r.ACTIVE),e(i.NAV_DROPDOWN).removeClass(r.OPEN),e(i.NAV_DROPDOWN+':has(a[href="'+t.replace(/^\//,"").split("?")[0]+'"])').addClass(r.OPEN),e(i.NAV_ITEM+' a[href="'+t.replace(/^\//,"").split("?")[0]+'"]').addClass(r.ACTIVE),this.loadPage(t)},n.loadBlank=function(e){window.open(e)},n.loadTop=function(e){window.location=e},n._getConfig=function(e){return e=Object.assign({},s,e)},n._addEventListeners=function(){var t=this;e(document).on(a.CLICK,i.NAV_LINK+'[href!="#"]',function(e){e.preventDefault(),e.stopPropagation(),"_top"===e.currentTarget.target?t.loadTop(e.currentTarget.href):"_blank"===e.currentTarget.target?t.loadBlank(e.currentTarget.href):t.setUpUrl(e.currentTarget.getAttribute("href"))})},t._jQueryInterface=function(n){return this.each(function(){var r=e(this).data("coreui.ajaxLoad"),o="object"==typeof n&&n;r||(r=new t(this,o),e(this).data("coreui.ajaxLoad",r))})},o(t,null,[{key:"VERSION",get:function(){return"2.0.18"}},{key:"Default",get:function(){return s}}]),t}();return e.fn[t]=c._jQueryInterface,e.fn[t].Constructor=c,e.fn[t].noConflict=function(){return e.fn[t]=n,c._jQueryInterface},c}(t),i=function(e){return-1!==e.map(function(e){return document.body.classList.contains(e)}).indexOf(!0)},s=function(e,t){var n=t.indexOf(e),r=t.slice(0,n+1);i(r)?r.map(function(e){return document.body.classList.remove(e)}):document.body.classList.add(e)},c=function(e){var t="aside-menu",n="coreui.aside-menu",r=e.fn[t],a={CLICK:"click",LOAD_DATA_API:"load.coreui.aside-menu.data-api",TOGGLE:"toggle"},i={BODY:"body",ASIDE_MENU:".aside-menu",ASIDE_MENU_TOGGLER:".aside-menu-toggler"},c=["aside-menu-show","aside-menu-sm-show","aside-menu-md-show","aside-menu-lg-show","aside-menu-xl-show"],u=function(){function t(e){this._element=e,this._addEventListeners()}return t.prototype._addEventListeners=function(){e(i.ASIDE_MENU_TOGGLER).on(a.CLICK,function(e){e.preventDefault(),e.stopPropagation();var t=e.currentTarget.dataset.toggle;s(t,c)})},t._jQueryInterface=function(){return this.each(function(){var r=e(this),o=r.data(n);o||(o=new t(this),r.data(n,o))})},o(t,null,[{key:"VERSION",get:function(){return"2.0.18"}}]),t}();return e(window).on(a.LOAD_DATA_API,function(){var t=e(i.ASIDE_MENU);u._jQueryInterface.call(t)}),e.fn[t]=u._jQueryInterface,e.fn[t].Constructor=u,e.fn[t].noConflict=function(){return e.fn[t]=r,u._jQueryInterface},u}(t),u=function(e){var t="sidebar",r=e.fn[t],a={transition:400},i={ACTIVE:"active",BRAND_MINIMIZED:"brand-minimized",NAV_DROPDOWN_TOGGLE:"nav-dropdown-toggle",OPEN:"open",SIDEBAR_FIXED:"sidebar-fixed",SIDEBAR_MINIMIZED:"sidebar-minimized",SIDEBAR_OFF_CANVAS:"sidebar-off-canvas"},c={CLICK:"click",DESTROY:"destroy",INIT:"init",LOAD_DATA_API:"load.coreui.sidebar.data-api",TOGGLE:"toggle",UPDATE:"update"},u={BODY:"body",BRAND_MINIMIZER:".brand-minimizer",NAV_DROPDOWN_TOGGLE:".nav-dropdown-toggle",NAV_DROPDOWN_ITEMS:".nav-dropdown-items",NAV_ITEM:".nav-item",NAV_LINK:".nav-link",NAVIGATION_CONTAINER:".sidebar-nav",NAVIGATION:".sidebar-nav > .nav",SIDEBAR:".sidebar",SIDEBAR_MINIMIZER:".sidebar-minimizer",SIDEBAR_TOGGLER:".sidebar-toggler"},l=["sidebar-show","sidebar-sm-show","sidebar-md-show","sidebar-lg-show","sidebar-xl-show"],d=function(){function t(e){this._element=e,this.ps=null,this.perfectScrollbar(c.INIT),this.setActiveLink(),this._addEventListeners()}var r=t.prototype;return r.perfectScrollbar=function(e){var t=this;void 0!==n&&(e!==c.INIT||document.body.classList.contains(i.SIDEBAR_MINIMIZED)||(this.ps=this.makeScrollbar()),e===c.DESTROY&&this.destroyScrollbar(),e===c.TOGGLE&&(document.body.classList.contains(i.SIDEBAR_MINIMIZED)?this.destroyScrollbar():this.ps=this.makeScrollbar()),e!==c.UPDATE||document.body.classList.contains(i.SIDEBAR_MINIMIZED)||setTimeout(function(){t.destroyScrollbar(),t.ps=t.makeScrollbar()},a.transition))},r.makeScrollbar=function(e){void 0===e&&(e=u.NAVIGATION_CONTAINER);var t=new n(document.querySelector(e),{suppressScrollX:!0});return t.isRtl=!1,t},r.destroyScrollbar=function(){this.ps&&(this.ps.destroy(),this.ps=null)},r.setActiveLink=function(){e(u.NAVIGATION).find(u.NAV_LINK).each(function(t,n){var r=n,o=String(window.location).split("?")[0];"#"===o.substr(o.length-1)&&(o=o.slice(0,-1)),e(e(r))[0].href===o&&e(r).addClass(i.ACTIVE).parents(u.NAV_DROPDOWN_ITEMS).add(r).each(function(t,n){r=n,e(r).parent().addClass(i.OPEN)})})},r._addEventListeners=function(){var t=this;e(u.BRAND_MINIMIZER).on(c.CLICK,function(t){t.preventDefault(),t.stopPropagation(),e(u.BODY).toggleClass(i.BRAND_MINIMIZED)}),e(u.NAV_DROPDOWN_TOGGLE).on(c.CLICK,function(n){n.preventDefault(),n.stopPropagation();var r=n.target;e(r).parent().toggleClass(i.OPEN),t.perfectScrollbar(c.UPDATE)}),e(u.SIDEBAR_MINIMIZER).on(c.CLICK,function(n){n.preventDefault(),n.stopPropagation(),e(u.BODY).toggleClass(i.SIDEBAR_MINIMIZED),t.perfectScrollbar(c.TOGGLE)}),e(u.SIDEBAR_TOGGLER).on(c.CLICK,function(e){e.preventDefault(),e.stopPropagation();var t=e.currentTarget.dataset.toggle;s(t,l)}),e(u.NAVIGATION+" > "+u.NAV_ITEM+" "+u.NAV_LINK+":not("+u.NAV_DROPDOWN_TOGGLE+")").on(c.CLICK,function(){document.body.classList.remove("sidebar-show")})},t._jQueryInterface=function(){return this.each(function(){var n=e(this),r=n.data("coreui.sidebar");r||(r=new t(this),n.data("coreui.sidebar",r))})},o(t,null,[{key:"VERSION",get:function(){return"2.0.18"}}]),t}();return e(window).on(c.LOAD_DATA_API,function(){var t=e(u.SIDEBAR);d._jQueryInterface.call(t)}),e.fn[t]=d._jQueryInterface,e.fn[t].Constructor=d,e.fn[t].noConflict=function(){return e.fn[t]=r,d._jQueryInterface},d}(t),l=function(){for(var e={},t=document.styleSheets,n="",r=t.length-1;r>-1;r--){for(var o=t[r].cssRules,a=o.length-1;a>-1;a--)if(".ie-custom-properties"===o[a].selectorText){n=o[a].cssText;break}if(n)break}return n=n.substring(n.lastIndexOf("{")+1,n.lastIndexOf("}")),n.split(";").forEach(function(t){if(t){var n=t.split(": ")[0],r=t.split(": ")[1];n&&r&&(e["--"+n.trim()]=r.trim())}}),e},d=function(){return Boolean(document.documentMode)&&document.documentMode>=10},f=function(e){return e.match(/^--.*/i)},I=function(e,t){void 0===t&&(t=document.body);var n;if(f(e)&&d()){n=l()[e]}else n=window.getComputedStyle(t,null).getPropertyValue(e).replace(/^\s/,"");return n},p=function(e){if(void 0===e)throw new Error("Hex color is not defined");if(!e.match(/^#(?:[0-9a-f]{3}){1,2}$/i))throw new Error(e+" is not a valid hex color");var t,n,r;return 7===e.length?(t=parseInt(e.substring(1,3),16),n=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16)):(t=parseInt(e.substring(1,2),16),n=parseInt(e.substring(2,3),16),r=parseInt(e.substring(3,5),16)),"rgba("+t+", "+n+", "+r+")"},h=function(e,t){if(void 0===t&&(t=100),void 0===e)throw new Error("Hex color is not defined");if(!e.match(/^#(?:[0-9a-f]{3}){1,2}$/i))throw new Error(e+" is not a valid hex color");var n,r,o;return 7===e.length?(n=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),o=parseInt(e.substring(5,7),16)):(n=parseInt(e.substring(1,2),16),r=parseInt(e.substring(2,3),16),o=parseInt(e.substring(3,5),16)),"rgba("+n+", "+r+", "+o+", "+t/100+")"},g=function(e){if(void 0===e)throw new Error("Hex color is not defined");if("transparent"===e)return"#00000000";var t=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);if(!t)throw new Error(e+" is not a valid rgb color");var n="0"+parseInt(t[1],10).toString(16),r="0"+parseInt(t[2],10).toString(16),o="0"+parseInt(t[3],10).toString(16);return"#"+n.slice(-2)+r.slice(-2)+o.slice(-2)};!function(e){if(void 0===e)throw new TypeError("CoreUI's JavaScript requires jQuery. jQuery must be included before CoreUI's JavaScript.");var t=e.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1===t[0]&&9===t[1]&&t[2]<1||t[0]>=4)throw new Error("CoreUI's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}(t),window.getStyle=I,window.hexToRgb=p,window.hexToRgba=h,window.rgbToHex=g,e.AjaxLoad=a,e.AsideMenu=c,e.Sidebar=u,Object.defineProperty(e,"__esModule",{value:!0})});