(function () { 'use strict'; var devtools = { open: false, orientation: null }; var threshold = 160; var emitEvent = function (state, orientation) { window.dispatchEvent(new CustomEvent('devtoolschange', { detail: { open: state, orientation: orientation } })); }; setInterval(function () { var widthThreshold = window.outerWidth - window.innerWidth > threshold; var heightThreshold = window.outerHeight - window.innerHeight > threshold; var orientation = widthThreshold ? 'vertical' : 'horizontal'; if (!(heightThreshold && widthThreshold) && ((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || widthThreshold || heightThreshold)) { if (!devtools.open || devtools.orientation !== orientation) { emitEvent(true, orientation); } devtools.open = true; devtools.orientation = orientation; } else { if (devtools.open) { emitEvent(false, null); } devtools.open = false; devtools.orientation = null; } }, 500); if (typeof module !== 'undefined' && module.exports) { module.exports = devtools; } else { window.devtools = devtools; } })(); function addEvent(evnt, elem, func) { if (elem.addEventListener) // W3C DOM elem.addEventListener(evnt,func,false); else if (elem.attachEvent) { // IE DOM elem.attachEvent("on"+evnt, func); } else { // No much to do elem[evnt] = func; } } function vvDebugg(message){ /* var caller_t = arguments.callee.caller.toString().split('function'); var caller_s = caller_t[1].split('{'); if(caller_s[0] != " ()"){ caller =null;// ''+caller_s[0]+': '; }else { caller = null; } */ caller = null; level = false; style = ""; if(typeof message == 'string'){ if(message.match(/\+\+/)){ message = '%c'+message.replace('++',''); style = "color: green; font-weight: bold;"; }else if(message.match(/\*\*\*/)){ message = '%c'+message.replace('***',''); style = "color: red; font-weight: bold;"; }else if(message.match(/\-\-/)){ message = '%c'+message.replace('--',''); style = "color: gray;"; } } if(debugg){ if (window.console) { if (!level || level === 'info') { if(caller == null){ window.console.log(message,style); }else{ window.console.log(caller,message); } } else { if (window.console[level]) { window.console[level](message,style); } else { window.console.log('<' + level + '> ' + message); } } } } } function IsJsonString(str) { try { JSON.parse(str); } catch (e) { return false; } return true; } function truncate(string,l){ if (string.length > l) return string.substring(0,(l-3))+'...'; else return string; }; function vvTemplate(html,array){ for(var o in array){ var re = new RegExp("{"+o+"}", 'g'); html = html.replace(re, array[o]); } return html } /** * vvGetData * * @Denna funktion ligger i vvjQuery.js * @Detta är gjort för marcovukota * */ $.fn.vvGetData = async function(options){ var defaults = { parent : null, url : "/?init=none&vvAjaxRequest=true", dataType: "html", // xml, json, script, or html type : "GET",// GET callback: null, after: null, trigger:'vvGetDataDone', parms : {} } var plugin = this; plugin.settings = {}; plugin.init = function() { plugin.settings = $.extend({}, defaults, options); plugin.vvAjax(); vvDebugg('--- vvGetData init'); } plugin.callback = function(data){ $(plugin).html(data); //$(document).trigger('vvInit'); if(plugin.settings.parms.silent){ }else{ vvCountDownVVInit(); } $(document).trigger(plugin.settings.trigger); if(plugin.settings.triggerAfter != undefined){ $(document).trigger(plugin.settings.triggerAfter,plugin.settings,data); } if(plugin.settings.after != null){ plugin.settings.after(data); } }; plugin.vvAjax = function() { vvDebugg('--- vvGetData url -> '+plugin.settings.url); vvDosubmit = true; jQuery.support.cors = true; storeRequest( $.ajax({ url:plugin.settings.url+'&vvAjaxRequest=true', data:plugin.settings.parms, type:plugin.settings.type, dataType:plugin.settings.dataType, cache: false, crossDomain: true, error: function (jqXHR, textStatus, errorThrown) { //alert('AJAX Request Error: ' + textStatus + ', ' + errorThrown); $(plugin).removeClass('loading'); vvDebugg('vvGetData: ' + textStatus + ', ' + errorThrown); // If you want to call the callback even in case of error, ensure to handle error inside the callback plugin.callback('Request aborted, please try again.'); }, beforeSend: function(){ $(plugin).addClass('loading'); vvDebugg(plugin.settings); //vvLoadShow(); }, complete: function(data){ $(plugin).removeClass('loading'); vvDosubmit = false; //vvLoadHide(); vvDebugg('--- vvGetData complete'); if(IE){ } }, success: function(data){ if(plugin.settings.dataType == 'html'){ if(IsJsonString(data)){ data = JSON.parse(data); vvDebugg(data); if(!data.success || data.user == 'faild'){ $(document).trigger('vvAjaxFailed',data); } } } if(plugin.settings.callback != null){ vvDebugg('-- vvGetData callback: '+plugin.settings.callback); plugin.settings.callback(data); }else{ plugin.callback(data); } } }) ); }; plugin.init(); }; /** * vvShorten * * @Denna funktion ligger i vvjQuery.js * @Detta är gjort för telia was * */ $.fn.vvShorten = function(){ this.each(function(index, obj){ if($(obj).attr('stitle') == undefined){ title = $(obj).text(); $(obj).attr('stitle',title); }else{ title = $(obj).attr('stitle'); } leng = ($(window).width()/11); if((title.length*12)>$(this).parent().width()){ if($(obj).attr('rtitle') != undefined){ $(this).html($(obj).attr('rtitle')); }else{ if(title.length>leng){ shortText = jQuery.trim(title).substring(0, leng).split(" ").slice(0, -1).join(" ") + "..."; $(this).html(shortText); } } }else{ $(this).html(title); } }); } $.fn.preload = function() { this.each(function(){ $('')[0].src = this; }); } /** * vvSelector * * @Denna funktion ligger i vvjQuery.js * @Detta är gjort för noexcuses * */ $.fn.vvSelector = function() { $(this).each(function(index, element) { $(this).unbind('change').bind('change',function(e){ $(this).parent().find('span').html($(this).find(':selected').text()); $(this).trigger('vvSelectChange'); }); if($(this).find(':selected').text() == ""){ val = $(this).parent().find('span').attr('placeholder'); }else{ val = $(this).find(':selected').text(); } $(this).parent().find('span').html(val); }); return true; } /** * vvScrollFade * * @Denna funktion ligger i vvjQuery.js * @Detta är gjort för mood * */ $.fn.vvScrollFade = function(s) { if(this.attr('stop') == undefined){ this.attr('stop',this.offset().top); } var st = parseInt(this.attr('stop'))+this.height(); var s = $(window).scrollTop(); var e = $(".white-page").offset().top; var t = this.offset().top+this.height(); var p = e-t; var a = e-st; var x = p/a; this.css({opacity:x}); } /** * vvAbsolutCenter * * @Denna funktion ligger i vvjQuery.js * @För att centerar en din efter w */ $.fn.vvAbsolutCenter = function(w) { this.each(function(){ if($(this).outerWidth()>w){ var v = Math.max(0,($(this).outerWidth()-w)/2); }else{ var v = 0; } $(this).css({left:-v}); }); } /** * vvAbsolutCenter * * @Denna funktion ligger i vvjQuery.js * @För att centerar en din efter w */ $.fn.vvFixedAtPass = function(s) { this.each(function(){ if($("."+$(this).attr('id')+'-clone').get(0) == undefined){ clone = $('
'); clone.addClass($(this).attr('id')+'-clone'); clone.addClass($(this).attr('mobile_class')); clone.css({padding:$(this).css('padding')}); $(this).css('position','absolute'); $(this).after(clone); }else{ clone = $("."+$(this).attr('id')+'-clone'); } clone.css({height:$(this).height()}); if(s >= clone.offset().top){ /* if($(this).attr('lastPos') == undefined){ $(this).attr('lastPos',$(this).css('position')); $(this).attr('lastPosY',$(this).offset().top); } if($("."+$(this).attr('id')+'-clone').get(0) == undefined){ clone = $(this).clone(); clone.addClass($(this).attr('id')+'-clone'); clone.removeClass('fixed-at-pass'); clone.css({position:'fixed',top:0,zIndex:99999999999999999999}); $(body).prepend(clone); } */ $(this).css({position:'fixed',top:0}); }else{ //$("."+$(this).attr('id')+'-clone').hide(); $(this).css({position:'absolute',top:'auto'}); } }); } /** * vvCenter * * @Denna funktion ligger i vvjQuery.js * @För att centerar en din efter w */ $.fn.vvCenter = function(w) { this.each(function(){ if($(this).css('display') == 'none'){ return true; } var v = Math.max(0,(w-$(this).outerWidth())/2); $(this).css({left:v}); }); } /** * vvMiddle * * @Denna funktion ligger i vvjQuery.js * @För att centerar horisontelt en din efter h och scroll */ $.fn.vvMiddle = function(h,s,ani) { if(ani == undefined){ ani = false; } this.each(function(){ if($(this).css('display') == 'none'){ return true; } var m = Math.max(0,((h-$(this).outerHeight())/2)+s); if(ani){ $(this).stop().animate({top:m},100); }else{ $(this).offset({top:m}) } }); } /** * vvFullWith * * @Denna funktion ligger i vvjQuery.js * @För att gör div lika som w */ $.fn.vvFullWith = function(w){ if($(this).css('display') == 'none'){ return true; } pad = parseInt($(this).css('paddingLeft'))+parseInt($(this).css('paddingRight')); margin = parseInt($(this).css('marginLeft'))+parseInt($(this).css('marginRight')); border = parseInt($(this).css('border')); v = w-pad-margin-border; $(this).css('width',v); } /** * vvFullWith * * @Denna funktion ligger i vvjQuery.js * @För att gör div lika som h */ $.fn.vvFullHeight = function(h){ if($(this).css('display') == 'none'){ return true; } pad = parseInt($(this).css('paddingTop'))+parseInt($(this).css('paddingBottom')); border = parseInt($(this).css('border')); v = h; $(this).css('height',h); } /** * vvDivResponsive * * @Denna funktion ligger i vvjQuery.js * @För att göra video scale prop */ $.fn.vvDivResponsive = function(w,h){ var width = w; // var height = h; // if(width == undefined){ return; } if(height == undefined){ return; } //original height / original width x new width = new height dHeight = height/width * $(this).width(); $(this).css('height',dHeight); } /** * vvDivStretch * * @ Denna funktion ligger i vvjQuery.js * @ */ $.fn.vvDivStretch = function(w,h,sw,sh){ var maxWidth = sw; // var maxHeight = sh; // var ratio = 0; // Used for aspect ratio var width = w; // var height = h; // vvDebugg(w+', '+h+', '+sw+', '+sh); // Check if the current width is larger than the max if(width < maxWidth){ /* get ratio for scaling image*/ ratio = maxWidth/width; vvDebugg(ratio); $(this).css("width", maxWidth);// Set new width $(this).css("height", height * ratio); // Scale height based on ratio height = height * ratio;// Reset height to match scaled image width = width * ratio;// Reset width to match scaled image } if(height < maxHeight){ // Check if current height is larger than max /* get ratio for scaling image*/ ratio = maxHeight/height; vvDebugg('H:'+ratio); $(this).css("height", maxHeight);// Set new height $(this).css("width", width * ratio);// Scale width based on ratio width = width*ratio;// Reset width to match scaled image } } /** * vvVideoStretch * * @Denna funktion ligger i vvjQuery.js * @För att gör video Stretch */ $.fn.vvVideoStretch = function(w,h){ var maxWidth = w; // Max width for the image var maxHeight = h; // Max height for the image var ratio = 0; // Used for aspect ratio var width = $(this).attr('mwidht'); // Current image width var height = $(this).attr('mheight'); // Current image height // Check if the current width is larger than the max if(width < maxWidth){ /* get ratio for scaling image*/ ratio = maxWidth/width; vvDebugg(ratio); $(this).css("width", maxWidth);// Set new width $(this).css("height", height * ratio); // Scale height based on ratio height = height * ratio;// Reset height to match scaled image width = width * ratio;// Reset width to match scaled image } if(height < maxHeight){ // Check if current height is larger than max /* get ratio for scaling image*/ ratio = maxHeight/height; vvDebugg('H:'+ratio); $(this).css("height", maxHeight);// Set new height $(this).css("width", width * ratio);// Scale width based on ratio width = width*ratio;// Reset width to match scaled image } } /** * vvVideoResponsive * * @Denna funktion ligger i vvjQuery.js * @För att göra video scale prop */ $.fn.vvVideoResponsive = function(){ var width = $(this).attr('mwidht'); // Current image width var height = $(this).attr('mheight'); // Current image height if(width == undefined){ return; } if(height == undefined){ return; } //original height / original width x new width = new height videoHeight = height/width * $(this).width(); $(this).css('height',videoHeight); } function vvIsNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); } /** * vvSerialize * * @Victors egna serialize function för vvajax */ $.fn.vvSerialize = function() { var radio = new Array(); var parms = {}; var i = 0; var multiInputs = new Array(); parms.validForm = true; this.each(function(){ obj = $(this); if(obj.attr('required') != undefined || obj.hasClass('required')){ if (obj.attr("type") == "checkbox" && !obj.is(':checked')) { parms[obj.attr("name")] = '_empty'; parms.validForm = false; }else if (obj.attr("type") == "radio"){ if( !$("input:radio[name="+obj.attr('name')+"]").is(":checked")){ parms[obj.attr("name")] = '_empty'; parms.validForm = false; }else{ parms[obj.attr("name")] = $("input:radio[name="+obj.attr('name')+"]:checked").val(); } }else{ if(obj.val() === null || obj.val() == "" || obj.val() == obj.attr('placeholder')){ if(!obj.prop('disabled')){ parms[obj.attr("name")] = '_empty'; parms.validForm = false; if($(this).attr('required_text') != undefined){ obj.parent().addClass('_error'); vvMsgBox($(this).attr('required_text'),null,4000); } } }else{ obj.parent().removeClass('_error'); } } } if(obj.hasClass('required_mail')){ if(!validEmail(obj.val()) || obj.val() == ""){ parms[obj.attr("name")] = '_empty'; if($(this).attr('required_text') != undefined){ obj.parent().css({border:'1px solid red'}); vvMsgBox($(this).attr('required_text'),null,4000); } }else{ obj.parent().css({border:''}); } } if(obj.hasClass('required_number')){ vvDebugg('NR: '+vvIsNumeric(obj.val())); if(!vvIsNumeric(obj.val()) || obj.val() == ""){ parms[obj.attr("name")] = '_empty'; if($(this).attr('required_text') != undefined){ obj.parent().css({border:'1px solid red'}); vvMsgBox($(this).attr('required_text'),null,4000); } }else{ obj.parent().css({border:''}); } } if(obj.attr('required_length') != undefined){ if(obj.val() == "" || obj.val().length < parseInt(obj.attr('required_length'))){ parms[obj.attr("name")] = '_empty'; obj.parent().css({border:'1px solid red'}); vvMsgBox(allText.requiredLength,null,4000); }else{ obj.parent().css({border:''}); } } if(parms[obj.attr("name")] == undefined){ if(parms[obj.attr("name")] != '_empty'){ if (obj.hasClass("summernote")) { obj.val(obj.summernote('code')); parms[obj.attr("name")] = obj.val(); vvDebugg(parms[obj.attr("name")]); }else if (obj.attr("type") == "radio") { if(obj.is(':checked')){ parms[obj.attr("name")] = obj.val(); } if(obj.hasClass('required') && obj.parent().parent().find("input:checked").length == 0){ if($(this).attr('required_text') != undefined){ obj.parent().parent().css({border:'1px solid red'}); vvMsgBox($(this).attr('required_text'),null,4000); } parms[obj.attr("name")] = false; }else{ obj.parent().parent().css({border:''}); } }else if (obj.attr("type") == "checkbox") { if(obj.hasClass('checkboxPlus')){ if(obj.is(':checked')){ if(parms[obj.attr("name")] == "" || parms[obj.attr("name")] == undefined){ parms[obj.attr("name")] = obj.val(); }else{ parms[obj.attr("name")] += ","+obj.val(); } } }else{ if(obj.is(':checked')){ parms[obj.attr("name")] = 1; }else{ parms[obj.attr("name")] = 0; } } }else{ if(obj.attr("name") != undefined){ if(obj.attr("name").match(/\[(.*?)\]/)){ n = obj.attr("name"); regex = /(.*?)\[\]/gi; m = regex.exec(n); if(m != null){ if(multiInputs[m[1]] == undefined){ multiInputs[m[1]] = 0; } multiInputs[m[1]]++; parms[m[1]+'['+multiInputs[m[1]]+']'] = obj.val(); }else{ parms[n] = obj.val(); } }else{ parms[obj.attr("name")] = obj.val(); } } } } } }); for(var k in parms){ if(k != "validForm"){ if(parms[k] != null && (typeof parms[k] == "string")){ parms[k] = parms[k].replace('+','+'); parms[k] = encodeURI(parms[k]); } if(parms[k] == "_empty" ){ parms[k] = null; } i++; } } if(parms.length> 0){ vvDebugg(parms); } parms.length = i; return parms; } /** * vvSerializeDiv by indice * * @vvSerializeDiv */ $.fn.vvSerializeDiv = function() { var parms = {}; var i = 0; this.each(function(){ obj = $(this); parms[obj.attr("id")] = i; obj.attr("indice",i); i++; }); parms.length = i; return parms; } /** * vvSortList by indice * * @Sorterat div lista */ $.fn.vvSortList = function(c) { $(this).html($(c).sort(function(a, b) { return $(a).attr('indice') - $(b).attr('indice'); })); } /** * vvAttackTrim * * @Rensar sring from script */ function vvAttackTrim(v){ v = v.replace('script',''); v = v.replace('/g, '>'); var OPTS = { 'ENT_NOQUOTES': 0, 'ENT_HTML_QUOTE_SINGLE': 1, 'ENT_HTML_QUOTE_DOUBLE': 2, 'ENT_COMPAT': 2, 'ENT_QUOTES': 3, 'ENT_IGNORE': 4 }; if (quote_style === 0) { noquotes = true; } if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags quote_style = [].concat(quote_style); for (i = 0; i < quote_style.length; i++) { // Resolve string input to bitwise e.g. 'ENT_IGNORE' becomes 4 if (OPTS[quote_style[i]] === 0) { noquotes = true; } else if (OPTS[quote_style[i]]) { optTemp = optTemp | OPTS[quote_style[i]]; } } quote_style = optTemp; } if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { string = string.replace(/'/g, '''); } if (!noquotes) { string = string.replace(/"/g, '"'); } return string; } function htmlspecialchars_decode (string, quote_style) { var optTemp = 0, i = 0, noquotes = false; if (typeof quote_style === 'undefined') { quote_style = 2; } string = string.toString().replace(/</g, '<').replace(/>/g, '>'); var OPTS = { 'ENT_NOQUOTES': 0, 'ENT_HTML_QUOTE_SINGLE': 1, 'ENT_HTML_QUOTE_DOUBLE': 2, 'ENT_COMPAT': 2, 'ENT_QUOTES': 3, 'ENT_IGNORE': 4 }; if (quote_style === 0) { noquotes = true; } if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags quote_style = [].concat(quote_style); for (i = 0; i < quote_style.length; i++) { // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4 if (OPTS[quote_style[i]] === 0) { noquotes = true; } else if (OPTS[quote_style[i]]) { optTemp = optTemp | OPTS[quote_style[i]]; } } quote_style = optTemp; } if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { string = string.replace(/�*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should // string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP } if (!noquotes) { string = string.replace(/"/g, '"'); } string = string.replace(/&/g, '&'); return string; } $.fn.vvHtml = function(arr) { for(d in arr){ arr[d] = htmlspecialchars_decode(arr[d]); } return arr; } jQuery.fn.insertAt = function(index, element) { var lastIndex = this.children().size() if (index < 0) { index = Math.max(0, lastIndex + 1 + index) } this.append(element) if (index < lastIndex) { this.children().eq(index).before(this.children().last()) } return this; } /*! Copyright 2012, Ben Lin (http://dreamerslab.com/) * Licensed under the MIT License (LICENSE.txt). * * Version: 1.0.19 * * Requires: jQuery >= 1.2.3 */ ;( function ( factory ) { if ( typeof define === 'function' && define.amd ) { // AMD. Register module depending on jQuery using requirejs define. define( ['jquery'], factory ); } else { // No AMD. factory( jQuery ); } }( function ( $ ){ $.fn.addBack = $.fn.addBack || $.fn.andSelf; $.fn.extend({ actual : function ( method, options ){ // check if the jQuery method exist if( !this[ method ]){ throw '$.actual => The jQuery method "' + method + '" you called does not exist'; } var defaults = { absolute : false, clone : false, includeMargin : false, display : 'block' }; var configs = $.extend( defaults, options ); var $target = this.eq( 0 ); var fix, restore; if( configs.clone === true ){ fix = function (){ var style = 'position: absolute !important; top: -1000 !important; '; // this is useful with css3pie $target = $target. clone(). attr( 'style', style ). appendTo( 'body' ); }; restore = function (){ // remove DOM element after getting the width $target.remove(); }; }else{ var tmp = []; var style = ''; var $hidden; fix = function (){ // get all hidden parents $hidden = $target.parents().addBack().filter( ':hidden' ); style += 'visibility: hidden !important; display: ' + configs.display + ' !important; '; if( configs.absolute === true ) style += 'position: absolute !important; '; // save the origin style props // set the hidden el css to be got the actual value later $hidden.each( function (){ // Save original style. If no style was set, attr() returns undefined var $this = $( this ); var thisStyle = $this.attr( 'style' ); tmp.push( thisStyle ); // Retain as much of the original style as possible, if there is one $this.attr( 'style', thisStyle ? thisStyle + ';' + style : style ); }); }; restore = function (){ // restore origin style values $hidden.each( function ( i ){ var $this = $( this ); var _tmp = tmp[ i ]; if( _tmp === undefined ){ $this.removeAttr( 'style' ); }else{ $this.attr( 'style', _tmp ); } }); }; } fix(); // get the actual value with user specific methed // it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc // configs.includeMargin only works for 'outerWidth' and 'outerHeight' var actual = /(outer)/.test( method ) ? $target[ method ]( configs.includeMargin ) : $target[ method ](); restore(); // IMPORTANT, this plugin only return the value of the first element return actual; } }); }));