")
}])
.run(["$templateCache", function ($templateCache) {
$templateCache.put("template/dialog/message.html", '
{{ title }}
{{ message }}
')
}])
.run(['$templateCache', function ($templateCache) {
$templateCache.put('/templates/keyvalue.html',
"
" +
"
" +
"" +
"" +
"
" +
"
" +
"" +
"
" +
"
Name
" +
"
Content
" +
"
" +
"
" +
"" +
"" +
"
" +
"
" +
"
" +
"
" +
"
" +
"" +
"" +
"
" +
"
" +
"
" +
"" +
"
" +
"
"
)
}])
.run(['$templateCache', function ($templateCache) {
$templateCache.put('/templates/cbtree.html',
"
" +
"" +
"
" +
"
" +
"
" +
"
"+
"
" +
"" +
"
" +
"
{{opt.name}}
" +
"" +
"
" +
"
" +
"
" +
"
" +
"
{{subopt.name}}
" +
"" +
"
" +
"
"+
"
"+
"
" +
"
" +
"
" +
"
"
)
}]);
})(angular);
/**
* Gestisce il load delle immagini con un'animazione in caso di src funzionante.
* In caso di errori mostra immagine 1x1 transparente.
*/
;(function(ng, ngmodule) {
ngmodule.directive('lpBgimage', ['$log',function($log){
var transparentPixel = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D";
return {
restrict: 'A',
scope: {
lpBgimage: '@',
delay: '='
},
link: function (scope, element, attrs) {
element.addClass('lp-bgimage');
scope.$watch('lpBgimage', function (newValue) {
var src = newValue;
try {
if (ng.isDefined(src)) {
element.addClass('loading');
var image = new Image();
ng.element(image).on('load error', function(e){
element.removeClass('loading');
if (e.type=='error') {
$log.error("Image loading error:\nUrl: {0}\nMessage: {1}", [src, e.message]);
if (emptyImage != null)
ng.element(element).css({
'background-image': emptyImage
});
} else {
ng.element(element).animate({
opacity: 0
}, scope.delay, function () {
ng.element(element)
.css({
'background-image': 'url('+src+')'
})
.animate({
opacity: 1
}, scope.delay);
});
}
});
image.src = src;
} else {
if (emptyImage != null)
ng.element(element).css({
'background-image': emptyImage
});
}
} catch (e) {
$log.error(e.message);
}
});
}
}
}]);
})(angular, angular.module('liquidpixels.directive'));
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpCbtree', ['$timeout', function ($timeout) {
return {
require: '^ngModel',
restrict: 'E',
replace: 'true',
transclude: 'false',
templateUrl: '/templates/cbtree.html',
scope: {
ngModel: '=', // [{name:'',id:'',parent_id:''}]
choices: '=' // [{name:'',id:'',parent_id:''}]
},
link: function (scope, element, attrs) {
scope.options = [];
var selfChanged = false; // usato per non fare init se la modifica di ngModel è fatta dalla direttiva
var init = function () {
var options = [];
scope.ngModel = scope.ngModel || [];
// preparing data
_.each(scope.choices, function (item) {
// determino lo stato checked
var checked = _.find(scope.ngModel, function (opt) {
return _.isEqual(item.id, opt.id);
});
ng.extend(item, { checked: !_.isUndefined(checked) });
// determino il padre
var parent = _.find(options, function (m) {
return _.isEqual(m.id, item.parent_id);
});
if (_.isUndefined(parent)) {
parent = _.extend({ items: [] }, item);
} else {
parent.items.push(ng.extend(item));
options = _.reject(options, function (m) {
return _.isEqual(m.id, parent.id);
});
}
options.push(parent);
});
scope.options = options;
}
var updateModel = function () {
var preparedOptions = [];
ng.forEach(scope.options, function (option) {
if (option.checked) preparedOptions.push(_.pick(option, 'id', 'name', 'parent_id'));
ng.forEach(option.items, function (suboption) {
if (suboption.checked) preparedOptions.push(_.pick(suboption, 'id', 'name', 'parent_id'));
});
});
scope.ngModel = preparedOptions;
}
scope.$watch('ngModel', function (newVal, oldVal) {
if (ng.isDefined(newVal) && !ng.equals(newVal, oldVal) && !selfChanged) {
init();
}
});
scope.$watch('choices', function (newVal, oldVal) {
if (ng.isDefined(newVal) && !ng.equals(newVal, oldVal)) {
init();
}
});
scope.toggleCheck = function (option) {
selfChanged = true;
option.checked = !option.checked;
// se è ceccata ed è figlia allora cecco il padre
if (option.checked && !_.isUndefined(option.parent_id) && !_.isNull(option.parent_id)) {
var index = -1;
for (var i = 0; i < scope.options.length; i++) {
if (scope.options[i].id == option.parent_id) {
index = i;
break;
}
}
if (index >= 0) scope.options[index].checked = true;
} else if (!option.checked) { // se non è ceccata ed è padre de-cecco eventuali figli
var childsIndex = [];
for (var i = 0; i < scope.choices.length; i++) {
if (scope.choices[i].parent_id == option.id) {
childsIndex.push(i);
}
}
ng.forEach(childsIndex, function (index) {
scope.choices[index].checked = false;
});
}
updateModel();
$timeout(function () {
selfChanged = false;
}, 1);
}
init();
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
/**
* Enhanced Date picker with range
*
* @author : Alessio Grumiro
* @date : 02 Apr 2014
*/
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpDaterangepicker', ['$timeout', function ($timeout) {
return {
restrict: 'A',
scope: {
lpDaterangepicker: '=',
uiStartdate: '=',
uiEnddate: '='
},
link: function (scope, element, attrs) {
var defaults = {
format: 'DD/MM/YYYY',
opens: 'left',
minDate: '01/01/2000',
startDate: moment(),
endDate: moment(),
separator: '-',
singleDatePicker: false,
labelTemplate: '{startDate} - {endDate}',
blockKb: false
}
// determino la posizione di apertura in base al centro schermo della select
var middleScreen = $(document).width() / 2;
if (element.offset().left < middleScreen) defaults.opens = 'right';
var config = ng.extend(defaults, scope.lpDaterangepicker);
if (config.singleDatePicker) {
config.labelTemplate = '{startDate}';
}
$(element).daterangepicker(config);
scope.$watch('uiStartdate', function () {
updateLabel();
});
scope.$watch('uiEnddate', function () {
updateLabel();
});
var updateLabel = function () {
var startDate = null;
var endDate = null;
if (!_.isUndefined(scope.uiStartdate)
&& !_.isNull(scope.uiStartdate)
&& (scope.uiStartdate != '')) {
startDate = scope.uiStartdate;
$(element).data('daterangepicker').setStartDate(startDate);
}
if (!config.singleDatePicker
&& !_.isUndefined(scope.uiEnddate)
&& !_.isNull(scope.uiEnddate)
&& (scope.uiEnddate != '')) {
endDate = scope.uiEnddate;
$(element).data('daterangepicker').setEndDate(endDate);
}
var label = null;
if (endDate != null) {
label = config.labelTemplate.replace('{startDate}', startDate).replace('{endDate}', endDate);
} else {
label = config.labelTemplate.replace('{startDate}', startDate);
}
$(element).val(label);
}
$(element).on('apply.daterangepicker', function (e, picker) {
scope.uiStartdate = picker.startDate.format(config.format);
if (!config.singleDatePicker) scope.uiEnddate = picker.endDate.format(config.format);
if (!scope.$$phase) scope.$apply();
});
$(element).on('cancel.daterangepicker', function (e, picker) {
scope.uiStartdate = null;
if (!config.singleDatePicker)
scope.uiEnddate = null;
if (!scope.$$phase) scope.$apply();
});
$(element[0]).on('change', function (e, picker) {
if ($(element[0]).val() == "") {
scope.uiStartdate = null;
if (!config.singleDatePicker)
scope.uiEnddate = null;
if (!scope.$$phase) scope.$apply();
}
});
if (config.blockKb) {
$(element)
.off('keydown')
.on('keydown', function (e) {
e.preventDefault();
e.stopPropagation();
return false;
});
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
;(function ($, ngmodule) {
'use strict';
ngmodule.directive('lpEcommerce', function ($parse) {
return {
restrict: 'A',
link: function ($scope, element, attrs) {
$(element).data('ecommerce', attrs.lpEcommerce);
// $(element).ecommerce();
}
}
}
);
})(jQuery, angular.module('liquidpixels.directive'));
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpGooglechart', [function () {
var defaults = {
title: '',
width: '',
height: '',
is3D: false,
legend: 'left'
}
return {
require: '^ngModel',
restrict: 'A',
scope: {
lpGooglechart: '=',
ngModel: '=',
columns: '='
},
link: function (scope, element, attrs) {
var init = function () {
var config = defaults;
if (!_.isUndefined(scope.lpGooglechart)
&& !_.isNull(scope.lpGooglechart))
config = ng.extend(config, scope.lpGooglechart);
var data = google.visualization.arrayToDataTable(scope.ngModel);
var chart;
switch (config.$type) {
case 'bar':
chart = new google.visualization.BarChart(element[0]);
break;
case 'column':
chart = new google.visualization.ColumnChart(element[0]);
break;
default:
chart = new google.visualization.PieChart(element[0]);
}
chart.draw(data, config);
}
scope.$watch('ngModel', function (newVal) {
if (ng.isDefined(newVal) && !_.isEmpty(newVal)) startChecker();
});
var startChecker = function () {
var checker = setInterval(function () {
if (window.GOOGLECHARTS_READY) {
clearInterval(checker);
init();
}
}, 1000);
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function ($, ngmodule) {
'use strict';
ngmodule.directive('lpupload', function ($parse) {
return {
scope: {
"url": '=ngUrl',
"name": '=ngName',
"fileSelected": '=ngFileSelected',
"uploaded": '=ngUploaded',
"isLoading": '=ngIsLoading',
"control": "=",
"finish": "&ngFinish",
"fileName": "=ngFileName"
},
// required to make it work as an element
restrict: 'E',
template: '
',
replace: true,
// observe and manipulate the DOM
link: function ($scope, element, attrs) {
//disabled="disabled"
var iframe = $("iframe", element)[0];
$scope.isUploaded = false;
var formContainer = $(".form_container", element);
var form = $("form", formContainer)[0];
form.action = $scope.url;
form.method = "POST";
$(".btnSelect", element).on("click", function (evt) {
$("input", formContainer).click();
});
$("input", formContainer).on("change", function () {
var has_selected_file = $(this).filter(function () {
return $.trim(this.value) != ''
}).length > 0;
var name = this.value;
$scope.$apply(function (ev) {
$scope.fileName = name;
});
if (has_selected_file) {
$scope.$apply(function (ev) {
$scope.fileSelected = true;
});
$(".btnCancel", element).removeAttr("disabled");
}
});
$(".btnCancel", element).on("click", function (evt) {
$("input", formContainer).val('');
$(".btnCancel", element).attr("disabled", "disabled");
$scope.$apply(function (ev) {
$scope.fileSelected = false;
$scope.fileName = "";
});
});
$(".btnCancel", element).attr("disabled", "disabled");
$scope.internalControl = $scope.control || {};
$scope.internalControl.upload = function () {
$scope.isLoading = true;
form.submit();
}
}
}
}
);
})(jQuery, angular.module('liquidpixels.directive'));
(function (ng, ngmodule, _) {
ngmodule.directive('inject', [function () {
return {
link: function ($scope, $element, $attrs, controller, $transclude) {
if (!$transclude) {
throw minErr('ngTransclude')('orphan',
'Illegal use of ngTransclude directive in the template! ' +
'No parent directive that requires a transclusion found. ' +
'Element: {0}',
startingTag($element));
}
var innerScope = $scope.$new();
$transclude(innerScope, function (clone) {
$element.empty();
$element.append(clone);
$element.on('$destroy', function () {
innerScope.$destroy();
});
});
}
};
}]);
})(angular, angular.module('liquidpixels.directive'), _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpKeyvalue', ['$log', '$timeout', function ($log, $timeout) {
return {
require: '^ngModel',
restrict: 'EA',
replace: true,
transclude: false,
templateUrl: '/templates/keyvalue.html',
scope: {
ngModel: '=',
onAdd: '&add',
onRemove: '&remove'
},
link: function (scope, element, attrs) {
var selfChanged = false; // usato per non fare init se la modifica di ngModel è fatta dalla direttiva
var init = function () {
scope.metas = [];
if (ng.isDefined(scope.ngModel)) {
try {
var metas = JSON.parse(scope.ngModel) || [];
ng.forEach(metas, function (value) {
scope.metas.push(ng.extend(value, {
cssClass: ''
}));
});
} catch (e) {
$log.error("Errore mentre cercavo di parsare i metatags: " + e);
}
}
}
scope.addMeta = function () {
scope.metas.push({ key: '', value: '', cssClass: 'new' });
(scope.onAdd||ng.noop)();
}
scope.removeMeta = function (meta) {
var index = _.keys(scope.metas).indexOf(meta.key);
(scope.onRemove || ng.noop)(scope.metas[index]);
scope.metas.splice(index, 1);
}
scope.saveMeta = function (meta) {
selfChanged = true;
meta.cssClass = 'saved';
if (_.isEmpty(scope.metas)) {
scope.ngModel = null;
} else {
var newModel = [];
ng.forEach(scope.metas, function(meta){
newModel.push(_.pick(meta, 'key', 'value'));
});
scope.ngModel = JSON.stringify(newModel);
}
$timeout(function () {
selfChanged = false;
meta.cssClass = '';
}, 1000);
}
scope.$watch('ngModel', function (newVal, oldVal) {
if (ng.isDefined(newVal) && !ng.equals(newVal, oldVal) && !selfChanged) {
init();
}
});
init();
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule) {
ngmodule.directive('lpLookupField', ["$rootScope", "$q", "$http", "apiUrl", function ($rootScope, $q, $http, apiUrl) {
return {
restrict: 'AE',
replace: true,
template: '',
scope: {
field_url: '=fieldUrl',
parent_data:'=parentData'
},
link: function (scope, element, attrs) {
var values = [];
var lastQuery = null;
var cancelToken = null;
var noSort = (_.isUndefined(attrs.noSort)) ? false : true;
var params = {};
scope.search = function (val) {
if (cancelToken != null) {
cancelToken.resolve();
}
if ((lastQuery != null) && (lastQuery.indexOf(val) >= 0)) {
lastQuery = val;
return values;
}
cancelToken = $q.defer();
lastQuery = val;
params['q'] = val;
if (!_.isUndefined(attrs.parentData) && window[scope.parent_data]) {
params[scope.parent_data] = window[scope.parent_data];
}
return $http.get(apiUrl + scope.field_url, {
timeout: cancelToken.promise,
params: params
}).then(function (response) {
cancelToken = null;
values = [];
if (ng.isDefined(response)) {
if (noSort)
values = response.data;
else
values = _.sortBy(response.data, function (o) { return o.type; });
values = _.groupBy(values, 'type');
values = _.map(values, function (g) { g[0].firstInGroup = true; return g; });
values = _.flatten(values);
}
return values;
});
};
if (attrs.value) {
scope.selected = attrs.value
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'));
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpCardnumber', [function () {
return {
require: '^ngModel',
restrict: 'A',
scope: {
config: '=lpCardnumber'
},
link: function (scope, element, attrs) {
//$(element).inputmask("9999-9999-9999-9999", {
// oncomplete: function () {
// if (/^\d+$/.test($(this).val()))
// scope.ngModel = $(this).val();
// else
// showTooltip("Il numero inserito non e' valido");
// }
//});
var GetCardType=function(number) {
// visa
var re = new RegExp("^4");
if (number.match(re) != null)
return "Visa";
// Mastercard
// Updated for Mastercard 2017 BINs expansion
if (/^(5[1-5][0-9]{14}|2(22[1-9][0-9]{12}|2[3-9][0-9]{13}|[3-6][0-9]{14}|7[0-1][0-9]{13}|720[0-9]{12}))$/.test(number))
return "Mastercard";
// AMEX
re = new RegExp("^3[47]");
if (number.match(re) != null)
return "AMEX";
// Discover
re = new RegExp("^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)");
if (number.match(re) != null)
return "Discover";
// Diners
re = new RegExp("^36");
if (number.match(re) != null)
return "Diners";
// Diners - Carte Blanche
re = new RegExp("^30[0-5]");
if (number.match(re) != null)
return "Diners - Carte Blanche";
// JCB
re = new RegExp("^35(2[89]|[3-8][0-9])");
if (number.match(re) != null)
return "JCB";
// Visa Electron
re = new RegExp("^(4026|417500|4508|4844|491(3|7))");
if (number.match(re) != null)
return "Visa Electron";
return "";
}
$(element).on("keyup", function (event) {
var number = $(element).val();
$(element).removeClass("visa");
$(element).removeClass("maestro");
$(element).removeClass("mastercard");
// visa
var re = new RegExp("^4");
if (number.match(re) != null)
$(element).addClass("visa");
// mastercard
var re = new RegExp("^5[1-5]");
if (number.match(re) != null)
$(element).addClass("mastercard");
// maestro
var re = new RegExp("^5018|^5020|^5038|^5893|^6304|^6759|^6761|^6762|^6763");
if (number.match(re) != null)
$(element).addClass("maestro");
$(element).val(number.replace(/\ /g,""));
});
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpDatepicker', ['$timeout', function ($timeout) {
return {
require: '^ngModel',
restrict: 'A',
scope: {
config: '=lpDatepicker'
},
link: function (scope, element, attrs) {
$(element).inputmask("99/99/9999", {
placeholder:"gg/mm/aaaa",
oncomplete: function () {
var date = moment($(this).val(), "DD/MM/YYYY");
if (!date.isValid() || (date.year() < 1900) || (date.year() > moment().year())) {
//showTooltip("La data inserita non e' valida");
} else scope.ngModel = $(this).val();
}
});
var showTooltip = function (msg) {
var top = $(element).offset().top;
var left = $(element).offset().left;
var containerEl = $('', {
"class": "x-tooltip-container hidden-xs",
css: {
'margin-top':$(element).outerHeight(true),
'display':'none',
'left': left + 'px',
'top': top + 'px'
}
})
$('', {
"class":"arrow-top"
}).appendTo(containerEl);
$('', {
html: msg
}).appendTo(containerEl);
containerEl.appendTo($('body')).fadeIn('fast');
setTimeout(function () {
containerEl.fadeOut('slow', function () { $(this).remove(); });
}, 5000);
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpEmail', [function () {
return {
require: '^ngModel',
restrict: 'A',
scope: {
config: '=lpEmail'
},
link: function (scope, element, attrs) {
var regex = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm;
/*
$(element).inputmask({
mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
greedy: false,
onBeforePaste: function (pastedValue, opts) {
pastedValue = pastedValue.toLowerCase();
return pastedValue.replace("mailto:", "");
},
definitions: {
'*': {
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
cardinality: 1,
casing: "lower"
}
},
onincomplete: function () {
showTooltip("L'indirizzo email inserito non e' valido");
},
oncomplete: function () {
scope.ngModel = $(this).val();
}
});
*/
//$(element).blur(function () {
// if ($(this).val() == '' || !regex.test($(this).val()))
// showtooltip("l'indirizzo email inserito non e' valido");
//});
var showtooltip = function (msg) {
var top = $(element).offset().top;
var left = $(element).offset().left;
var containerel = $('', {
"class": "x-tooltip-container hidden-xs",
css: {
'margin-top': $(element).outerheight(true),
'display': 'none',
'left': left + 'px',
'top': top + 'px'
}
})
$('', {
"class": "arrow-top"
}).appendto(containerel);
$('', {
html: msg
}).appendto(containerel);
containerel.appendto($('body')).fadein('fast');
settimeout(function () {
containerel.fadeout('slow', function () { $(this).remove(); });
}, 5000);
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpPhone', ['Utils', '$timeout', function (Utils, $timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
var timeoutPromise = null;
$(element).inputmask({
mask: "9{0,10}",
greedy: false,
oncomplete: function () {
var value = $(this).val();
hideTooltip();
if (timeoutPromise != null) $timeout.cancel(timeoutPromise);
if (/^\d+$/.test(value)) {
timeoutPromise = $timeout(function () {
Utils.isValidPhone(value).then(function (r) {
ngModel.$setValidity(attrs.ngModel, r);
if (!r) {
// showTooltip("Il numero di telefono inserito non e' valido");
}
});
}, 2000);
} else {
// showTooltip("Il numero di telefono inserito non e' valido");
}
}
});
var hideTooltip = function () {
// $("#tt_phone.x-tooltip-container").fadeOut('fast', function () { $(this).remove(); });
}
var showTooltip = function (msg) {
var top = $(element).offset().top;
var left = $(element).offset().left;
var containerEl = $('', {
"id": "tt_phone",
"class": "x-tooltip-container hidden-xs",
css: {
'margin-top':$(element).outerHeight(true),
'display':'none',
'left': left + 'px',
'top': top + 'px'
}
})
$('', {
"class":"arrow-top"
}).appendTo(containerEl);
$('', {
html: msg
}).appendTo(containerEl);
containerEl.appendTo($('body')).fadeIn('fast');
setTimeout(function () {
containerEl.fadeOut('slow', function () { $(this).remove(); });
}, 5000);
}
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpSelect2', [function () {
var defaults = {}
return {
restrict: 'A',
scope: {
},
link: function (scope, element, attrs) {
var config = defaults;
if (!_.isUndefined(attrs.lpSelect2)
&& !_.isEmpty(attrs.lpSelect2)
&& !_.isNull(attrs.lpSelect2)
&& _.isString(attrs.lpSelect2)) {
config = ng.extend(config, JSON.parse(attrs.lpSelect2.replace(/'/g, '"')));
}
$(element).select2(config);
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
;(function(ng, ngmodule, _) {
ngmodule.directive('lpSly', ['$timeout', function ($timeout) {
return {
scope: {
items: '=',
containerClass: '@',
options: '@',
itemClick: '&',
slidePage: '@',
currentId: '@',
canInit: '=',
moveFn: '&'
},
restrict: 'EA',
replace: true,
transclude: true,
template: '
' +
'' +
''+
'
'+
'
'+
'
' +
''+
'
'+
'
'+
'
'+
'
',
link: function (scope, element, attrs) {
var htmlReady = false;
var defaults,
frameEl,
nextBtn,
prevBtn,
nextPageBtn,
prevPageBtn;
var initSly = function () {
if (htmlReady) {
$timeout(function () {
var args = ng.extend({}, defaults, JSON.parse(scope.options || "{}"));
$(frameEl).sly(args);
if (ng.isDefined(scope.moveFn)) {
$(frameEl).sly('on', 'change', function () {
scope.moveFn({ item: scope.items[this.rel.activeItem] });
});
}
if (ng.isDefined(scope.currentId) && scope.currentId != '')
setCurrentItemStyle(scope.currentId);
}, 500);
}
}
var setCurrentItemStyle = function (id) {
if (htmlReady) {
$('li', frameEl).removeClass('current');
var currentIndex = -1;
ng.forEach(scope.items, function (item, index) {
if (item.id == id) currentIndex = index;
});
if (currentIndex >= 0) {
$($('li', frameEl)[currentIndex]).addClass('current');
}
}
}
var init = function () {
$(element).removeData('container-class');
frameEl = $('.frame', element);
if (scope.itemClick != null) {
$(frameEl).on('click', 'li', function () {
$('li', frameEl).removeClass('selected');
$(this).addClass('selected');
scope.itemClick({ item: scope.items[$(this).data('index')] });
});
}
if (scope.slidePage) {
nextPageBtn = $('button.forward', element);
prevPageBtn = $('button.backward', element);
} else {
nextBtn = $('button.forward', element);
prevBtn = $('button.backward', element);
}
defaults = {
horizontal: 1,
itemNav: 'forceCentered',
smart: 1,
activateOn: 'click',
mouseDragging: 1,
touchDragging: 1,
releaseSwing: 1,
startAt: 0,
speed: 300,
elasticBounds: 1,
easing: 'easeOutExpo',
dragHandle: 1,
dynamicHandle: 1,
clickBar: 1,
prev: prevBtn,
next: nextBtn,
prevPage: prevPageBtn,
nextPage: nextPageBtn,
activateMiddle: true
}
htmlReady = true;
if (ng.isDefined(scope.items) && scope.items.length > 0)
initSly();
}
scope.$watch('items', function (newVal, oldVal) {
if (ng.isDefined(newVal) && newVal != oldVal &&htmlReady) {
$(frameEl).sly(false);
initSly();
}
});
scope.$watch('canInit', function (newVal, oldVal) {
if (newVal != oldVal && scope.canInit && !htmlReady) {
init();
}
});
scope.$on('lpsly-updatecurrent-id', function (evt, args) {
setCurrentItemStyle(args.currentId);
});
if (scope.canInit) init();
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpVatcode', ['Utils', '$timeout', function (Utils, $timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function (scope, element, attrs, ngModel) {
ngModel.$validators.lpVatcode = function (modelValue, viewValue) {
Utils.isValidVATCode(viewValue).then(function (r) {
ngModel.$setValidity(attrs.ngModel, r);
});
};
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function (ng, ngmodule) {
'use strict';
ngmodule.directive('numeric', function ($parse) {
return {
scope: {
"number": '=ngModel',
'prefix': '@'
},
// required to make it work as an element
restrict: 'E',
template:
'
'
+ '{{prefix}}'
+ ''
+''
+''
+''
+ ''
+'
',
replace: true,
// observe and manipulate the DOM
link: function ($scope, element, attrs) {
//attrs.$observe('caption', function(value) {
// element.find('figcaption').text(value)
//})
var number = 0;
var update = function () {
$scope.$apply(function (ev) {
$scope.number = number;
});
}
$("input", element).on("keydown", function (evt) {
evt = evt || window.event;
var cancelKeypress = /^(48|49|50|51|52|53|54|55|56|57|58|59|16|24|37|38|39|40|8|9)$/.test("" + evt.keyCode);
if (!cancelKeypress) {
return false;
}
});
$scope.$watch("number", function (v) {
number = parseFloat(v + "") || 0;
number = Math.round(number * 100) + "";
var decimal = parseInt(number.substring(number.length - 2)) || 0;
var integer = parseInt(number.substring(0, number.length - 2)) || 0;
$("input.integer", element).val(integer);
$("input.decimal", element).val(decimal);
});
$("input", element).on("change", function () {
try {
number = parseFloat($("input.integer", element).val()) + parseFloat($("input.decimal", element).val()) / Math.pow(10, $("input.decimal", element).val().length);
if (isNaN(number))
number = 0;
} catch (e) {
number = 0;
}
update();
});
}
}
}
);
})(angular, angular.module('liquidpixels.directive'));
(function (ng, ngmodule) {
'use strict';
ngmodule.directive('numericstep', function ($parse) {
return {
scope: {
"number": '=ngModel',
"step": '=step',
},
// required to make it work as an element
restrict: 'E',
// replace with this html
template: '
',
replace: true,
// observe and manipulate the DOM
link: function ($scope, element, attrs) {
//attrs.$observe('caption', function(value) {
// element.find('figcaption').text(value)
//})
if (!$scope.step) {
$scope.step = 1;
}
var number = 0;
var update = function () {
$scope.$apply(function (ev) {
$scope.number = number;
});
}
$(".up", element).click(function () {
if (number || number === 0)
number += $scope.step;
else
number = 0;
$("input", element).val(number);
update();
});
$(".down", element).click(function () {
if (!number)
number = 0;
if (number - $scope.step >= 0)
number -= $scope.step;
$("input", element).val(number);
update();
});
$("input", element).on("keydown", function (evt) {
evt = evt || window.event;
var cancelKeypress = /^(48|49|50|51|52|53|54|55|56|57|58|59|16|24|37|38|39|40)$/.test("" + evt.keyCode);
if (!cancelKeypress) {
return false;
}
});
$scope.$watch("number", function (v) {
number = v;
$("input", element).val(v);
});
$("input", element).on("change", function () {
try {
number = parseInt($("input", element).val());
if (isNaN(number))
number = 0;
number = Math.round(number / $scope.step) * $scope.step;
} catch (e) {
number = 0;
}
update();
});
}
}
}
);
})(angular, angular.module('liquidpixels.directive'));
/**
* Gestisce il load delle immagini con un'animazione in caso di src funzionante.
* In caso di errori mostra immagine 1x1 transparente.
*/
(function (ng, ngmodule, _) {
ngmodule.directive('lpResponsive', ['$window', function ($window) {
return {
restrict: 'A',
scope: {
lpResponsive: '='
},
template: '',
link: function (scope, element, attrs) {
var classesJson = _.isString(scope.lpResponsive) ? JSON.parse(scope.lpResponsive) : scope.lpResponsive;
// classesJson = {'mobile':'btn-xs', 'tablet':'btn-sm', 'desktop': 'btn', 'desktop-lg': 'btn-lg'}
var update = function () {
var device = 'desktop';
var w = ng.element($window).width();
if (w < 768) {
device = 'mobile';
} else if (w >= 768 && w < 992) {
device = 'tablet';
} else if (w >= 992 && w < 1200) {
device = 'desktop';
} else if (w >= 1200) {
device = 'desktop-lg';
}
for (var c in classesJson) ng.element(element).removeClass(classesJson[c]);
var cssClass = classesJson[device];
if (ng.isDefined(cssClass)) {
ng.element(element).addClass(cssClass);
}
}
var t;
ng.element($window).bind('resize', function () {
clearTimeout(t);
t = setTimeout(function() {
update();
scope.$apply();
}, 300);
});
update();
}
};
}]);
})(angular, angular.module('liquidpixels.directive'), _);
(function (ng, ngmodule, $, _) {
'use strict';
ngmodule.directive('lpTokenfield', ['$timeout', function ($timeout) {
var defaults = {
delimiter: ',',
inputType: 'text'
}
return {
require: '^ngModel',
restrict: 'A',
scope: {
ngModel:"="
},
link: function (scope, element, attrs) {
var selfChanged = false; // usato per non fare init se la modifica di ngModel è fatta dalla direttiva
var config = {};
/*if (!_.isUndefined(attrs.lpTokenfield)
&& !_.isEmpty(attrs.lpTokenfield)
&& !_.isNull(attrs.lpTokenfield)
&& _.isString(attrs.lpTokenfield))
config = ng.extend(config, JSON.parse(attrs.lpTokenfield));*/
var init = function () {
$(element).tokenfield(config);
$(element).off().on('tokenfield:createdtoken tokenfield:removedtoken tokenfield:editedtoken', function () {
selfChanged = true;
updateModel();
$timeout(function () { selfChanged = false; }, 1);
});
}
var updateModel = function () {
scope.ngModel = $(element).tokenfield('getTokensList');
}
scope.$watch('ngModel', function (newVal, oldVal) {
if (ng.isDefined(newVal) && !selfChanged) {
init();
$(element).tokenfield('setTokens', newVal);
}
});
scope.$on('$destroy', function () {
$(element).tokenfield('destroy');
});
init();
}
}
}]);
})(angular, angular.module('liquidpixels.directive'), jQuery, _);
(function ($, ngmodule) {
'use strict';
ngmodule.directive('visualcheck', function ($parse) {
return {
scope: {
"model": '=ngModel',
"imgCheck": '=ngImageCheck',
"imgUncheck": '=ngImageUncheck',
},
// required to make it work as an element
restrict: 'E',
template: '
',
replace: true,
// observe and manipulate the DOM
link: function ($scope, element, attrs) {
$(".check", element).on("click", function (evt) {
$scope.$apply(function () {
$scope.model = false;
});
});
$(".uncheck", element).on("click", function (evt) {
$scope.$apply(function () {
$scope.model = true;
});
});
$scope.$watch("model", function (v) {
if (v) {
$(".check", element).show();
$(".uncheck", element).hide();
} else {
$(".check", element).hide();
$(".uncheck", element).show();
}
});
$scope.$watch("imgCheck", function (v) {
$(".check", element).attr("src", v);
});
$scope.$watch("imgUncheck", function (v) {
$(".uncheck", element).attr("src", v);
});
}
}
}
);
})(jQuery, angular.module('liquidpixels.directive'));
/*
*
*/
;(function(ng, ngmodule){
ngmodule.filter('dateformat', ['$log', function ($log) {
return function (text, outformat, informat) {
if (text === undefined)
return "";
try {
var date = moment(text);
if (ng.isDefined(informat)) date = moment(text, informat);
return date.format(outformat);
} catch (e) {
$log.error('Error while parsing date: '+e);
return "error";
}
}
}]);
})(angular, angular.module('liquidpixels.filters'));
/*
*
*/
;(function(ng, ngmodule){
ngmodule.filter('truncate', function(){
return function(text, length, end){
if (text === undefined)
return "";
if (isNaN(length))
length = 10;
if (end === undefined)
end = "...";
var maxLength = length - end.length;
return (text.length>maxLength)?text.substring(0, maxLength)+end:text;
}
});
ngmodule.filter('unsafe', function($sce) {
return function(val) {
return $sce.trustAsHtml(val);
};
});
ngmodule.filter("unique", function () {
// we will return a function which will take in a collection
// and a keyname
return function (collection, keyname) {
// we define our output and keys array;
var output = [],
keys = [];
// we utilize angular's foreach function
// this takes in our original collection and an iterator function
angular.forEach(collection, function (item) {
// we check to see whether our object exists
var key = item[keyname];
// if it's not already part of our keys array
if (keys.indexOf(key) === -1) {
// add it to our keys array
keys.push(key);
// push this item to our final output array
output.push(item);
}
});
// return our array which should be devoid of
// any duplicates
return output;
};
});
})(angular, angular.module('liquidpixels.filters'));
;(function (ng, ngmodule) {
ngmodule.filter('typeahead', ['$log', function ($log) {
return function (text, term, ignoreCase) {
if (text == null || term == null) return;
var terms = term.split(" ");
var output = "";
for (var i = 0; i < terms.length; i++) {
var pattern = new RegExp(terms[i] , 'g' + (ignoreCase) ? 'i' : '');
text = text.replace(pattern, "#1#$#");
}
text = text.split("#1#").join("");
text = text.split("#2#").join("");
return text;
}
}]);
})(angular, angular.module('liquidpixels.filters'));