{"version":3,"file":"Compilator.Common-5.55.8.11.min.js","names":["compilator","common","isCharacter","keyCode","ctrlVPressed","e","key","window","event","which","ctrl","ctrlKey","ctrlCPressed","ctrlXPressed","clickOnEnterPress","buttonClientId","$","click","isGuid","str","test","arrowDown","arrowUp","enterPressed","telerikDateSelected","sender","args","control","setTimeout","get_dateInput","focus","togglePageSection","clickedElement","callbackFunction","initFunction","Promise","resolve","then","$common","runTogglePageSection","content","parent","next","horizontalRule","find","arrowIcon","sectionHeader","hasClass","prev","prop","off","is","toggleClass","animate","opacity","slideUp","bind","this","slideDown","getContainerContentHeight","containerId","containerChildren","children","height","each","index","child","jqChild","tagName","outerHeight","getNotUsedParentHeightExcludingElement","elementId","remainingHeight","id","setElementToRemainingHeight","animateElementToRemainingHeight","animationDuration","newHeight","duration","hideDueWarning","ajax","suppressErrors","url","type","remove","attachAutoComplete","pricelistId","includeServiceArticles","articleNumberTextbox","autocomplete","source","request","response","$url","OrderMVC","Order","SearchArticleAutoSuggest","searchText","term","success","data","longestArticleNo","reduce","result","val","Math","max","isNaN","ArticleNo","length","parseInt","toString","map","n","i","paddingSize","label","ShortText","value","$string","repeat","error","select","ui","v","item","trim","blur","html","minLength","keypress","hide","_renderItem","ul","append","appendTo","jQuery","fn","scrollTo","elem","speed","scrollTop","offset","top","undefined","String","prototype","startsWith","searchString","position","indexOf","getKendoValidator","settings","kendoValidator","document","on","$this","offsetWidth","scrollWidth","attr","text","keycode","target","td","closest","nextInput","kendoGrid","currentTarget","saveRow","dataSource","options","batch","transport","create","one","addRow","cancelRow","charCode","element","srcElement"],"sources":["Compilator.Common.js"],"mappings":"AAAA,aAQA,IAAIA,WAAaA,YAAc,CAAC,EAEhCA,WAAWC,OAAS,CAElBC,YAAa,SAAUC,GACrB,OAAkB,IAAXA,GAAiBA,GAAW,IAAMA,GAAW,IAAMA,GAAW,IAAMA,GAAW,KAAOA,GAAW,KAAOA,GAAW,KAAOA,GAAW,KAAOA,GAAW,KAAkB,KAAXA,CACv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n$common      - compilator.common\r\n\r\n*/\r\n// Defines compilator global namespace.\r\nvar compilator = compilator || {};\r\n\r\ncompilator.common = {\r\n\r\n  isCharacter: function (keyCode) {\r\n    return keyCode == 32 || keyCode >= 48 && keyCode <= 90 || keyCode >= 96 && keyCode <= 111 || keyCode >= 186 && keyCode <= 192 || keyCode >= 219 && keyCode <= 222 || keyCode == 229;\r\n  },\r\n  ctrlVPressed: function (e) {\r\n    e = e || window.event;\r\n    var key = e.which || e.keyCode; // keyCode detection\r\n    var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false); // ctrl detection\r\n\r\n    if (key == 86 && ctrl) {\r\n      return true;\r\n    } \r\n    return false;\r\n  },\r\n  ctrlCPressed: function (e) {\r\n    e = e || window.event;\r\n    var key = e.which || e.keyCode; // keyCode detection\r\n    var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false); // ctrl detection\r\n\r\n    if (key == 67 && ctrl) {\r\n      return true;\r\n    }\r\n    return false;\r\n  },\r\n  ctrlXPressed: function (e) {\r\n    e = e || window.event;\r\n    var key = e.which || e.keyCode; // keyCode detection\r\n    var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false); // ctrl detection\r\n\r\n    if (key == 88  && ctrl) {\r\n      return true;\r\n    }\r\n    return false;\r\n  },\r\n\r\n\r\n  //Fires click event of a button when enterkey is pressed.\r\n  clickOnEnterPress: function (event, buttonClientId) { //PressEnter()\r\n    if (event.keyCode === 13) {\r\n      $('#' + buttonClientId).click();\r\n    }\r\n  },\r\n\r\n\r\n  isGuid: function (str) {\r\n    const reg = /^(\\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\\}{0,1})$/;\r\n    return reg.test(str);\r\n  },\r\n\r\n  /* Returns true if arrow down key was typed otherwise false. */\r\n  arrowDown: function (e) {\r\n    const keyCode = e.keyCode || e.which,\r\n          key = { left: 37, up: 38, right: 39, down: 40, enter: 13 };\r\n    switch (keyCode) {\r\n      case key.down:\r\n        return true;\r\n      case key.enter:\r\n        return true;\r\n    }\r\n    return false;\r\n  },\r\n\r\n  /* Returns true if arrow up key was typed otherwise false. */\r\n  arrowUp: function (e) {\r\n    const keyCode = e.keyCode || e.which,\r\n            arrow = { left: 37, up: 38, right: 39, down: 40 };\r\n    switch (keyCode) {\r\n      case arrow.up:\r\n        return true;\r\n    }\r\n    return false;\r\n  },\r\n  /* Returns true if enter key was typed otherwise false. */\r\n  enterPressed: function (e) {\r\n      const keyCode = e.keyCode || e.which,\r\n          keyDown = { enter: 13};\r\n      switch (keyCode) {\r\n      case keyDown.enter:\r\n          return true;\r\n      }\r\n      return false;\r\n\r\n  },\r\n  telerikDateSelected: function (sender, args) {\r\n    const control = sender;\r\n    setTimeout(function () {\r\n      control.get_dateInput().focus()\r\n    }, 1);\r\n  },\r\n\r\n  togglePageSection: function (clickedElement, callbackFunction, initFunction) {\r\n\r\n    if (initFunction) {\r\n      const initPromise = Promise.resolve(window[initFunction](clickedElement));\r\n      initPromise.then(function () {\r\n        $common.runTogglePageSection(clickedElement, callbackFunction, initFunction);\r\n      });\r\n    }\r\n    else {\r\n      $common.runTogglePageSection(clickedElement, callbackFunction, initFunction);\r\n    }\r\n  },\r\n\r\n  runTogglePageSection: function (clickedElement, callbackFunction, initFunction) {\r\n    // Find elements\r\n    const content = $($(clickedElement).parent().next(\".PageSectionContent\"));\r\n    const horizontalRule = content.find(\"hr:first-of-type\");\r\n    let arrowIcon;\r\n    let sectionHeader;\r\n\r\n    if (!$(clickedElement).hasClass(\"k-icon\")) {\r\n      sectionHeader = $(clickedElement);\r\n      arrowIcon = $(sectionHeader.prev());\r\n    }\r\n    else {\r\n      arrowIcon = $(clickedElement);\r\n      sectionHeader = $(clickedElement).next();\r\n    }\r\n\r\n    // Unbind click functions while animating\r\n    arrowIcon.prop('onclick', null).off('click');\r\n    sectionHeader.prop('onclick', null).off('click');\r\n\r\n    // Animate\r\n    if (content.is(\":visible\")) {\r\n      arrowIcon.toggleClass(\"rotate-180\");\r\n      horizontalRule.animate({ opacity: 0 }, 1, function () {\r\n        content.slideUp(\"fast\", function () {\r\n          arrowIcon.bind(\"click\", function () { $common.togglePageSection(this, callbackFunction, initFunction) });\r\n          sectionHeader.bind(\"click\", function () { $common.togglePageSection(this, callbackFunction, initFunction) });\r\n\r\n          if (callbackFunction) {\r\n            window[callbackFunction](clickedElement);\r\n          }\r\n        });\r\n      });\r\n    }\r\n    else {\r\n      arrowIcon.toggleClass(\"rotate-180\");\r\n      content.slideDown(\"fast\", function () {\r\n        horizontalRule.animate({ opacity: 1 }, 1, function () {\r\n          arrowIcon.bind(\"click\", function () { $common.togglePageSection(this, callbackFunction, initFunction) });\r\n          sectionHeader.bind(\"click\", function () { $common.togglePageSection(this, callbackFunction, initFunction) });\r\n\r\n          if (callbackFunction) {\r\n            window[callbackFunction](clickedElement);\r\n          }\r\n        });\r\n      });\r\n    }\r\n  },\r\n\r\n  getContainerContentHeight: function (containerId) {\r\n    const containerChildren = $(\"#\" + containerId).children();\r\n    let height = 0;\r\n\r\n    // Loop container children\r\n    containerChildren.each(function (index, child) {\r\n      const jqChild = $(child);\r\n\r\n      // Remove visible children heights when not supplied element\r\n      if (child.tagName && jqChild.outerHeight(true) > 0 && jqChild.is(\":visible\")) {\r\n        height += jqChild.outerHeight(true);\r\n      }\r\n    });\r\n\r\n    return height;\r\n  },\r\n\r\n  getNotUsedParentHeightExcludingElement: function (containerId, elementId) {\r\n    // Get container height\r\n    let remainingHeight = $(\"#\" + containerId).outerHeight(true);\r\n    const containerChildren = $(\"#\" + containerId).children();\r\n\r\n    // Loop container children\r\n    containerChildren.each(function (index, child) {\r\n      const jqChild = $(child);\r\n\r\n      // Remove visible children heights when not supplied element\r\n      if (child.tagName && jqChild.outerHeight(true) > 0 && jqChild.is(\":visible\")) {\r\n        if (child.id && child.id === elementId) {\r\n          return true;\r\n        }\r\n        remainingHeight = remainingHeight - jqChild.outerHeight(true);\r\n      }\r\n    });\r\n\r\n    return remainingHeight;\r\n  },\r\n\r\n  setElementToRemainingHeight: function (containerId, elementId) {\r\n    const height = $common.getNotUsedParentHeightExcludingElement(containerId, elementId);\r\n    $(\"#\" + elementId).height(height);\r\n  },\r\n\r\n  animateElementToRemainingHeight: function (containerId, elementId, animationDuration) {\r\n    const newHeight = $common.getNotUsedParentHeightExcludingElement(containerId, elementId);\r\n\r\n    $(\"#\" + elementId).animate({\r\n      height: newHeight\r\n    }, {\r\n      duration: animationDuration\r\n    });\r\n  },\r\n\r\n  hideDueWarning: function () {\r\n    $.ajax({\r\n      suppressErrors: true,\r\n      url: \"../Layout/Layout/HideDueWarning\",\r\n      type: \"POST\"\r\n    });\r\n    $(\".due-warning-container\").remove();\r\n  },\r\n\r\n  attachAutoComplete: function (ctrl, pricelistId, includeServiceArticles) {\r\n    const articleNumberTextbox = $(ctrl);\r\n    //Only attach AutoComplete if it hasn't already been attached to this input.\r\n    if (!articleNumberTextbox.hasClass(\"ui-autocomplete-input\")) {\r\n      articleNumberTextbox.autocomplete({\r\n        source: function (request, response) {\r\n          $url.OrderMVC.Order.SearchArticleAutoSuggest.ajax({\r\n            searchText: request.term,\r\n            pricelistId: pricelistId,\r\n            includeServiceArticles: includeServiceArticles\r\n          }, {\r\n            success: function (data) {\r\n              //Get the longest ArticleNo (longest in number of characters). So that it can be used for calculating the space needed \r\n              //for making the text aligned.\r\n              const longestArticleNo = data.reduce(\r\n                function (result, val) {\r\n                  return Math.max(result, isNaN(val.ArticleNo) ? val.ArticleNo.length : parseInt(val.ArticleNo).toString().length);\r\n                }, 0);\r\n\r\n              response($.map(data, function (n, i) {\r\n                //Calculate the number of spaces needed to align the text.\r\n                //For some reason we need to double the padding to get it to align correctly.\r\n                const paddingSize = 2 * (longestArticleNo - n.ArticleNo.toString().length + 1);\r\n                const nonBreakingSpace = \"\\xa0\";\r\n\r\n                return {\r\n                  label: n.ShortText,\r\n                  value: n.ArticleNo + $string.repeat(nonBreakingSpace, paddingSize)\r\n                };\r\n              }));\r\n            },\r\n            error: function () { }\r\n          });\r\n        },\r\n\r\n        //Set the input value to the ArticleNo when selecting an item.\r\n        select: function (event, ui) {\r\n          //The value has padding because of the aligning, so we need to remove the padding before setting the value on the input.\r\n          const v = ui.item.value.trim();\r\n          this.value = v;\r\n\r\n          articleNumberTextbox.blur();\r\n          return false;\r\n        },\r\n\r\n        html: true,\r\n        minLength: 3\r\n      })\r\n      .keypress(function (e) {\r\n        if (e.which === 13) {\r\n          $(\".ui-menu-item\").hide();\r\n        }\r\n      })\r\n      //Override _renderItem so that we're able to use html to style the items.\r\n      .data(\"ui-autocomplete\")._renderItem = function (ul, item) {\r\n        return $(\"<li></li>\")\r\n          .data(\"item.autocomplete\", item)\r\n          .append(\"<div><span class='FontBold'>\" + item.value + \"</span>\" + item.label + \"</div>\")\r\n          .appendTo(ul);\r\n      };\r\n    }\r\n  },\r\n}\r\n\r\n\r\n// Scroll function used in most pages.\r\njQuery.fn.scrollTo = function (elem, speed) {\r\n  $(this).animate({\r\n    scrollTop: $(this).scrollTop() - $(this).offset().top + $(elem).offset().top - 25\r\n  }, speed === undefined ? 1000 : speed);\r\n\r\n  return this;\r\n};\r\n\r\n// Polyfill\r\nif (!String.prototype.startsWith) {\r\n  String.prototype.startsWith = function (searchString, position) {\r\n    position = position || 0;\r\n    return this.indexOf(searchString, position) === position;\r\n  };\r\n}\r\n\r\njQuery.fn.getKendoValidator = function (settings) {\r\n  if (settings) {\r\n    return $(this).kendoValidator(settings).data('kendoValidator');\r\n  }\r\n  return $(this).data('kendoValidator') || $(this).kendoValidator(settings).data('kendoValidator');\r\n}\r\n\r\n$(function () {\r\n  // Bind all elements with the label class to show tootip with full text if cut-of by css ellipsis.\r\n  $(document).on('mouseenter', '.label, .k-tooltip', function () {\r\n    const $this = $(this);\r\n\r\n    if (this.offsetWidth < this.scrollWidth && !$this.attr('title')) {\r\n      $this.attr('title', $this.text());\r\n    }\r\n  });\r\n\r\n  $(document).on('click', '.k-tooltip-validation', function () {\r\n    $(this).hide();\r\n  });\r\n\r\n  //Add global listener for handling \"enter\" on kendo grids\r\n  $(document).on('keyup', '[data-role=grid][data-continue-on-enter]', function (event) {\r\n    const keycode = (event.keyCode ? event.keyCode : event.which);\r\n    if (keycode === 13) {\r\n      $(event.target).blur();\r\n      const td = $(event.target).closest('td');\r\n      const tr = $(td).closest('tr');\r\n      if (tr.hasClass('k-grid-edit-row')) {\r\n        const nextInput = $('input:enabled', td.next('td'));\r\n        if (nextInput.length > 0) {\r\n          nextInput.focus();\r\n        }\r\n        else {\r\n          const kendoGrid = $(event.currentTarget).data('kendoGrid');\r\n          kendoGrid.saveRow();\r\n          if (!kendoGrid.dataSource.options.batch && kendoGrid.dataSource.transport.options && kendoGrid.dataSource.transport.options.create) {\r\n            kendoGrid.one('dataBound', function () {\r\n              kendoGrid.addRow();\r\n            });\r\n          } else {\r\n            kendoGrid.addRow();\r\n          }\r\n        }\r\n      }\r\n    }\r\n    else if (keycode === 27) {\r\n      const kendoGrid = $(event.currentTarget).data('kendoGrid');\r\n      kendoGrid.cancelRow();\r\n    }\r\n  });\r\n\r\n  //Add global listener for handling \"enter\" on kendo grids in forms\r\n  //  - Allow enter if textarea/button/link\r\n  //  - Otherwise don't allow enter in grid\r\n  $(document).on('keydown', 'form [data-role=grid]', function (e) {\r\n    e = e || event;\r\n    const isAnythingButEnter = (e.keyCode || e.which || e.charCode || 0) !== 13;\r\n    if (isAnythingButEnter) {\r\n      // User did not push enter -> allow\r\n      return true;\r\n    }\r\n    const element = (e.target || e.srcElement);\r\n    const isAllowed = /^(textarea|button|a)$/i.test(element.tagName);\r\n    return isAllowed;\r\n  });\r\n});\r\n\r\nvar $common = compilator.common;"]}