function uploadImages($id, $type) { $('#UploadImages'+$id).uberuploadcropper({ //--------------------------------------------------- // uploadify options.. //--------------------------------------------------- 'debug' : true, 'action' : base_url+'common/uploadAvatar', 'params' : {}, 'allowedExtensions': ['jpg','jpeg','png','gif'], 'multiple': false, //'sizeLimit' : 0, 'multi' : false, //--------------------------------------------------- //now the cropper options.. //--------------------------------------------------- 'aspectRatio': 1, 'allowSelect': false, //can reselect 'allowResize' : true, //can resize selection 'setSelect': [ 0, 0, 200, 200 ], //these are the dimensions of the crop box x1,y1,x2,y2 'minSize': [ 175, 175 ], //if you want to be able to resize, use these 'maxSize': [ 1000, 1000 ], 'aspectRatio': 1, //--------------------------------------------------- //now the uber options.. //--------------------------------------------------- 'folder': base_url+'uploads/', // only used in uber, not passed to server 'cropAction': base_url+'common/cropAvatar', // server side request to crop image 'onComplete': function(imgs,data){ var $PhotoPrevs = $('#PhotoPrevs'+$id); $(".avatarImage"+$id).remove(); for(var i=0,l=imgs.length; i"); $("#avatars").append(""); $PhotoPrevs.html(' Odstrani to sliko'); } } }); } function copierLicence(numero){ $("#licenca"+numero+"").live('keyup', function() { $("#licence"+numero+"").val($(this).val()); }) } function copierLicence2(numero){ $("#licenca2"+numero+"").live('keyup', function() { $("#licence2"+numero+"").val($(this).val()); }) } function childCopyForm(numero){ $("#"+numero+"-child_country").val($("#ccountry"+numero+"").val()); //test $("#cname"+numero+"").live('keyup', function() { //gender update $("#"+numero+"-child_gender").val($("#cgender"+numero+"").val()); $("#"+numero+"-child_country").val($("#ccountry"+numero+"").val()); $("#"+numero+"-child_address").val($("#caddress"+numero+"").val()); $("#"+numero+"-child_city").val($("#ccity"+numero+"").val()); $("#"+numero+"-child_zip").val($("#czip"+numero+"").val()); $("#"+numero+"-child_email").val($("#cemail"+numero+"").val()); $("#"+numero+"-child_phone").val($("#cphone"+numero+"").val()); $("#"+numero+"-child_day").val($("#cday"+numero+"").val()); $("#"+numero+"-child_month").val($("#cmonth"+numero+"").val()); $("#"+numero+"-child_year").val($("#cyear"+numero+"").val()); }); $("#cname"+numero+"").live('keyup', function() { $("#"+numero+"-child_name").val($(this).val()); }) $("#csurname"+numero+"").live('keyup', function() { $("#"+numero+"-child_surname").val($(this).val()); }) $("#cgender"+numero+"").live('change', function() { $("#"+numero+"-child_gender").val($(this).val()); }) $("#ccountry"+numero+"").live('change', function() { $("#"+numero+"-child_country").val($(this).val()); }) $("#cday"+numero+"").live('change', function() { $("#"+numero+"-child_day").val($(this).val()); }) $("#cmonth"+numero+"").live('change', function() { $("#"+numero+"-child_month").val($(this).val()); }) $("#cyear"+numero+"").live('change', function() { $("#"+numero+"-child_year").val($(this).val()); }) $("#caddress"+numero+"").live('keyup', function() { $("#"+numero+"-child_address").val($(this).val()); }) $("#ccity"+numero+"").live('keyup', function() { $("#"+numero+"-child_city").val($(this).val()); }) $("#czip"+numero+"").live('keyup', function() { $("#"+numero+"-child_zip").val($(this).val()); }) $("#cemail"+numero+"").live('keyup', function() { $("#"+numero+"-child_email").val($(this).val()); }) $("#cphone"+numero+"").live('keyup', function() { $("#"+numero+"-child_phone").val($(this).val()); }) } function createDisciplineModal(ider, numero) { var appender = '
'; appender += '
'; appender += '
'; appender += ''; appender += ''; //appender += ''; //appender += ''; appender += '
'; appender += '
'; appender += '
'; $("#modalHolder").append(appender); $('.dialog-'+numero).dialog({ autoOpen: false, height: 'auto', width: 425, modal: true, closeText: 'Zapri', cancelText: 'Prekliči', buttons: { "Shrani": function() { $( this ).dialog( "close" ); var value = $("#disciplina-input"+numero+" option:selected").val(); var text = $("#disciplina-input"+numero+" option:selected").text(); $("[discip='"+numero+"']").fadeOut('slow', function() { $(this).html(text).fadeIn('slow'); }) $("#disciplina-title"+numero).val(text); $("#disciplina-id"+numero).val(value); }, "Prekliči": function() { $( this ).dialog( "close" ); } }, close: function() { } }); var select = $("#disciplina-input"+numero); $.ajax({ type: "GET", data: "type=html&term=", dataType: "html", url: base_url+"common/disciplineSearch", success: function(data){ select.append(data); } }); completeDiscipline("#disciplina-inputbox"+numero, numero, select); } function updateDiscipline(numero, value) { $.ajax({ type: "GET", data: "number="+numero, dataType: "html", url: base_url+"register/getDisciplines", success: function(data){ $(data).replaceAll('#disciplina'+numero); $('#disciplina'+numero).live('change', function() { $("#disciplina-id"+numero).val($(this).val()); updateCategory(numero, $(this).val()); }); if(typeof(value)!=='undefined') { $('#disciplina'+numero).val(value); $('#disciplina'+numero).change(); } } }); } function updateCategory(numero, disciplineid) { $.ajax({ type: "GET", data: "number="+numero+"&discipline="+disciplineid, dataType: "html", url: base_url+"register/getCategories", success: function(data){ $(data).replaceAll('#category'+numero); $('#category'+numero).live('change', function() { $("#category"+numero+"category").val($(this).val()); }); } }); } function completeDiscipline(selector, numero) { var select = $("#select_disciplines"); $( selector ).autocomplete({ delay: 0, minLength: 0, source: function( request, response ) { var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); response( select.children( "option" ).map(function() { var text = $( this ).text(); var val = $( this ).val(); if ( this.value && ( !request.term || matcher.test(text) ) ) return { label: text.replace( new RegExp( "(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(request.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi" ), "$1" ), value: text, dataval: val, option: this }; }) ); }, select: function( event, ui ) { ui.item.option.selected = true; $(selector).val(ui.item.label); $("#disciplina-id"+numero).val(ui.item.dataval); updateCategory(numero, ui.item.dataval); }, change: function( event, ui ) { if ( !ui.item ) { var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ), valid = false; select.children( "option" ).each(function() { if ( $( this ).text().match( matcher ) ) { valid = true; return false; } }); if ( !valid ) { // remove invalid value, as it didn't match anything $( this ).val( "" ); //select.val( "" ); //input.data( "autocomplete" ).term = ""; return false; } } } }) .data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; } function completeClub(selector) { /*var __response = $.ui.autocomplete.prototype._response; $.ui.autocomplete.prototype._response = function(content) { __response.apply(this, [content]); if(content.length == 0) { var data = [ {label: 'Ni rezultatov!', value: '0'} ]; __response.apply(this, [data]); } else { __response.apply(this, [content]); } };*/ $( selector ).autocomplete({ source: base_url+"common/clubsSearch", minLength: 2, focus: function( event, ui ) { $(selector).val( ui.item.label ); return false; }, select: function( event, ui ) { if(ui.item.label == "Ni rezultatov!") { return false; } $(selector).val(ui.item.label); $(selector+"club").val(ui.item.id); return false; } }) .data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; } function completeCategory(selector) { /*var __response = $.ui.autocomplete.prototype._response; $.ui.autocomplete.prototype._response = function(content) { __response.apply(this, [content]); if(content.length == 0) { var data = [ {label: 'Ni rezultatov!', value: '0'} ]; __response.apply(this, [data]); } else { __response.apply(this, [content]); } };*/ $( selector ).autocomplete({ source: base_url+"common/categorySearch", minLength: 2, focus: function( event, ui ) { $(selector).val( ui.item.label ); return false; }, select: function( event, ui ) { if(ui.item.label == "Ni rezultatov!") { return false; } $(selector).val(ui.item.label); $(selector+"category").val(ui.item.id); return false; } }) .data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data( "item.autocomplete", item ) .append( "" + item.label + "" ) .appendTo( ul ); }; } $(document).ready(function(){ $('.helper').CreateBubblePopup({ position : 'top', align : 'center', innerHtml: $(this).attr('help'), innerHtmlStyle: { color:'#FFFFFF', 'text-align':'center' }, themeName: 'all-azure', themePath: base_url+'assets/img' }); $('.helper').live('mouseover', function(event) { var text = $(this).attr('help'); $(this).ShowBubblePopup({ position : 'top', align : 'center', innerHtml: text, innerHtmlStyle: { color:'#FFFFFF', 'text-align':'center' }, themeName: 'all-azure', themePath: base_url+'assets/img' }); }); uploadImages(0, "main"); //updateDiscipline(6666); $("#register-form").validate({ rules: { user_name: { required: true }, user_surname: { required: true }, user_surname: { required: true }, user_password: "required", user_password_again: { equalTo: "#user_password" }, day: { required: true }, month: { required: true }, year: { required: true }, user_gender: { required: true }, user_city: { required: true }, user_address: { required: true }, user_zip: { required: true }, user_country: { required: true }, user_email: { required: true, email: true, remote: { url: base_url+"register/email_exists", type: "post" } }, disciplina: { required: true }, kategorija: { required: true } }, messages: { email: { email: 'Prosimo vpišite veljaven E-mail!', remote: 'Ta E-mail naslov je že v uporabi!' } } }); $(".removeAvatar").live("click", function(e) { id = $(this).attr("rid"); $(this).fadeOut('slow'); $("#avatarImage"+id).fadeOut('slow', function() { $(this).remove() $(".avatarImage"+id).remove(); }) e.preventDefault(); }) $("#register-form").submit(function(e) { // če je katerakoli disciplina prazna: // če je katerakoli kategorija prazna: var v = true; $("[id^=disciplina]").each(function() { if ($(this)[0].type != "select") return; if ($(this).find('option:selected').length == 0 || $(this).find('option:selected').val().length == 0) { //noty({text: 'Nastavi panogo!', type: "error"}); v = false; return false; } }); if ($(this).valid() == true && v == true){ this.submit(); } else { if ($(this).valid() == true) noty({text: 'Vnesite vsaj eno panogo!!', type: "error"}); else noty({text: 'Izpolnite vsa polja!!', type: "error"}); return false; } }); /*if (!Modernizr.inputtypes.date) { $('.user_birthdate').datepicker({ dateFormat: "yy-mm-dd", changeYear: true, yearRange: '1900:2012', showAnim: 'drop' }); delete $.validator.methods.date; }else{ $('.user_birthdate').keypress(function(){ event.preventDefault(); }); }*/ var numero = 2395; $("#add-discipline").live('click', function(e) { var diver = $(this).attr("addDiv"); var type = $(this).attr("type"); //if(type == "child") { numero = $(this).attr("numero") } var discipline_holder = '
    '; //var discipline = '

    Nastavi najmanj eno panogo

    '; var discipline = ''; var loyal = ''; // loyal += ''; loyal += ''; loyal += ''; loyal += ''; loyal += ''; loyal += ''; discipline += '
    '; discipline += ''; discipline += ''; discipline += ''; discipline += ''; discipline += ''; discipline += 'X'; discipline += '
    '; discipline_holder += '
    '; $("#discipline_holder"+diver).append(discipline_holder); $("#"+numero).hide().append(discipline).fadeIn(900); $("#loyalties").append(loyal); $(".remove-discipline").button(); //completeDiscipline("#disciplina"+numero, numero); updateDiscipline(numero); completeClub("#klub"+numero, numero); //completeCategory("#category"+numero, numero); copierLicence(numero); copierLicence2(numero); numero = numero + 1; e.preventDefault(); }) $(".editable").live('click', function(e){ var numero = $(this).attr('discip'); $('.dialog-'+numero).dialog( "open" ); e.preventDefault(); }) $(".remove-discipline").live('click', function(e) { var numerodel = $(this).attr('rel'); var type = $(this).attr('type'); $("#"+numerodel).slideToggle('1500', function() { $(this).remove(); }) $(".dialog-"+numerodel).remove(); $("#disciplina-"+numerodel).remove(); $("#klub-"+numerodel).remove(); $("#kateg-"+numerodel).remove(); $("#licence-"+numerodel).remove(); $("#licence2-"+numerodel).remove(); $("#disciplina-title"+numerodel).remove(); $("#disciplina-id"+numerodel).remove(); $("#klub"+numerodel+"club").remove(); $("#category"+numerodel+"category").remove(); $("#licence"+numerodel).remove(); $("#licence2"+numerodel).remove(); if(type == "save") { $("#loyal"+type+"-"+numerodel).attr("name", "loyaldelete[]"); } else { $("#loyal"+type+"-"+numerodel).remove(); } e.preventDefault(); }); $("#remove-child").live('click', function(e) { $('html, body').animate({ scrollTop: $('#mainPerson').offset().top }, 'slow'); var numerodel = $(this).attr('child'); $("#child"+numerodel).fadeOut('1000', function() { $(this).remove(); }) $(".childInput"+numerodel).remove(); e.preventDefault(); }); $("#add-child").live('click', function(e) { //var number = Math.floor(Math.random()*5555); while($("#"+numero).length != 0) numero++; $.ajax({ type: "GET", data: "number="+numero, dataType: "html", url: base_url+"register/addChildCopy", success: function(data){ $("#childers").append(data); childCopyForm(numero); } }); $.ajax({ type: "GET", data: "number="+numero, dataType: "html", url: base_url+"register/addChild", success: function(data){ $("#childs").append(data); $('html, body').animate({ scrollTop: $('#child'+numero).offset().top }, 'slow'); uploadImages(numero, "child") /*if (!Modernizr.inputtypes.date) { delete $.validator.methods.date; $.each($('.user_birthdate'), function() { var $dater = $(this).attr("field"); $(this).datepicker("destroy").datepicker({ dateFormat: "yy-mm-dd", changeYear: true, yearRange: '1940:2012', showAnim: 'drop', onSelect: function(dateText, inst) { $($dater).val(dateText); } }); }) }else{ $('.user_birthdate').keypress(function(){ event.preventDefault(); }); }*/ $("#caddress"+numero).val($("#address").val()); $("#ccity"+numero).val($("#city").val()); $("#czip"+numero).val($("#zip").val()); $("#ccountry"+numero).val($("#country").val()); $("#cemail"+numero).val($("#email").val()); $("#cphone"+numero).val($("#phone").val()) } }); $(".register-next").live('click', function() { $('#register-form').submit(); }) ; e.preventDefault(); }) jQuery.extend(jQuery.validator.messages, { required: "To polje je obvezno.", remote: "Vpis v tem polju v bazi že obstaja.", email: "Prosimo, vnesite pravi email naslov.", url: "Prosimo, vnesite pravi URL.", date: "Prosimo, vnesite pravi datum.", dateISO: "Prosimo, vnesite pravi datum (ISO).", number: "Prosimo, vnesite pravo številko.", digits: "Prosimo, vnesite samo številke.", creditcard: "Prosimo, vnesite pravo številko kreditne kartice.", equalTo: "Prosimo, ponovno vnesite enako vsebino.", accept: "Prosimo, vnesite vsebino s pravo končnico.", maxlength: $.validator.format("Prosimo, da ne vnašate več kot {0} znakov."), minlength: $.validator.format("Prosimo, vnesite vsaj {0} znakov."), rangelength: $.validator.format("Prosimo, vnesite od {0} do {1} znakov."), range: $.validator.format("Prosimo, vnesite vrednost med {0} in {1}."), max: $.validator.format("Prosimo, vnesite vrednost manjšo ali enako {0}."), min: $.validator.format("Prosimo, vnesite vrednost večjo ali enako {0}.") }); jQuery(function($){ $.datepicker.regional['sl'] = {clearText: 'Očiten', clearStatus:'', closeText: 'Zapri', closeStatus: '', prevText: '«Prejšnji', prevStatus: '', nextText: 'Naslednji»', nextStatus: '', currentText: 'Danes', currentStatus: '', monthNames:['Januar','Februar','Marec','April','Maj','Junij','Julij','Avgust','September','Oktober','November','December'], monthNamesShort: ['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Avg','Sep','Okt','Nov','Dec'], monthStatus: '', yearStatus: '', weekHeader: 'Ve', weekStatus: '', dayNamesShort: ['Ned','Pon','Tor','Sre','Čet','Pet','Sob'], dayNames:['Nedelja','Ponedeljek','Torek','Sreda','Četrtek','Petek','Sobota'], dayNamesMin: ['Ne','Po','To','Sr','Če','Pe','So'], dayStatus: 'DD', dateStatus: 'D, M d', dateFormat: 'yy-mm-dd', firstDay: 1, initStatus: '', isRTL: false}; $.datepicker.setDefaults($.datepicker.regional['sl']); }); });