HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/vebon.komma.pro/wwwroot/js/kms/kms.js.map
{"version":3,"sources":["kms.confirm.js","main.js","kms.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AChHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACpJA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"kms.js","sourcesContent":["/**\n * Created by Jaap Faes on 09/03/15.\n */\n\n(function($){\n\n    $.confirm = function(params){\n\n        if($('#confirmOverlay').length){\n            // A confirmbox is already open\n            return false;\n        }\n\n        var buttonHtml = '';\n        $.each(params.buttons, function(name, obj){\n            // Generate the html for the buttons\n            buttonHtml += '<a href=\"#\" class=\"button '+ obj['class'] +'\">'+name+'<span></span></a>';\n            if(!obj.action){\n                obj.action = function(){};\n            }\n        });\n\n        var markup = [\n            '<div id=\"confirmOverlay\">',\n            '<div id=\"confirmBox\">',\n            '<h1>', params.title, '</h1>',\n            '<p>', params.message, '</p>',\n            '<div id=\"confirmButtons\">',\n            buttonHtml,\n            '</div></div></div>'\n        ].join('');\n\n        $(markup).hide().appendTo('body').fadeIn();\n\n        var buttons = $('#confirmBox .button');\n        var i = 0;\n\n        $.each(params.buttons, function(name, obj){\n            buttons.eq(i++).on('click', function(){\n                $.confirm.hide();\n                return obj.action();\n                //return false;\n            });\n        });\n    };\n\n    $.confirm.hide = function(){\n        $('#confirmOverlay').fadeOut(function(){\n            $(this).remove();\n        });\n    };\n\n    $('[kms-confirm]').click(function(e){\n        e.preventDefault();\n        var $this = $(this);\n        $.confirm({\n            'title': $this.attr('kms-confirm'),\n            'message': $this.attr('kms-confirm-message'),\n            'buttons': {\n                'Yes': {\n                    'class': 'btn btn-error-glow',\n                    'action': function(){\n                        $this.closest('form').submit();\n                    }\n                },\n                'No': {\n                    'class': 'btn btn-brand-glow',\n                    'action': function(){\n                        return false;\n                    }\n                }\n            }\n        });\n        return false;\n    });\n\n    var initExitWithoutSave = function(e) {\n        //e.preventDefault();\n        //alert('test');\n        $(\"#entities a, #sidebar a\").click(function (e) {\n            var $this = $(this);\n            if ($this.is('[href^=\"#\"]')) {\n                return;\n            }\n            // Beter checking is required, v2 in angular?\n            if ($('#entity .ng-dirty, #entity .error').length > 0) {\n                e.preventDefault();\n                $.confirm({\n                    'title': 'Not saved',\n                    'message': 'There are changes that has not been saved yet, are you sure you want to leave this page?',\n                    'buttons': {\n                        'Yes': {\n                            'class': 'btn btn-error-glow',\n                            'action': function () {\n                                window.location = $this.attr('href');\n                            }\n                        },\n                        'No': {\n                            'class': 'btn btn-brand-glow',\n                            'action': function () {\n                                return false;\n                            }\n                        }\n                    }\n                });\n            }\n        });\n    };\n\n    $(\"#entities .entities-list\").mousedown(initExitWithoutSave);\n    initExitWithoutSave();\n\n})(jQuery);","(function ($) {\n\n\n    // Save button\n    $('#save-button').click(function (e) {\n        $('#entity-form').find('input, textarea').attr('disabled', false);\n        $('#entity-form').submit();\n    });\n\n    // TinyMCE\n    tinymce.init({\n        selector: 'textarea.tiny-mce',\n        skin: 'kms',\n        menubar: false,\n        statusbar: false,\n        plugins: ['code', 'paste', 'link'],\n        toolbar: 'styleselect | bold italic underline | bullist numlist | link image | code',\n        height: '200',\n        paste_as_text: true,\n        style_formats: [{title: 'Titel', block: 'h2'}]\n    });\n\n    // Hierarchical list\n    $('.entities-list-item .dropdown-icon').click(function (e) {\n        e.preventDefault();\n        if ($(this).parent().parent().hasClass('open')) {\n            //$('.animate-to-triangle', this)[0].beginElement();\n            $(this).parent().parent().removeClass('open');\n        } else {\n            //$('.animate-to-minus', this)[0].beginElement();\n            $(this).parent().parent().addClass('open');\n        }\n    });\n\n    var toggled = true;\n\n    // Scroll to active item in list\n    $(window).load(function () {\n\n\n        if ($('#entity-form .lock').hasClass('open')) {\n            toggled = false;\n            $('#entity-form').find('input, textarea').attr('disabled', toggled);\n        }\n\n\n        var $container = $('#entities .entities-list');\n        var $activeListItem = $('.entities-list-item.active', $container).first();\n        if ($activeListItem.length == 0) return;\n        var top = $activeListItem.position().top;\n        $container.scrollTop(top);\n\n\n        $('.site-brand-name input').attr('placeholder', $('#global_name').val())\n\n    });\n\n    $('#global_name').change(function () {\n        $('.site-brand-name input').attr('placeholder', $(this).val())\n    });\n\n\n    //error accordian\n    $('.error-accordion .collapsible-ul').hide();\n    $('.error-accordion h3').click(function () {\n        $(this).parent().find('.collapsible-ul').toggle();\n    });\n\n    //$('.order-status.selectize').selectize();\n\n\n    // Product category selector\n\n    //$('#productCategorySelector').selectize();\n\n    //$('#selectYearAndMonthForm select').selectize();\n\n    $('#selectYearAndMonthForm select').change(function () {\n        var location = '/kms/orders/voltooid?month=' + $('#selectYearAndMonthForm select#orderMonthSelector').val() + '&year=' + $('#selectYearAndMonthForm select#orderYearSelector').val();\n        window.location = location;\n    })\n\n    $('#productCategorySelector').change(function () {\n        window.location = '/kms/products?category=' + encodeURIComponent(this.value);\n    });\n\n    // Flash messages\n    var hideFlashMessage = function () {\n        $('#flash-messages').fadeOut();\n    };\n    $('#flash-messages').click(function () {\n        hideFlashMessage();\n    });\n    setTimeout(function () {\n        hideFlashMessage();\n    }, 5000);\n\n\n    //var toggled = true;\n    $('#entity-form .lock').click(function () {\n        $(this).toggleClass('open')\n        toggled = !toggled;\n        $(this).parents('#entity-form').find('input, textarea').attr('disabled', toggled);\n\n    })\n\n\n\n    /* grab important elements */\n    var sortInput = jQuery('#sort_order');\n    var submit = jQuery('#autoSubmit');\n    var messageBox = jQuery('#message-box');\n    var list = jQuery('.fieldGroupItems');\n    /* create requesting function to avoid duplicate code */\n\n    /* worker function */\n    var fnSubmit = function(save) {\n        var sortOrder = [];\n        list.children('li').each(function(){\n            sortOrder.push(jQuery(this).data('id'));\n        });\n        sortInput.val(sortOrder.join(','));\n        console.log(sortInput.val());\n        if(save) {\n            request();\n        }\n    };\n    /* store values */\n    list.children('li').each(function() {\n        var li = jQuery(this);\n        li.data('id',li.attr('title')).attr('title','');\n    });\n    /* sortables */\n    list.sortable({\n        opacity: 0.7,\n        update: function() {\n\n        }\n    });\n    \n    /* ajax form submission */\n    jQuery('#dd-form').bind('submit',function(e) {\n        if(e) e.preventDefault();\n        fnSubmit(true);\n    });\n\n\n})(jQuery);\n","'use strict';\n\nvar attributes = {};\n\nvar app = angular.module('kms', [\n    'ui.bootstrap',\n    'ui.select',\n    'ui.date',\n    'ui.tree',\n    'ui.sortable',\n    'ngSanitize',\n    'ui.utils.masks'\n]);\n\n//Tabs\napp.run(function ($rootScope) {\n\n    var tabSlug = null;\n\n    var modelString;\n    var itemCounter;\n\n    var openTab = function (tabSlug) {\n\n        //Todo clean this mess\n        //Remove trailing / on the left hand side\n        tabSlug = tabSlug.replace(/^\\/(.*)/, '$1')\n\n        var originalTabSlug = tabSlug;\n\n        if (!tabSlug) return;\n\n        $('#tab-slug').val(tabSlug);\n\n        var tabSlugs = tabSlug.split('/');\n        if (tabSlugs.length > 1) {\n            var subTabSlug = tabSlugs.pop();\n            tabSlug = tabSlugs.join('/');\n        }\n\n        $('.tab-content').css('display', 'none');\n        $('.sub-tab-content').css('display', 'none');\n\n        $('.entity-tabs > .nav-tabs > li').removeClass('active');\n        $('.sub-tabs > .nav-tabs > li').removeClass('active');\n\n        $('#tab-content-' + tabSlug).css('display', 'block');\n        $('.entity-tabs > .nav-tabs > li a[href=\"#' + tabSlug + '\"]').parent().addClass('active');\n\n        if (subTabSlug) {\n            $('#tab-content-' + tabSlug + ' #sub-tab-content-' + subTabSlug).css('display', 'block');\n            $('#tab-content-' + tabSlug + ' .sub-tabs > .nav-tabs > li a[href=\"#' + originalTabSlug + '\"]').parent().addClass('active');\n        } else {\n            $('#tab-content-' + tabSlug + ' .sub-tab-content:first').css('display', 'block');\n            $('#tab-content-' + tabSlug + ' .sub-tabs > .nav-tabs > li:first').addClass('active');\n        }\n    };\n\n    $(window).on('hashchange load', function (event) {\n        tabSlug = window.location.hash.substring(1);\n        if (tabSlug) {\n            openTab(tabSlug);\n            return;\n        }\n        openTab($('#tab-slug').val());\n    });\n\n    $rootScope.$on('$locationChangeStart', function (event, next, current) {\n        var splited = next.split('#');\n        tabSlug = splited.length > 1 ? splited.pop().substring(1) : '';\n        if (tabSlug) {\n            openTab(tabSlug);\n            return;\n        }\n\n        openTab($('#tab-slug').val());\n    });\n\n\n});\n\napp.controller('KmsEntities', function ($scope, $element) {\n\n    $scope.entities = [];\n    $scope.paginatedEntities = [];\n\n    $scope.isSorting = false;\n\n    $scope.isSearching = function () {\n        return $scope.searchEntitiesText.text.length > 1;\n    };\n\n    $scope.currentPage = 1;\n    $scope.numPerPage = 5;\n    $scope.maxSize = 5;\n\n    var entityList = $('.entities-list-items .entities-list-item', $element);\n    for (var i = 0; i < entityList.length; i++) {\n        var dataElement = entityList[i];\n        var dataObject = {\n            thumbHtml: $('.entities-item-pre', dataElement).html(),\n            text: $('.entities-item-text', dataElement).html(),\n            status: $('.entities-item-status', dataElement).html(),\n            link: $('a', dataElement).first().attr('href'),\n            active: $(dataElement).hasClass('active')\n        };\n        $scope.entities.push(dataObject);\n    }\n\n    $scope.activateSorting = function () {\n        $scope.isSorting = true;\n    };\n\n    $scope.deactivateSorting = function () {\n        $scope.isSorting = false;\n    };\n\n    $scope.$watch(\"currentPage + numPerPage\", function () {\n        var begin = (($scope.currentPage - 1) * $scope.numPerPage)\n            , end = begin + $scope.numPerPage;\n\n        $scope.paginatedEntities = $scope.entities.slice(begin, end);\n    });\n\n});\n\napp.controller('SortableTree', function ($scope, $http, $attrs) {\n\n    $http.defaults.headers.post[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\n\n    $scope.data = [];\n\n    $scope.treeOptions = {\n        dropped: function (event) {\n            $http({\n                method: 'POST',\n                url: '/kms/api/' + $attrs.siteslug + '/' + $attrs.slug,\n                data: {\"tree\": angular.toJson($scope.data)}\n            }).then(function (response) {\n            });\n        }\n    };\n\n    $scope.openLink = function (id) {\n        window.location = $scope.url + '/' + id;\n    };\n\n    $scope.toggle = function (scope) {\n        scope.toggle();\n    };\n\n    var getRootNodesScope = function () {\n        return angular.element(document.getElementById('tree-root').scope());\n    };\n\n    $scope.collapseAll = function () {\n        var scope = getRootNodesScope();\n        scope.collapseAll();\n    };\n\n    $scope.expandAll = function () {\n        var scope = getRootNodesScope();\n        scope.expandAll();\n    };\n\n    $http.get('/kms/api/' + $attrs.siteslug + '/' + $attrs.slug)\n        .then(function (response) {\n            //console.log(angular.toJson(response.data));\n            $scope.data = response.data[0]['children'];\n        });\n});\n\napp.controller('KmsAttributes', function ($scope) {\n    $scope.attributes = attributes;\n\n    $scope.createModelString = function (modelKey, $itemKey) {\n\n\n        //Check if the modelKey is an array structure (field_name[x])\n        var match = modelKey.match(/(.*)\\[(.*)]/)\n\n        //There is no match, so a basic key\n        if (match == null) {\n            //SEt the modelKey as modelString\n            $scope.modelString = modelKey\n            //ItemKy is null\n            $scope.itemKey = null;\n            //return and exit\n            return $scope.modelString\n        }\n\n        //Set the match[2] as the itemKey\n        var itemCounter = match[2]\n\n        //If the itemKey is not undefined and itemkey is the string itemKey\n        if (typeof($itemKey) != \"undefined\" && match[2] == 'itemKey') {\n            //Set the $itemKey to the scope itemKey\n            itemCounter = $itemKey\n        }\n        //Glue the parts together\n        var modelString = match[1] + '_' + itemCounter\n\n        //Set to the global modelString\n        $scope.modelString = modelString;\n        $scope.itemCounter = itemCounter;\n\n        //Return the string\n        return modelString\n    }\n\n    /**\n     * Wrapper for Json.parse()\n     * So i can parse Json in blade\n     * @param value\n     */\n    $scope.parse = function (value) {\n\n        //If there is no value return;\n        if (!value) return;\n        //If it is already an object, return the value\n        if (typeof(value) == 'object') return value;\n\n        //Parse the string to a Json object\n        return JSON.parse(value);\n    }\n\n    $scope.convertToSlug = function (str) {\n        str = str.replace(/^\\s+|\\s+$/g, ''); // trim\n        str = str.toLowerCase();\n\n        // remove accents, swap ñ for n, etc\n        var from = \"ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;\";\n        var to = \"aaaaaeeeeeiiiiooooouuuunc------\";\n        for (var i = 0, l = from.length; i < l; i++) {\n            str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));\n        }\n\n        str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars\n            .replace(/\\s+/g, '-') // collapse whitespace and replace by -\n            .replace(/-+/g, '-'); // collapse dashes\n\n        return str;\n    }\n\n});\n\napp.controller('KmsAttributeTextFieldController', function ($scope, $element) {\n    $scope.attributes = attributes;\n});\n\napp.controller('KmsAttributePasswordController', function ($scope, $element) {\n    $scope.attributes = attributes;\n\n    //Set enabler true (show enable bottom)\n    $scope.enabler = true\n    //Change the password field to a hidden field\n    $('.passwordField', $element).attr('type', 'hidden')\n\n    //Method called when clikced on the enable button\n    $scope.enablePasswordField = function () {\n        //Change the type of the password field to password\n        $('.passwordField', $element).attr('type', 'password')\n        //Disable the enable buttom\n        $scope.enabler = false\n    }\n});\n\n\napp.controller('KmsAttributeDateController', function ($scope, $element) {\n    $scope.attributes = attributes;\n\n    $('input[ui-date]', $element).datepicker({\n        changeYear: true,\n        changeMonth: true,\n        firstDay: 1,\n        dateFormat: 'dd-mm-yy',\n    });\n\n});\n\napp.controller('KmsAttributeCurrencyFieldController', function ($scope, $element, $locale) {\n    $scope.attributes = attributes;\n\n\n    $scope.initCurrencyField = function (dec_value, currency) {\n\n        if (typeof(currency) !== 'undefined') {\n            //Set currencySymbol\n            $locale.NUMBER_FORMATS.CURRENCY_SYM = currency;\n        }\n\n        //Set the value an de dec_value\n        attributes[$scope.modelString] = {\"value\": dec_value / 100, \"dec_value\": dec_value}\n\n        $scope.$watch('attributes.' + $scope.modelString + '.value', function (newValue, oldValue) {\n            if (newValue === oldValue) return;\n\n            attributes[$scope.modelString].dec_value = newValue * 100\n\n        });\n    }\n\n\n});\n\napp.controller('KmsAttributePercentageFieldController', function ($scope, $element, $timeout) {\n    $scope.attributes = attributes;\n\n});\n\napp.controller('KmsAttributeTextFieldCurrencyController', function ($scope, $element, $timeout) {\n\n    $scope.attributes = attributes;\n    var id = $('input', $element).attr('id'); // get the id of the hidden field\n\n    var taxSelectFieldId = $('[data-kms-tax-field]', $element).attr('data-kms-tax-field');\n    var taxFieldId = id + '_tax';\n    var noTaxFieldId = id + '_no_tax';\n    var parseCurrencyStringToCents = function (currencyString) {\n\n        var val = currencyString.toString();\n        val = val.replace(/[.]/g, '');\n        val = val.replace(/[,]/g, '.');\n        val = val.replace(/[^0-9\\.]+/g, '');\n        val = val * 100;\n        return val;\n    };\n\n    var addTax = function (value) {\n        if (attributes[taxSelectFieldId].selected) {\n            var factor = 1 + (attributes[taxSelectFieldId].selected.fullValue.rate / 100);\n            return value * factor;\n        }\n    };\n    var subtractTax = function (value) {\n        if (attributes[taxSelectFieldId].selected) {\n            var factor = 1 + (attributes[taxSelectFieldId].selected.fullValue.rate / 100);\n            return value / factor;\n        }\n    };\n    $scope.$watch('attributes.' + taxFieldId, function (newValue, oldValue) {\n        if (newValue !== oldValue) {\n            $scope.attributes[id] = parseCurrencyStringToCents(newValue);\n        }\n    });\n\n    $scope.$watch('attributes.' + noTaxFieldId, function (newValue, oldValue) {\n        if (newValue !== oldValue) {\n            $scope.attributes[id] = Math.round(addTax(parseCurrencyStringToCents(newValue)));\n        }\n    });\n\n    var watcherMain = function (newValue, oldVal) {\n        if ($.isNumeric($scope.attributes[id])) {\n            var $taxField = $('#' + taxFieldId);\n            var $noTaxField = $('#' + noTaxFieldId);\n            if (!$taxField.is(':focus')) {\n                $taxField.val($scope.attributes[id] / 100)\n            }\n            if (!$noTaxField.is(':focus')) {\n                $noTaxField.val(Math.round(subtractTax($scope.attributes[id])) / 100)\n            }\n        }\n    };\n\n    // Clear fields on blur if no value\n    $('#' + taxFieldId + ', #' + noTaxFieldId).blur(function (e) {\n        if ($scope.attributes[id] == 0) {\n            $('#' + taxFieldId + ', #' + noTaxFieldId).val(0);\n        }\n    });\n\n    $scope.$watch('attributes.' + id, watcherMain);\n    $scope.$watch('attributes.' + taxSelectFieldId + '.selected', watcherMain);\n    $scope.attributes[id] = $('input', $element).attr('value'); // get the value of the hidden field\n    $timeout(watcherMain, 500);\n});\n\napp.controller('KmsAttributeSelectController', function ($scope, $element) {\n\n    $scope.attributes = attributes;\n    $scope.selectData = [];\n\n\n    /**\n     * Initialize the choices for ui-select\n     *\n     * @param choices | string\n     * @returns {*}\n     */\n    $scope.initChoices = function (choices) {\n        //If there are no choices;\n        if (!choices) return;\n\n        //If it is not already an object, make one from json\n        if (typeof(choices) != 'object') choices = JSON.parse(choices)\n\n        //Set the choices to the selectData\n        $scope.selectData = choices\n        return choices\n    };\n\n});\n\napp.controller('KmsAttributeMultiSelectController', function ($scope, $element) {\n\n    $scope.attributes = attributes;\n    $scope.selectData = [];\n\n    /**\n     * Initialize the choices for ui-select\n     *\n     * @param choices | string\n     * @returns {*}\n     */\n    $scope.initChoices = function (choices) {\n        //If there are no choices;\n        if (!choices) return;\n\n        //If it is not already an object, make one from json\n        if (typeof(choices) != 'object') choices = JSON.parse(choices)\n\n        //Set the choices to the selectData\n        $scope.selectData = choices\n        return choices\n    };\n\n    $scope.setValue = function (values) {\n\n        if (!values) return;\n        // compare \"values\" array and \"$scope.selectData\" array\n        var result = [];\n        for (var i = 0; i < $scope.selectData.length; i++) {\n            var valueInElement = false;\n            for (var j = 0; j < values.length; j++) {\n                if ($scope.selectData[i].value == values[j]) {\n                    valueInElement = true;\n                    break;\n                }\n            }\n            if (valueInElement) result.push($scope.selectData[i]);\n        }\n\n        // $scope.attributes[id] = angular.toJson(values);\n        // $scope.attributes[id + '_select'] = result;\n        return result;\n    };\n\n\n});\n\napp.controller('KmsAttributeSlugController', function ($scope, $element) {\n    $scope.attributes = attributes\n\n    //Get the slugField key\n    var slugField = $('[data-kms-slug-field]', $element).attr('data-kms-slug-field');\n    //Change [[itemCounter]] with the $scope.itemCounter (fieldGroup)\n    slugField = slugField.replace('[[itemCounter]]', $scope.itemCounter)\n\n    //Watch the slugField\n    $scope.$watch('attributes.' + slugField, function (newValue, oldValue) {\n        //When nothing changes, do nothing\n        if (newValue === oldValue) return;\n        //Set the string converted to Slug to the field\n        attributes[$scope.modelString] = $scope.convertToSlug(attributes[slugField]);\n    });\n\n});\n\n\napp.controller('KmsAttributeFieldGroupController', function ($scope, $element) {\n    $scope.number = 0;\n    $scope.itemKey = 1;\n    $scope.maxFieldGroups = null;\n\n    $scope.getNumber = function () {\n        return new Array($scope.number);\n    }\n\n    $scope.addRow = function () {\n\n        if ($scope.itemKey >= $scope.maxFieldGroups) return\n        //Add one to the itemKey\n        $scope.itemKey++;\n        //Addd one to the numbers\n        $scope.number++;\n\n    }\n    /**\n     * Initialize the given values\n     * @param itemKey | Amount (-1) of  items fieldGroups\n     * @param maxFieldGroups | max fieldgroups\n     */\n    $scope.init = function (itemKey, maxFieldGroups) {\n\n        //Items in the fieldGroup\n        $scope.itemKey = itemKey\n        //Max items in fieldGroup\n        $scope.maxFieldGroups = maxFieldGroups\n        //If it is a new, add a row\n        if (itemKey == 0) $scope.addRow();\n    }\n});\n\napp.controller('KmsAttributeRouteController', function ($scope, $element) {\n\n    $scope.attributes = attributes;\n\n    var id = $('input', $element).attr('id');\n    attributes[id] = $('input', $element).attr('value');\n\n    //Get the name of the slugField\n    var slugField = $('[data-kms-slug-field]', $element).attr('data-kms-slug-field');\n    //Change [[itemCounter]] with the $scope.itemCounter (fieldGroup)\n    slugField = slugField.replace('[[itemCounter]]', $scope.itemCounter)\n    //Get the name of the parentField\n    var parentField = $('[data-kms-parent-field]', $element).attr('data-kms-parent-field');\n\n    //Set the languageId\n    var languageId = $('[data-kms-language-id]', $element).attr('data-kms-language-id');\n    //Set the structure\n    var structure = $('[data-kms-structure]', $element).attr('data-kms-structure');\n\n\n    /**\n     * This function generates the correct Route\n     * when a watched field is changed\n     *\n     * @param newValue\n     * @param oldValue\n     */\n    var parseStructure = function (newValue, oldValue) {\n        //If the value is the same, stop and return\n        if (newValue === oldValue) return;\n\n        //Create an empty parentSlug string\n        var parentSlug = '';\n        //Check if the parentField exist in then attributes\n        if (attributes[parentField]) {\n            //Check if the parentField has an selected.routes object\n            if (!attributes[parentField].selected.routes) {\n                //If not trow an error\n                console.error('Routes are not set in the ' + parentField + 'field')\n            }\n            //Set the routes for the current language to parentSlug\n            parentSlug = attributes[parentField].selected.routes[languageId];\n        }\n\n        //Create newRoute\n        var newRoute = '';\n\n        //Replace {{parentSlugs}} with the parentSlug\n        newRoute = structure.replace('{{parentSlugs}}', parentSlug);\n        //Replace {{slug}} with the Slug\n        newRoute = newRoute.replace('{{slug}}', $scope.convertToSlug(newValue));\n\n        //Set the new route to the attribute of the current $scope.modelString\n        attributes[$scope.modelString] = newRoute\n\n    };\n\n    //Set a watch on the slugField, and execute the parseStructure method on a change\n    $scope.$watch('attributes.' + slugField, parseStructure);\n    //If there is an parentField\n    if (attributes[parentField]) {\n        //Set a watch on the parentField, and execute the parseStructure method on a change\n        $scope.$watch('attributes.' + parentField + '.selected', parseStructure);\n\n    }\n\n\n});\n\n\napp.controller('KmsAttributeSorterController', function ($scope, $element) {\n    $scope.attributes = attributes;\n\n});\n\napp.filter(\"multiWordFilter\", function ($filter) {\n    return function (inputArray, searchText) {\n        var wordArray = searchText ? searchText.toLowerCase().split(/\\s+/) : [];\n        var wordCount = wordArray.length;\n        for (var i = 0; i < wordCount; i++) {\n            // Hack for filtering on text parameter: {text:wordArray[i]}\n            inputArray = $filter('filter')(inputArray, {text: wordArray[i]});\n        }\n        return inputArray;\n    }\n});\n\napp.filter('valuesToArrayFilter', function () {\n    return function (input) {\n\n        if (!input) return;\n\n        var output = input.map(function (a) {\n            return a.value;\n        });\n\n        return output\n\n\n    }\n});\n\n\n/**\n * AngularJS default filter with the following expression:\n * \"person in people | filter: {name: $select.search, age: $select.search}\"\n * performs a AND between 'name: $select.search' and 'age: $select.search'.\n * We want to perform a OR.\n */\napp.filter('propsFilter', function () {\n    return function (items, props) {\n        var out = [];\n\n        if (angular.isArray(items)) {\n            items.forEach(function (item) {\n                var itemMatches = false;\n\n                var keys = Object.keys(props);\n                for (var i = 0; i < keys.length; i++) {\n                    var prop = keys[i];\n                    var text = props[prop].toLowerCase();\n                    if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {\n                        itemMatches = true;\n                        break;\n                    }\n                }\n\n                if (itemMatches) {\n                    out.push(item);\n                }\n            });\n        } else {\n            // Let the output be the input untouched\n            out = items;\n        }\n        return out;\n    };\n});\n\n\nvar IsJsonString = function (str) {\n    try {\n        JSON.parse(str);\n    } catch (e) {\n        return false;\n    }\n    return true;\n}\n"]}