var cssJqTsoft = false;
$('link').each(function() {
var href = $(this).attr('href') || '';
if (href.indexOf('jqTsoft\.')) {
cssJqTsoft = true;
}
});
if (cssJqTsoft === false) {
var css = '/theme/standart/css/jqTsoft.css?114';
$("head").append("");
}
if ($.fn.on === undefined) {
$.fn.on = function(event, selector, foksiyon) {
//cLog("Tip" + typeof selector);
if (typeof selector === 'string') {
this.find(selector).live(event, foksiyon);
} else if (typeof selector === 'function') {
this.live(event, selector);
}
};
}
if ($.fn.draggable === undefined) {
$.getScript('/theme/standart/js/jquery-ui-1.7.2.custom.min.js');
}
if ($.fn.checkboxStyle === undefined) {
$.fn.checkboxStyle = function(arr) {
var aktif = 'AKTİF';
var pasif = 'PASİF';
if (arr != undefined) {
if (arr.yes != undefined) {
aktif = arr.yes;
}
if (arr.no != undefined) {
pasif = arr.no;
}
}
var html = '
';
this.each(function() {
var name = $(this).attr('name');
var id = $(this).attr('id');
var val = $(this).is(':checked') ? 1 : 0;
$(this).after(html);
$(this).parent().find('.iphoneStyle:last input').attr('name', name);
$(this).parent().find('.iphoneStyle:last input').attr('id', id);
$(this).parent().find('.iphoneStyle:last input').val(val);
$(this).remove();
if (name !== undefined)
$(this).parent().find('.iphoneStyle:last .iChecked span').text(aktif);
if (id !== undefined)
$(this).parent().find('.iphoneStyle:last .iUnChecked span').text(pasif);
});
$('.iphoneStyle').unbind('click').click(function() {
var ml = parseInt($(this).find('.iphoneBoruHat').css('margin-left'));
if (ml == 0) {
ml = -40;
$('.sliderLeft').css('visibility', 'hidden');
$(this).find('input').val(0);
} else {
ml = 0;
$('.sliderRight').css('visibility', 'visible');
$(this).find('input').val(1);
}
$(this).parent().find('.iphoneStyle:last input').trigger('change');
$(this).find('.iphoneBoruHat').animate({
marginLeft: ml
}, 300);
});
};
}
//Javascript fonksiyonlarının kullanımı için tema klasöründeki >>> Mesaj.tpl içerisine bakınız.
function merge_options(obj1, obj2) {
var obj3 = {};
for (var attrname in obj1) {
obj3[attrname] = obj1[attrname];
}
for (var attrname in obj2) {
obj3[attrname] = obj2[attrname];
}
return obj3;
}
function Message(options) {
Message.counter = Message.counter || 0;
var opt = {
id: 'myDialog',
title: '',
html: '',
timeout: 3500,
width: 300,
height: 'auto',
buttons: [],
openingEffect: 'drop',
openingEffectTime: 600,
openingEasing: 'easeOutBack',
closingEffect: 'ckBottom',
closingEffectTime: 600,
closingEasing: 'swing',
selector: '.ckDialog:last',
afterClose: function() {
}
};
//'none',
var allowedEffects = ['tsoftTop', 'tsoftLeft', 'tsoftBottom', 'tsoftRight', 'blind', 'bounce', 'clip', 'drop', 'explode', 'fade', 'fold', 'highlight', 'puff', 'pulsate', 'scale', 'shake', 'size', 'slide', 'transfer'];
var allowedEasing = ["linear", "swing", "easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic", "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInSine", "easeOutSine", "easeInOutSine", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic", "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack", "easeInBounce", "easeOutBounce", "easeInOutBounce"];
for (var i in options) {
opt[i] = options[i];
}
this.get = function(key) {
return opt[key];
};
this.set = function(key, val) {
opt[key] = val;
return true;
};
var _this = this;
Message.instance = Message.instance || {};
Message.instance['activeDialog'] = this;
if (typeof Message.instance[_this.get('id')] !== 'undefined') {
var selector = $(_this.get('selector'));
var overlay = $('.ckOverlay:last');
selector.remove();
overlay.remove();
$('.ui-effects-wrapper').remove();
}
Message.instance[_this.get('id')] = _this;
Message.getInstance = function(id) {
return Message.instance[id];
};
Message.showDialog = function(title, html, width, height) {
//_this.set('buttons', []);
var count = Object.keys(Message.instance).length + 1;
var _setting = {
id: 'myDialog_' + count,
title: title,
html: html,
width: width > 100 ? width : 300,
height: height > 0 ? height : 'auto'
};
var _instance = new Message(_setting);
_instance.show();
};
this.setDialogEvents = function() {
$(_this.get('selector')).find('.ckClose').unbind('click').click(function() {
_this.close();
});
};
this.close = function(selector) {
var selector = $(_this.get('selector'));
var overlay = $('.ckOverlay:last');
var top = $(document).scrollTop() + (($(window).height() - selector.height()) / 2) - 50;
top = top > 0 ? top : 100;
var left = ($(window).width() - selector.width()) / 2;
var newTop = top;
var newLeft = left;
switch (_this.get('closingEffect')) {
case "tsoftTop":
newTop = -selector.height();
break;
case "tsoftLeft":
newLeft = -selector.width();
break;
case "tsoftBottom":
newTop = $(document).scrollTop() + $(window).height();
break;
case "tsoftRight":
newLeft = $(window).width();
break;
}
var afterClose = _this.get("afterClose");
var fonk1 = function() {
setTimeout(function() {
overlay.remove();
$(_this.get('selector')).parents('.ckWrapper').remove();
$(_this.get('selector')).parent().remove();
}, 300);
afterClose();
};
if ($.inArray(_this.get('closingEffect'), ['tsoftTop', 'tsoftLeft', 'tsoftBottom', 'tsoftRight']) > -1) {
selector.animate({
left: newLeft,
top: newTop
}, _this.get('closingEffectTime'), _this.get('closingEasing'), fonk1);
} else if ($.inArray(_this.get('closingEffect'), allowedEffects) > -1) {
var options = {
effect: _this.get('closingEffect'),
easing: _this.get('closingEasing'),
duration: _this.get('closingEffectTime'),
complete: fonk1
};
if (_this.get('openingEffect') === "scale") {
options.percent = 0;
} else if (_this.get('openingEffect') === "transfer") {
options.to = '.sepet:first'; //= {to: "#button", className: "ui-effects-transfer"};
options.className = 'ckDialog';
} else if (_this.get('openingEffect') === "size") {
options.to = { width: 200, height: 60 };
}
var v = parseInt($.fn.jquery.replace(/\D/ig, ''));
if (v > 170) {
$(_this.get('selector')).hide(options);
} else {
$(_this.get('selector')).hide(options.effect, options, options.duration, options.complete);
setTimeout(fonk1, _this.get('closingEffectTime'));
}
} else {
fonk1();
}
};
Message.debug = function(content, width, time_out) {
if (time_out === undefined)
time_out = 3000;
if (width === undefined)
width = 300;
var mmm = new Message({ html: content, width: width, id: 'debugDialog' });
mmm.set('openingEffect', 'none');
mmm.show();
$('.ckHeader:last').remove();
$('.ckContent:last').css('line-height', '20px');
$('.ckButtonArea:last').remove();
setTimeout(function() {
mmm.close();
}, time_out);
mmm.setDialogEvents();
};
this.callBack = function() { //Ajax isteğinden sonra çalışır.
return true;
};
Message.notify = function(notice, success, timeout) {
if (timeout === undefined)
timeout = 3000;
if (success === undefined) {
success = 1;
timeout = 2 * timeout;
}
$("body").append('' + notice + '
');
$(".ckNotify:last").css("top", $("body").height());
$(".ckNotify:last").animate({ top: 20 }, 1000, function() {});
var _this1 = $(".ckNotify:last");
setTimeout(function() {
_this1.animate({ opacity: 0 }, 500, function() {
$(this).remove();
});
}, timeout);
};
this.refresh = function(key, value) {
_this.set(key, value);
switch (key) {
case 'buttons':
_this.showButtons();
break;
}
return true;
};
this.show = function() {
var dialogId = _this.get('id');
_this.set('selector', '#' + dialogId);
var height = _this.get('height');
var header = _this.get('title');
var content = _this.get('html');
var width = _this.get('width');
var z_index = Message.counter * 2 + 9980;
Message.counter++;
var maxHeight = Math.max($(window).height(), $('body').height(), $(document).height());
var html = '\n\
';
$('body').append(html);
$('.ckContent:last button.tDialog').each(function() {
var b = _this.get('buttons');
var myFn;
if (typeof $(this).attr('onclick') === 'string') {
var s = "function myFn(){ " + $(this).attr('onclick') + " }";
eval(s);
} else {
myFn = $(this).attr('onclick');
}
b.push({ text: $(this).text(), fn: myFn });
_this.set('buttons', b);
$(this).remove();
});
_this.showButtons();
$(_this.get('selector')).find('.tDialog').remove();
//$('.ckHeader:last').html(header + '');
if (height !== 'auto') {
$('.ckContent').css({ 'max-height': height + 'px', 'overflow-y': 'auto' });
}
var top = $(document).scrollTop() + (($(window).height() - $(_this.get('selector')).height()) / 2) - 10;
top = top > 0 ? top : 100;
var left = ($(window).width() - width) / 2;
var newTop = top;
var newLeft = left;
switch (_this.get('openingEffect')) {
case "tsoftTop":
newTop = -$(_this.get('selector')).height();
break;
case "tsoftLeft":
newLeft = -$(_this.get('selector')).width();
break;
case "tsoftBottom":
newTop = $(document).scrollTop() + $(window).height();
break;
case "tsoftRight":
newLeft = $(window).width();
break;
}
$(_this.get('selector')).css({ top: newTop, left: newLeft, width: width, 'z-index': z_index + 1 });
if ($.inArray(_this.get('openingEffect'), ['tsoftTop', 'tsoftLeft', 'tsoftBottom', 'tsoftRight']) > -1) {
var ef = typeof _this.get('openingEasing') === 'undefined' ? 'easeOutElastic' : _this.get('openingEasing');
$(_this.get('selector')).animate({
left: left,
top: top
}, _this.get('openingEffectTime'), _this.get('openingEasing'), function() {
$(_this.get('selector')).draggable({ handle: ".ckFooter:last" });
});
} else if ($.inArray(_this.get('openingEffect'), allowedEffects) > -1) {
$(_this.get('selector')).css('min-height', $(_this.get('selector')).height());
$(_this.get('selector')).hide();
var options = {
effect: _this.get('openingEffect'),
easing: _this.get('openingEasing'),
duration: _this.get('openingEffectTime'),
complete: function() {
$(_this.get('selector')).draggable({ handle: ".ckFooter:last" });
}
};
if (_this.get('openingEffect') === "scale") {
options.percent = 0;
} else if (_this.get('openingEffect') === "transfer") {
options.to = '.sepet:first'; //= {to: "#button", className: "ui-effects-transfer"};
options.className = 'ckDialog';
} else if (_this.get('openingEffect') === "size") {
options.to = { width: width };
}
var v = parseInt($.fn.jquery.replace(/\D/ig, ''));
if (v > 170) {
$(_this.get('selector')).show(options);
} else {
$(_this.get('selector')).show(options.effect, options, options.duration, options.complete);
}
setTimeout(function() {
$(_this.get('selector')).show('fast');
}, _this.get('openingEffectTime') + 100);
} else {
$(_this.get('selector')).show();
}
_this.setDialogEvents();
return true;
};
Message.addButtofn = function(name, func) {
var b = _this.get('buttons');
if (typeof name !== 'undefined') {
b.push({ text: name, fn: func });
_this.set('buttons', b);
}
Message.instance.activeDialog.showButtons(name, func);
};
this.showButtons = function() {
var b = _this.get('buttons');
$(_this.get('selector')).find('.ckButtonArea button').remove();
//$(_this.get('selector')).append('');
var div = $(_this.get('selector')).find('.ckButtonArea');
for (var i = 0; i < b.length; i++) {
var ad = b[i].text;
// var func = typeof b[i].fn === 'function' ? b[i].fn : function() {
// return true;
// };
var id = "button_" + (Message.counter * 100 + i);
div.append('');
$('#' + id).click(function() {
var no = $(this).attr('data-number');
var func = _this.get('buttons')[no].fn || function(param) {
return true;
};
var selector = $(_this.get('selector'));
if (func($('#' + id)) !== false) {
_this.close(selector);
}
});
}
$('.ckButtonArea button').css('position', 'relative');
return true;
};
return this;
}
var Message1 = new Message({});
var TSOFT = {
onEk: 'T_',
btn_no: 0,
dialogNumber: 0,
callback: function() {
},
settings: {
openingEffect: 'clip',
openingEffectTime: 600,
openingEffectOptions: { easing: 'swing' },
closingEffect: 'clip',
closingEffectTime: 600,
closingEffectOptions: { easing: 'swing' }
},
allowedEffects: ['none', 'tsoftTop', 'tsoftLeft', 'tsoftBottom', 'tsoftRight', 'blind', 'bounce', 'clip', 'drop', 'explode', 'fade', 'fold', 'highlight', 'puff', 'pulsate', 'scale', 'shake', 'size', 'slide', 'transfer'],
allowedEasing: ["linear", "swing", "easeInQuad", "easeOutQuad", "easeInOutQuad", "easeInCubic", "easeOutCubic", "easeInOutCubic", "easeInQuart", "easeOutQuart", "easeInOutQuart", "easeInQuint", "easeOutQuint", "easeInOutQuint", "easeInExpo", "easeOutExpo", "easeInOutExpo", "easeInSine", "easeOutSine", "easeInOutSine", "easeInCirc", "easeOutCirc", "easeInOutCirc", "easeInElastic", "easeOutElastic", "easeInOutElastic", "easeInBack", "easeOutBack", "easeInOutBack", "easeInBounce", "easeOutBounce", "easeInOutBounce"],
counter: 0,
buttons: new Array(),
serialize: function(element) {
var obj = {};
$(element).find('input,textarea,select').each(function() {
if (typeof $(this).attr('name') !== 'undefined') {
obj[$(this).attr('name')] = $(this).val();
if (typeof Ext !== 'undefined') {
var el = Ext.getCmp($(this).attr('name'));
if (typeof el !== 'undefined') {
if (el.xtype === 'combobox') {
obj[$(this).attr('name')] = el.getValue();
} else if (el.xtype === 'checkbox') {
obj[$(this).attr('name')] = el.getSubmitValue();
}
}
}
}
});
return obj;
},
isMobile: function() {
var check = false;
(function(a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
return check;
},
setForm: function(arr) {
for (var key in arr) {
$('*[name=' + key + ']').val(arr[key]);
if (typeof Ext !== 'undefined') {
if (typeof Ext.getCmp(key) !== 'undefined' && Ext.getCmp(key).xtype === 'combobox') {
var el = Ext.getCmp(key);
el.setValue(arr[key].toString());
}
}
}
},
replaceDiv: function(element) {
var onEk = TSOFT.onEk;
var d = $('body').find(element);
var dizi2 = d.attr('class').split(/\s+/ig);
for (var i = 0; i < dizi2.length; i++) {
d.addClass(onEk + dizi2[i]);
}
d.find('div, span, a, button').each(function() {
var cls = $(this).attr('class');
var dizi = cls.split(/\s+/ig);
for (var i = 0; i < dizi.length; i++) {
$(this).addClass(onEk + dizi[i]);
}
});
},
showUrl: function(url, header, width, callback) {
if (header === undefined)
header = "Sayfa";
if (width === undefined)
width = 500;
$.ajax({
url: url,
success: function(msg) {
TSOFT.showDialog(header, msg, width);
callback();
}
});
},
showDialog: function(header, content, width, height, recursive) {
var count = Object.keys(Message.instance).length + 1;
var _setting = {
id: 'myDialog_' + count,
title: header,
html: content,
width: width > 100 ? width : 300,
height: height > 0 ? height : 'auto',
openingEffect: TSOFT.settings.openingEffect,
openingEffectTime: TSOFT.settings.openingEffectTime,
openingEasing: TSOFT.settings.openingEffectOptions.easing,
closingEffect: TSOFT.settings.closingEffect,
closingEffectTime: TSOFT.settings.closingEffectTime,
closingEasing: TSOFT.settings.closingEffectOptions.easing
};
var _instance = new Message(_setting);
_instance.show();
TSOFT.callback();
TSOFT.callback = function() {};
var cssVar = false;
$('link').each(function() {
if (/(compressed|acilir_pencere)\.css/ig.test($(this).attr('href'))) {
cssVar = true;
}
});
var ckPos = $('.ckDialog').css('position');
if (typeof recursive === 'undefined' && (cssVar === false || (ckPos !== 'absolute' && ckPos !== 'relative'))) {
//$('.ckOverlay, .ckWrapper').hide();
var css = '/theme/standart/sub_theme/genel/astana/mavi/acilir_pencere.css?id=007';
$("head").append("");
return false;
}
},
addButton: function(name, func) {
Message.addButtofn(name, func);
},
debug: function(content, time_out, width) {
if (typeof time_out === 'undefined')
time_out = 3000;
if (typeof width === 'undefined')
width = 300;
var count = Object.keys(Message.instance).length + 1;
var _setting = {
id: 'myDialog_' + count,
title: '',
html: content,
width: width > 100 ? width : 300,
openingEffect: 'none',
closingEffect: 'none',
closingEffectTime: 0,
openingEffectTime: 0
};
var _instance = new Message(_setting);
_instance.show();
$('#' + _setting.id).find('.ckContent').css('border', 'none').addClass('br6');
$('#' + _setting.id).find('.ckFooter').remove();
$('#' + _setting.id).find('.ckClose').remove();
$('#' + _setting.id).css('min-height', '20px');
$('#' + _setting.id).parent().click(function(e) {
if ($(e.target).attr('class') !== 'ckDistance') {
_instance.close();
}
});
setTimeout(function() {
_instance.close();
}, time_out);
//TSOFT.setDialogEvents();
},
callBack: function() { //Ajax isteğinden sonra çalışır.
return true;
},
notify: function(notice, success, timeout) {
if (timeout === undefined)
timeout = 3000;
if (success === undefined) {
success = 1;
timeout = 2 * timeout;
}
$("body").append('' + notice + '
');
$(".tNotify:last").css("top", "0px");
$(".tNotify:last").animate({ top: $(window).height() - 80 }, 1000, function() {});
var _this = $(".tNotify:last");
setTimeout(function() {
_this.animate({ opacity: 0 }, 500, function() {
$(this).remove();
});
}, timeout);
},
//Varsayılan bir değere sahip inputa focuslanınca varsayılan değer silinir, Focusoutta değer boş ise varsayılan değer olur.
focusText: function(element) {
$(element).each(function() {
var deger = $(this).val();
$(this).focus(function() {
if ($(this).val() === deger)
$(this).val('');
}).focusout(function() {
if ($(this).val() === '')
$(this).val(deger);
});
});
},
//tablonun css'lerini güzelleştirir.
tableRender: function(element, cls) {
if (cls == undefined)
cls = "Tlist";
$(element).addClass(cls);
$("table." + cls + " tbody tr:odd").addClass("odd");
$("table." + cls + " tbody tr:even").addClass("even");
//$("table." + cls + " tr:last").css("border-bottom", "1px solid #ccc");
},
pager: function(element, total, perpage, fonksiyon) {
$(element).html("");
$(element).addClass("Tpager");
$(element).append('');
if (total <= perpage)
return false;
$(element).find("ul").append('');
var totalWidth = $(element).width() > 150 ? $(element).width() : 150;
var li = $(element).find('ul li');
var liWidth = li.width() + (parseInt(li.css('padding-left')) + parseInt(li.css('margin-left'))) * 2 + 7;
var liCnt = parseInt(totalWidth / liWidth);
var pageCnt = parseInt((total / perpage) + 1);
for (var i = 1; i < pageCnt; i++) {
var currentPage = i + 1;
$(element).find("ul").append('');
}
$(element).find(".sayfa_1").after('...');
$(element).find(".sayfa_" + pageCnt).before('...');
$(element + " ul li.myPager").unbind('click').click(function() {
var indis = parseInt($(this).text());
$(element + " ul li.myPager").hide();
$(element).find('.dot3').show();
$(element + " ul li").removeClass('selected');
$(this).addClass('selected');
var showPage = [];
if (pageCnt < 9) {
$(element).find('.dot3').hide();
for (var i = 1; i < pageCnt + 1; i++) {
showPage.push(i);
}
} else if (indis < 5) {
$(element).find('.dot3:first').hide();
showPage = [1, 2, 3, 4, 5, 6, 7, pageCnt];
} else if (indis + 4 > pageCnt) {
$(element).find('.dot3:last').hide();
showPage = [1, pageCnt - 6, pageCnt - 5, pageCnt - 4, pageCnt - 3, pageCnt - 2, pageCnt - 1, pageCnt];
} else {
showPage = [1, indis - 2, indis - 1, indis, indis + 1, indis + 2, pageCnt];
}
for (var i in showPage) {
$(element).find(".sayfa_" + showPage[i]).show();
}
fonksiyon(parseInt(indis));
});
$(element + " ul li.myPager:first").trigger('click');
return false;
},
numberFormat: function(number, digitCount) {
var r = "" + number;
while (r.length < digitCount) {
r = "0" + r;
}
return r;
},
linker: function(element) {
$(element).each(function() {
var link = window.location.href.replace(window.location.origin, '');
if (link == $(this).attr('href'))
$(this).addClass('selected');
});
},
telephoneControl: function(number) {
number = number + "";
if (/^(\+|00)/ig.test(number + "") && number.replace(/\D/ig, '').length > 7) {
return number.indexOf('_') > 0 ? false : true;
}
if ((number.length == 10 && number.substr(0, 1) != 0) || (number.length == 11 && number.substr(0, 1) == 0) || number == "") {
return true;
} else {
return false;
}
},
loadCss: function(path) {
var cacheTag = getCookie('cacheTag');
if (typeof cacheTag === 'undefined') {
$.get('/Y/mod/Settings/Other/getMaskedRevision', function(data) {
cacheTag = data;
setCookie('cacheTag', cacheTag, 10);
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = path + '?cacheTag=' + cacheTag;
link.media = 'all';
$("head").append(link);
});
} else {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = path + '?cacheTag=' + cacheTag;
link.media = 'all';
$("head").append(link);
}
return true;
}
};
var Cart = {
settings: {
showHeaderCart: false,
showAddCartPopup: false
},
showHeaderCart: function() {
if (Cart.settings.showHeaderCart === false) {
return false;
}
var AcilirSepetHeight = 0;
$('#cart-soft-count').parent().css({ position: 'relative' });
$('#cart-soft-count').parents('div').css({ overflow: 'visible' });
$('#cart-soft-count').mouseover(function() {
if ($('.AcilirSepet').length > 0) {
if ($('.AcilirSepet').height() === 0 && $('.AcilirSepet ul:first li').length > 0) {
$('.AcilirSepet').show();
$('.AcilirSepet').animate({ height: AcilirSepetHeight }, 500);
}
return true;
}
$.get('/srv/shopping/shopping/show-header-cart', function(content) {
$('.AcilirSepet').remove();
$('#cart-soft-count').parent().append(content);
AcilirSepetHeight = $('.AcilirSepet').height();
$('.AcilirSepet').height(0);
if ($('.AcilirSepet ul:first li').length > 0)
$('.AcilirSepet').animate({ height: AcilirSepetHeight }, 500);
});
});
$('#cart-soft-count').parent().parent().parent().mouseleave(function() {
//$('.AcilirSepet').hide();
$('.AcilirSepet').animate({ height: 0 }, 500, function() {
$('.AcilirSepet').hide();
});
});
},
changeNumber: function() {
var a = function() {
var input = $(this).parent().find('input.adet');
var adet = parseFloat(input.val().replace(/[^0-9\.]/ig, ''));
adet = isNaN(adet) ? 1 : adet;
var birim = input.val().replace(/\s*\d+\.?\d*?\s*/ig, '');
birim = birim === '' ? '' : ' ' + birim;
var varsayilanArtis = $(this).hasClass('arti') ? 1 : -1;
var artis = parseFloat($(this).attr('alt')); //parseInt($(this).parent().find('.arti').attr('alt'));
artis = isNaN(artis) ? varsayilanArtis : artis;
var sayi = adet + parseFloat(artis);
if (sayi.toString().indexOf('.') > 0) {
sayi = sayi.toFixed(2);
} else {
sayi = sayi.toFixed(0);
}
if (sayi < 0)
return false;
// if ((sayi % artis) !== 0) {
// sayi = artis * parseInt(sayi / artis);
// }
var sayiText = sayi.toString();
var adetStr = sayi + birim;
// if (adet.indexOf('.') > 0) {
// var i = adet.indexOf('.');
// adetStr = sayi.toString().substr(0, i) + '.' + sayi.toString().substr(i, sayi.toString().length - i) + birim;
// }
if (sayi > 0.0) {
input.val(adetStr);
Cart.updateProduct(this);
}
};
$('.SepetTable .arti,.SepetTable .eksi').unbind('click').click(a);
$('.SepetTable input.adet').blur(a);
},
removeProduct: function() {
$('.SepetTable .remove').unbind('click').click(function() {
// var pr_id = $(this).parents('.adetDiv').attr('data-product');
// var sub_pr_id = $(this).parents('.adetDiv').attr('data-subproduct');
var _this = this;
var sepet_id = $(_this).parents('.adetDiv').attr('data-id');
$.ajax({
url: '/srv/service/cart/remove/' + sepet_id,
success: function(response) {
response = JSON.parse(response);
var current = parseInt($("#cart-soft-count span").html());
current = current - response.quantity;
if (current == 0) {
$("#cart-soft-count label").html('0,00');
}
Cart.refresh(function() {
$("#cart-soft-count span").html(current);
$("#cart-soft-count label").html($(".SepetTutarTablo .second").html().replace(" TL", ""));
});
}
});
});
},
updateProduct: function(_this) {
var pr_id = $(_this).parents('.adetDiv').attr('data-product');
var sub_pr_id = $(_this).parents('.adetDiv').attr('data-subproduct') || 0;
var sepet_id = $(_this).parents('.adetDiv').attr('data-id');
var total_count = $(_this).parent().find('input.adet').val();
var tr = '.' + $(_this).parents('tr').attr('class');
$.ajax({
url: '/srv/service/cart/update-item/' + sepet_id + '/' + total_count,
dataType: 'json',
//'/conn/Shopping/Shopping/updateCart/' + pr_id + '/' + sub_pr_id + '/' + total_count,
success: function(msg) {
if (msg.status === 0) {
TSOFT.debug(msg.statusText, 4000, 400);
}
Cart.refresh(function() {
Cart.fireRow($(tr));
});
}
});
},
addRelatedProduct: function() {
$('.tamamlayiciUrun .GenelButon').unbind('click').click(function(e) {
e.preventDefault();
var productType = $(this).parents('.tamamlayiciUrun').attr('data-type');
var mainPrId = $(this).attr('alt').split('-');
var prId = parseInt(mainPrId[0]);
var prSubId = mainPrId[2] ? parseInt(mainPrId[2]) : '';
mainPrId = parseInt(mainPrId[1]);
var mainPrSubId = c_altUrunId();
mainPrId = mainPrSubId > 0 ? mainPrId + ':' + mainPrSubId : mainPrId;
if (productType !== '4') {
sepeteEkle(prId, prSubId, 1, '', '');
} else {
//le.log(prId + "|" + prSubId + "|" + mainPrId + "|");
sepeteEkle(prId, prSubId, 1, '', '', mainPrId);
}
sepeteEkle.showCartWin = false;
Cart.refresh(function() {
Cart.fireRow($('.SepetTable tr:last'));
});
});
},
fireRow: function(element) {
//cLog(element.length);
if (element.length < 1) {
return true;
}
element.css('background-color', '#96E296');
setTimeout(function() {
if (element.length < 1) {
return true;
}
element.css('background-color', '');
}, 1000);
/*
element.animate({
backgroundColor: "#CCC"
}, 700, function () {
element.animate({
backgroundColor: '#fff'
}, 700, function () {
if(element.length<1){
return true;
}
element.css({'background-color': ''});
});
});
*/
},
setEvents: function() {
//Cart.updateProduct();
Cart.removeProduct();
Cart.changeNumber();
Cart.addRelatedProduct();
},
refresh: function(callback) {
$.get('/srv/shopping/shopping/show-cart-win', function(html) {
// Cart.dialog('Alışveriş Sepetim 2', html, 750);
var d = document.createElement('div');
$('.SepetIcerik:last').html($(d).append(html).find('.SepetIcerik').html());
Cart.setEvents();
if (typeof callback === 'function')
callback();
});
},
show: function(tamamlayici_ana_urun_id) {
if (Cart.settings.showAddCartPopup === false) {
return false;
}
var clientBrowser = '';
try {
clientBrowser = navigator.userAgent;
} catch (error) {
clientBrowser = 'not-set';
}
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(clientBrowser) ? true : false;
if (isMobile) {
window.location.href = '/Sepet.php';
return false;
}
$.get('/srv/shopping/shopping/show-cart-win/' + tamamlayici_ana_urun_id, function(html) {
TSOFT.showDialog('', html, 864);
setTimeout(function() {
Cart.setEvents();
}, TSOFT.settings.openingEffectTime + 100);
if (typeof $.fn.yukseklikEsitle !== 'undefined') {
$('.TamamlayiciUrunler ul li').yukseklikEsitle();
}
});
}
};
var LANG = {
prefix: 'LANG_',
selected_lang: '',
cookie_name: 'lang',
last_lang_arr: new Array(),
lang: {},
run: function(selectedKey) {
if (typeof selectedKey !== 'undefined') {
//selectedKey = LANG.prefix + selectedKey.replace(/'LANG_'/g, '');
//if (typeof LANG.last_lang_arr[selectedKey] !== 'undefined')
LANG.insert([selectedKey]);
//$('.' + LANG.prefix + selectedKey).text(LANG.last_lang_arr[selectedKey]);
return true;
}
$('span[class^=' + LANG.prefix + ']').css('color', 'inherit');
$('span[class^=' + LANG.prefix + ']').each(function() {
var key = $(this).attr('class').trim();
key = key.replace(LANG.prefix, '');
var text = LANG.get(key) || '';
var replaceArr = text.match(/\|(.*?)\|/ig);
$(this).addClass('reset');
if (null === replaceArr) {
return false;
}
for (var i = 0; i < replaceArr.length; i++) {
var replaceKey = replaceArr[i].replace(/\|/g, '');
if ($(this).attr('data-' + replaceKey)) {
text = text.replace(replaceArr[i], $(this).attr('data-' + replaceKey));
}
}
$(this).text(text);
$(this).removeClass(LANG.prefix + key);
});
//for (var key in LANG.last_lang_arr) {
/*
if ($('.' + LANG.prefix + key).length > 0) {
$('span[class^=' + LANG.prefix + ']').css('color', 'inherit');
//$('.LANG_' + key).css('color', '#D30F94');
$('.' + LANG.prefix + key).addClass('reset');
var replaceArr = LANG.last_lang_arr[key].match(/\|(.*?)\|/ig);
if (replaceArr) { //%x% içinde değer varsa, data-x içindeki değeri oraya replace et
$('.' + LANG.prefix + key).each(function () {
var newText = LANG.last_lang_arr[key];
for (var i = 0; i < replaceArr.length; i++) {
var replaceKey = replaceArr[i].replace(/\|/g, '');
if ($('.' + LANG.prefix + key).attr('data-' + replaceKey)) {
newText = newText.replace(replaceArr[i], $(this).attr('data-' + replaceKey));
}
}
$(this).text(newText);
});
} else {
$('.' + LANG.prefix + key).text(LANG.last_lang_arr[key]);
}
}
*/
//}
setTimeout(function() {
$('span[class^=' + LANG.prefix + ']').css('color', 'inherit');
}, 3000);
},
getLang: function(is_load, callback) {
if (is_load === true && typeof getCookie(LANG.cookie_name) !== 'undefined' && getCookie(LANG.cookie_name).length === 2) {
LANG.selected_lang = getCookie(LANG.cookie_name);
if (typeof callback === 'function') {
callback();
}
} else {
$.get('/srv/admin/settings/language/selected-lang', function(msg) {
msg = msg.replace(/\W/ig, '');
if (msg.length > 1 && msg.length < 4) {
LANG.selected_lang = msg;
} else {
LANG.selected_lang = 'tr';
}
setCookie(LANG.cookie_name, LANG.selected_lang, 1);
if (typeof callback === "function")
callback();
});
}
return LANG.selected_lang;
},
load: function(lang_path, callback) {
var path = lang_path.replace(/\.js.*$/g, '');
path += lang_path.replace(/^.*(\.js)?(\?.*)?$/g, '.js$2');
try {
if (typeof getCookie('cacheTag') !== 'undefined')
path += '?cacheTag=' + getCookie('cacheTag');
} catch (ex) {
}
LANG.selected_lang = LANG.selected_lang.replace(/\W/i, '');
if (LANG.selected_lang.length !== 2) {
LANG.getLang(true, function() {
var url = '/lang_content/' + LANG.selected_lang + '/' + path;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
$("head").append(script);
setTimeout(function() {
LANG.run();
if (typeof callback !== 'undefined')
callback();
}, 1000);
});
} else {
var url = '/lang_content/' + LANG.selected_lang + '/' + path;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
$("head").append(script);
setTimeout(function() {
LANG.run();
if (typeof callback !== 'undefined')
callback();
}, 1000);
}
return true;
},
get: function(key, _default) {
var _defaultValue = _default || '' + key + '';
return typeof LANG.lang[key] !== 'undefined' ? LANG.lang[key] : _defaultValue;
},
set: function(arr) {
LANG.last_lang_arr = arr;
for (var key in arr) {
LANG.lang[key] = arr[key];
}
LANG.run();
},
insert: function(arr, iframe) {
for (var i = 0; i < arr.length; i++) {
var val = typeof LANG.lang[arr[i]] !== 'undefined' ? LANG.lang[arr[i]] : '' + arr[i] + '';
var element;
if (typeof iframe === 'undefined') {
element = $('.' + arr[i] + ', .' + LANG.prefix + arr[i]);
} else {
element = $(iframe).contents().find('.' + arr[i] + ', .' + LANG.prefix + arr[i]);
}
$(element).html(val);
element.each(function() {
val = typeof LANG.lang[arr[i]] !== 'undefined' ? LANG.lang[arr[i]] : '' + arr[i] + '';
$.each(this.attributes, function() {
if (this.specified) {
var attrVal = decodeURIComponent(this.value);
attrVal = attrVal.replace(/\+/g, ' ');
val = val.replace('{' + this.name + '}', attrVal);
}
});
$(this).html(val);
});
}
}
};
function getLanguage() {
var allowedLang = ['tr', 'en', 'az', 'ru', 'de', 'bs', 'ar', 'el', 'fa'];
var lang = 'tr';
if (typeof window.LANGUAGE === 'string' && allowedLang.indexOf(window.LANGUAGE) > 0) {
lang = window.LANGUAGE;
} else {
$.ajax({
url: '/conn/user/language/getLanguage',
async: false,
success: function(msg) {
msg = msg.replace(/\W/ig, '');
if (msg.length > 1 || msg.length < 4) {
lang = msg;
}
}
});
if (allowedLang.indexOf(lang) < 0) {
lang = 'tr';
}
}
return lang;
}
function check_fb_tw_login() {
if (window.location.href.indexOf('hata=mail_adresi_alinamadi') > 0) {
LANG.selected_lang = getLanguage();
LANG.load('Web/social.js', function() {
var type = window.location.href.indexOf('type=tw') > 0 ? 'twitter' : 'facebook';
var html = '';
TSOFT.showDialog(LANG.get('dialog_' + type), html, 400);
TSOFT.addButton(LANG.get('submit_button'), function() {
setCookie('fb_tw_mail', $('#fb_tw_mail').val(), 1);
window.location.href = '/memberConnector/' + type + '/login_' + type + '.php?mail=' + $('#fb_tw_mail').val();
});
});
}
}
function Upload(options) {
Upload.counter = Upload.counter || 0;
Upload.counter++;
var opt = {
instance: 'myUpload',
url: '', //post edilecek url
postParams: {}, //post edilecek parametreler
buttons: {
select: { text: 'Resim Seç', cls: 'selectButton', id: 'selectButton_' + Upload.counter },
upload: { text: 'Yükle', cls: 'uploadButton', id: 'uploadButton_' + Upload.counter }
},
uploadButtonActive: false,
progressWrapper: '.progressWrapper', //selector (Resimler seçildiğinde, resimlerin gözükeceği div)
progress: function(event, __this) {
var parent = $(__this).parents('li:first');
var percent = (event.loaded / event.total) * 100;
var total = '' + event.total + '';
total = total.length > 6 ?
total.replace(/(\w+)(\w{3})(\w{3})/ig, '$1.$2.$3') :
total.replace(/(\w+)(\w{3})/ig, '$1.$2');
parent.find('.progressBar2').css('width', Math.round(percent) + '%');
parent.find('.progressInfo').html('%' + Math.round(percent) + ' (' + total + ' byte)');
},
load: function(response) {
},
error: function() {},
abort: function() {},
callback: function(msg) {
}
};
Upload.instance = Upload.instance | {};
Upload.instance.activeUpload = this;
Upload.instance[opt.instance] = this;
this.get = function(key) {
return opt[key];
};
this.set = function(key, val) {
opt[key] = val;
return true;
};
function _get(key, obj, _default) {
return typeof obj[key] !== 'undefined' ? obj[key] : _default;
}
for (var i in options) {
opt[i] = options[i];
}
Upload.handleFiles = function(__this) {
var files = __this.files;
var parent = $(__this).parents('li:first');
if (!files.length) {
$(opt.progressWrapper).find('.imageList').html('Resim Seçilmedi !!!');
} else {
parent.find('.imageList').html('');
for (var i = 0; i < files.length; i++) {
var img = document.createElement("img");
img.src = window.URL.createObjectURL(files[i]);
img.height = 60;
img.onload = function(e) {
window.URL.revokeObjectURL(this.src);
};
parent.find('.imageList').append('');
parent.find('.imageList .imageArea:last div').append(img);
}
parent.find('.progressBar,.progressBar2').height(parent.find('.imageList').height());
if (opt.uploadButtonActive === false) {
var progressCount = parent.find('.progressInfo').text().replace('%', '').trim();
if (parseInt(progressCount) === 100) {
TSOFT.showDialog(LANG.get('error_dialog_header'), LANG.get('error_upload_again'), 300);
TSOFT.addButton(LANG.get('close'), function() {});
} else {
doUpload(files, __this);
}
}
}
};
function doUpload(files, __this) {
var formdata = new FormData();
// var files = files;
//var select = '#' + opt.buttons.upload.id;
//var element = document.getElementById(opt.buttons.upload.id);
for (var i = 0; i < files.length; i++) {
var file = files[i];
formdata.append("file" + i, file);
}
for (var key in opt.postParams) {
formdata.append(key, opt.postParams[key]);
}
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", function(event) {
opt.progress(event, __this);
});
ajax.addEventListener("load", function() {
opt.load(this.responseText);
opt.callback(this.responseText, __this);
});
ajax.addEventListener("error", opt.error);
ajax.addEventListener("abort", opt.abort);
ajax.open("POST", opt.url);
ajax.send(formdata);
}
this.getCreatedHtml = function() {
var html = '';
return html;
//$(opt.buttons.select.selector).attr('onclick', 'handleFiles()');
};
}
function PersonalizationForm(options) {
var str = '';
var opt = {
url: '/conn/product/Personalization/getPersonalizationForm/',
selector: '#product-personalization',
data: [],
form_id: 0, //
product_id: 0,
cart_id: -1,
sub_product_id: 0,
myForm: [],
moneyOrderDiscountPercent: 0,
instance: 'productDetail'
};
this.get = function(key) {
return opt[key];
};
this.set = function(key, value) {
opt[key] = value;
};
var _this = this;
for (var i in options) {
opt[i] = options[i];
}
PersonalizationForm.data = PersonalizationForm.data || opt.data;
PersonalizationForm.instance = PersonalizationForm.instance || {};
PersonalizationForm.instance['activeForm'] = this;
// if (typeof PersonalizationForm.instance[opt.instance] === 'object') {
// console.error('Personalization Error: Same instance "' + opt.instance + '"');
// }
PersonalizationForm.instance[opt.instance] = this;
this.validate = function() {
if ($('.CustomForm').length === 0) {
return true;
}
var r = true;
function showValidationError(_this, type, param) {
r = false;
var txt = LANG.get('error_' + type);
$(_this).parent().parent().append('' + txt.replace('{' + type + '}', param) + '');
$(_this).addClass('error');
}
$(opt.selector).find('.personalizationFormElement').removeClass('error');
$(opt.selector).find('.CustomForm span.error').remove();
var values = [];
var sayac = 0;
var myForm = [];
$(opt.selector).find('.personalizationFormElement').each(function() {
var val = $(this).val();
var cls = $(this).attr('class') || '';
myForm[sayac] = {
baslik: typeof opt.data[sayac] !== 'undefined' ? opt.data[sayac].baslik : '*',
value: $(this).val()
};
if ($(this).attr('disabled') === 'disabled') {
myForm[sayac]['active'] = 0;
} else {
if (typeof $(this).attr('data-required') !== 'undefined') {
if ($(this).is('input[type="checkbox"]')) {
if (!$(this).is(':checked')) {
showValidationError(this, 'required', '');
return false;
}
} else if ($(this).val() === '') {
showValidationError(this, 'required', '');
return false;
}
}
if ($(this).is('input') || $(this).is('textarea')) {
if ($(this).attr('type') == 'checkbox') {
myForm[sayac].value = $(this).is(':checked') ? 1 : 0;
}
var minsize = parseInt($(this).attr('data-minsize'));
var maxsize = parseInt($(this).attr('data-maxsize'));
if (minsize > 0 && val.length < minsize) {
showValidationError(this, 'minsize', minsize);
return false;
} else if (maxsize > 0 && val.length > maxsize) {
showValidationError(this, 'maxsize', maxsize);
return false;
} else if (typeof $(this).attr('data-regex') !== 'undefined') {
var rgx = new RegExp($(this).attr('data-regex'), "ig");
if (rgx.test(val) === false) {
showValidationError(this, 'regex', '');
return false;
}
}
}
myForm[sayac]['active'] = 1;
}
sayac++;
});
_this.set('myForm', myForm);
return r;
};
this.saveForm = function(callbackFunc) {
var form_id = _this.get('form_id');
var product_id = _this.get('product_id');
if (product_id < 1 || form_id < 0) {
return false;
}
var data = _this.get('data');
var myForm = _this.get('myForm');
var sub_product_id = _this.get('sub_product_id');
$.ajax({
url: '/conn/product/Personalization/saveForm/' + _this.get('cart_id'),
type: 'post',
async: false,
data: { form_id: form_id, data: JSON.stringify(myForm), product_id: product_id, sub_product_id: sub_product_id },
success: function(msg) {
if (typeof callbackFunc === 'function') {
callbackFunc(msg);
}
}
});
};
function _get(key, obj, _default) {
return obj[key] === 'undefined' ? _default : obj[key];
}
function getElement(tip, name, varsayilan, zorunlu, min, max, regex, secenek, label) {
//validate[required,minSize[3]]
var attr = [];
if (zorunlu === '1')
attr.push('data-required="1"');
if (varsayilan !== '')
attr.push('data-default="' + encodeURI(varsayilan) + '"');
attr.push('class="personalizationFormElement"');
if (min > 0)
attr.push('data-minsize="' + min + '"');
if (max > 0)
attr.push('data-maxsize="' + max + '"');
if (regex.length > 0)
attr.push('data-regex="' + regex.replace(/"/ig, '\\"') + '"');
if (tip.indexOf('input') > -1) {
return '<' + tip + ' name="' + name + '" ' + attr.join(' ') + ' />'
} else if (tip.indexOf('select') > -1) {
secenekler += '';
for (var m = 0; m < secenek.length; m++) {
secenekler += '';
}
return '<' + tip + ' name="' + name + '" ' + attr.join(' ') + ' >' + secenekler + '' + tip + '>'
} else if (tip.indexOf('imagebox') > -1) {
var secenekler = '';
for (var m = 0; m < secenek.length; m++) {
secenekler += ' ' + secenek[m].secenek + '';
}
return '';
} else if (tip.indexOf('textarea') > -1) {
return '<' + tip + ' name="' + name + '" ' + attr.join(' ') + ' >' + tip + '>';
} else if (tip.indexOf('image_upload') > -1) {
var up = new Upload({
url: '/conn/product/Personalization/sendImage',
postParams: {
url: document.URL
},
callback: function(response, __this) {
var parent = $(__this).parents('li:first');
var arr = { status: 0, statusText: '1----' };
try {
arr = JSON.parse(response);
} catch (ex) {
arr = { status: 0, statusText: '2----' };
}
if (parseInt(arr.status) === 1) {
parent.find('.personalizationFormElement').val(1);
} else {
TSOFT.showDialog(LANG.get('error_dialog_header'), LANG.get('error_upload' + arr.status), 300);
TSOFT.addButton(LANG.get('close'), function() {});
parent.find('.progressInfo').text('%0');
parent.find('.progressBar2').width(0);
}
}
});
return '' + up.getCreatedHtml();
}
return tip;
}
this.createForm = function(data) {
$(_this.get('selector')).css({ overflow: 'visible', clear: 'both' });
$(_this.get('selector')).after('');
PersonalizationForm.data = data;
var selectedLang = getLanguage(); //PersonalizationForm.getSelectedLang();
LANG.selected_lang = selectedLang;
//LANG.load('Product/PersonalizationSite.js');
$(opt.selector).html('');
for (var i = 0; i < data.length; i++) {
var label = _get('baslik', data[i], '"');
var fiyat = parseInt(_get('fiyat', data[i], 0));
var fiyatAciklama = _get('fiyatAciklama', data[i], '');
var secenekler = _get('secenekler', data[i], []);
var name = 'element_' + i; //_get('name', data[i], 'no_name');
var tip = _get('tip', data[i], 'input');
var zorunlu = _get('zorunlu', data[i], 0);
var varsayilan = _get('varsayilan', data[i], '');
var min = _get('min', data[i], 0);
var max = _get('max', data[i], 0);
var regex = _get('regex', data[i], '');
var lang = _get('lang', data[i], []);
var noteArr = [];
if (fiyat > 0 && parseInt(zorunlu) === 0) {
//noteArr.push('');
}
if (zorunlu === '1')
noteArr.push('*');
// if (min > 0)
// noteArr.push('Min (' + min + ')');
// if (max > 0)
// noteArr.push('Max (' + max + ')');
var li = '';
var element = getElement(tip, name, varsayilan, zorunlu, min, max, regex, secenekler, label);
if (tip.indexOf('checkbox') > 0) {
li = '' + element + '' + label + '' + noteArr.join('-') + '';
} else {
li = '' + element + '' + noteArr.join('-') + '';
}
if (fiyatAciklama.length > 2) {
li += '(' + fiyatAciklama + ')';
}
for (var m = 0; m < lang.length; m++) {
var rgx = new RegExp("\{#" + lang[m].key + "#\}", "ig");
li = li.replace(rgx, lang[m][selectedLang]);
}
$(opt.selector).find('.CustomForm ul:first').append(li);
}
};
function processForm(data) {
_this.set('data', data);
_this.set('moneyOrderDiscountPercent', data.moneyOrderDiscountPercent || 0);
//_this.set('myForm', data)
_this.createForm(data);
setPersonalizationEvents();
}
function setPersonalizationEvents() {
$(opt.selector).find('input.fieldActive').change(function() {
if ($(this).is(':checked')) {
$(this).parents('li').find('.personalizationFormElement').removeAttr('disabled');
} else {
$(this).parents('li').find('.personalizationFormElement').val('');
$(this).parents('li').find('.personalizationFormElement').attr('disabled', 'disabled');
}
});
$(opt.selector).find('input.fieldActive').trigger('change');
$(opt.selector).find('.personalizationFormElement').keyup(function() {
var maxLen = parseInt($(this).attr('data-maxsize'));
if (maxLen > 0) {
$(this).parents('li').find('span.note u').remove();
var len = maxLen - $(this).val().length;
$(this).parents('li').find('span.note').append('' + len + '');
}
});
$(opt.selector).find('.personalizationFormElement').trigger('keyup');
$(opt.selector).find('.tsoftCombo li').click(function() {
var content = $(this).html();
$(this).parents('.comboWrapper').find('div.selected').html(content);
$(opt.selector).find('.tsoftCombo').hide();
$(this).parents('.comboWrapper').find('input').val($(this).text().trim());
});
$(opt.selector).find('.comboWrapper div.selected').click(function() {
$(this).parents('.comboWrapper').find('.tsoftCombo').toggle();
});
$(opt.selector).find('.tsoftCombo').toggle();
var data = _this.get('data');
var myForm = _this.get('myForm'); //güncellemede
for (var i = 0; i < data.length; i++) {
var element = $(opt.selector).find('.personalizationFormElement').eq(i);
if (element.length > 0) {
if (typeof element.attr('data-default') !== 'undefined') {
if (data[i].tip === 'imagebox') {
element.parents('li:first').find('.comboLabel').each(function() {
if ($(this).text().trim() === element.attr('data-default').trim()) {
$(this).parents('li:first').trigger('click');
}
});
} else {
element.val(decodeURI(element.attr('data-default')));
}
}
if (typeof myForm[i] !== 'undefined') { //Güncelleme ise
element.val(myForm[i]['value']);
if (data[i].tip === 'image_upload') {
element.parents('li:first').find('.progressInfo').text('%100');
element.parents('li:first').find('.progressBar2').css('width', '100%');
} else if (data[i].tip === 'imagebox') {
element.parents('li:first').find('ul li').each(function() {
if (myForm[i]['value'].trim() === $(this).find('.comboLabel').html().trim()) {
$(this).trigger('click');
}
});
} else if (data[i].tip.indexOf('checkbox') > -1) {
element.val(1);
if (myForm[i]['value'] === 1) {
element.attr('checked', 'checked');
}
}
}
// element.val(myForm[i]['value']);
// if (myForm[i]['value'].length > 0) {
// element.parents('li').find('.fieldActive').attr('checked', 'checked');
// element.parents('li').find('.fieldActive').trigger('change');
// }
}
}
}
if (opt.data.length > 0) {
if (typeof opt.data !== 'object') {
// cLog('PersonalizationForm Error: InCorrect Data');
}
processForm(opt.data);
} else if (opt.data.length === 0) {
$.ajax({
url: opt.url + "" + opt.form_id,
dataType: 'json',
success: function(data) {
if (typeof data !== 'object') {
// cLog('PersonalizationForm Error: InCorrect Data');
} else {
processForm(data);
}
}
});
} else {
// cLog('no parameter set');
}
}
$(document).ready(function() {
if (typeof Cart === 'object' && typeof Cart.showHeaderCart !== 'undefined') {
Cart.showHeaderCart();
}
if (typeof $.fn.live !== 'undefined') {
$(".Tbox").live("click", function(e) {
e.preventDefault();
var title = ($(this).attr("title") === undefined) ? "Sayfa" : $(this).attr("title");
var link = $(this).attr("href");
var width = ($(this).attr("w") === undefined) ? 300 : parseInt($(this).attr("w"));
if (link === undefined)
return false;
var callback = function() {};
var ccc = $(this).attr("callback");
if (ccc !== undefined) {
callback = function() {
eval(ccc);
};
}
TSOFT.showUrl(link, title, width, callback);
});
}
check_fb_tw_login();
var alert_old = window.alert;
// Alertlerdeki kapat butonu istenildiğinde dile bağlanabilir..
if (typeof mobile == "undefined") {
window.alert = function(str, btnText) {
if (typeof btnText === "undefined") {
btnText = 'Kapat';
}
var count = Object.keys(Message.instance).length + 1;
var _setting = {
id: 'myDialog_' + count,
title: 'Dikkat',
html: str,
width: 350,
height: 'auto',
buttons: [{
text: btnText,
fn: function() {
// cLog('kapat');
}
}]
};
var _instance = new Message(_setting);
_instance.show();
// TSOFT.showDialog('Dikkat', str, 350);
// TSOFT.addButton('Tamam', function () {
// });
return true;
};
}
if (window.location.href.indexOf('?activation=') > 0) {
var activationType = window.location.href.replace(/^.*?activation=(\w+).*?$/ig, '$1');
switch (activationType) {
case 'facebook':
$.get('/srv/service/content/get/1008/facebook-email', function(content) {
Message.showDialog("Dikkat", content, 400);
});
break;
}
}
});
var ApprovePageTracking = {
callbackArray: []
};
var referererStorage = {
hasLocal: 'localStorage' in window && window['localStorage'] !== null,
addItem: function() {
if (this.hasLocal) {
this.addItemStorage();
} else {
this.addItemCookie();
}
},
hasQueryString: function() {
var ref = document.referrer || "";
if (ref == '') {
return false;
}
var a = document.createElement("a");
a.href = ref;
var q = '';
var queryString = a.search;
var pairs = (queryString[0] === '?' ? queryString.substr(1) : queryString).split('&');
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
if (pair[0] == 'q') {
q = pair[1];
}
}
return q != '';
},
addItemStorage: function() {
var cReferrer = localStorage.getItem("cReferrer");
var items = [];
if (cReferrer !== null) {
try {
var obj = JSON.parse(cReferrer);
} catch (err) {
var obj = {};
}
if (typeof obj.schedule != "undefined" && Date.now() < obj.schedule && !this.hasQueryString()) {
return;
}
items = obj.items || [];
}
items.push({ time: parseInt(Date.now() / 1000), uri: document.referrer, page: window.location.href });
this.setItems(items);
},
addItemCookie: function() {
try {
var cReferrer = $.cookie("cReferrer");
} catch (err) {
return;
}
var items = [];
if (cReferrer !== null) {
try {
var obj = JSON.parse(cReferrer);
} catch (err) {
var obj = {};
}
if (typeof obj.schedule != "undefined" && Date.now() < obj.schedule && !this.hasQueryString()) {
return;
}
items = obj.items || [];
}
items.push({ time: parseInt(Date.now() / 1000), uri: document.referrer });
this.setItems(items);
},
getObj: function() {
var cReferrer = null;
var cReferrerObj = {};
if (this.hasLocal) {
cReferrer = localStorage.getItem("cReferrer");
} else {
try {
cReferrer = $.cookie("cReferrer");
} catch (err) {}
}
try {
cReferrerObj = JSON.parse(cReferrer);
} catch (err) {}
return cReferrerObj;
},
getItems: function() {
return this.getObj().items || [];
},
setItems: function(items) {
var obj = {
schedule: Date.now() + (24 * 60 * 60 * 1000),
items: items || []
};
this.save(obj);
},
save: function(sObj) {
if (this.hasLocal) {
this.saveStorage(sObj);
} else {
this.saveCookie(sObj);
}
},
saveStorage: function(sObj) {
localStorage.setItem("cReferrer", JSON.stringify(sObj));
},
saveCookie: function(sObj) {
try {
$.cookie("cReferrer", JSON.stringify(sObj), { path: '/', expires: 30 });
} catch (err) {}
}
};
// Çerez Kullanım Uyarısı
var CookieBar = {
isActive: false,
cookie: 'CookieLaw',
titleDom: '.cookieLawTitle',
bodyDom: '.cookieLawBody',
load: function(cb) {
CookieBar.isActive = $("#cookie-law").val() === "1" || false;
if (CookieBar.isActive === true && CookieBar.getCookie() !== "1") {
CookieBar.getContent(function(r) {
if (typeof cb === 'function') {
cb(r);
}
});
}
},
setCookie: function(state) {
setCookie(CookieBar.cookie, state, 15);
},
getCookie: function() {
return getCookie(CookieBar.cookie);
},
getContent: function(cb) {
var tmp;
$.ajax({
type: 'GET',
url: '/srv/service/site/get-cookie-law',
data: {},
success: function(r) {
try {
tmp = JSON.parse(r);
$(CookieBar.titleDom).html(tmp.Title);
$(CookieBar.bodyDom).html(tmp.Content);
CookieBar.setCookie(1);
if (typeof cb === 'function') {
cb(tmp);
return false;
}
} catch (e) {
console.log(e);
return false;
}
},
});
}
};
$(document).ready(function() {
CookieBar.load(function(r) {
// load yukarda cookiebar a dom class verilirse dolduruyor
console.log(r);
});
referererStorage.addItem();
});