$(function() { /** * set required fields, add star class to them. * * @access public * @return void */ var setrequiredfields = function() { if(!config || !config.requiredfields) return; var requiredfields = config.requiredfields.split(','); for(i = 0; i < requiredfields.length; i++) { var $field = $('#' + requiredfields[i]); $field.closest('td,th').prepend("
"); $field.closest('.form-group').addclass('required'); if(window.v && window.v.lang.required) { $field.attr('placeholder', '(' + window.v.lang.required + ') ' + ($field.attr('placeholder') || '')); } } }; // set required feilds in form setrequiredfields(); // make company links on app navbar as modaltrigger to open content with modal $('#appnav .nav-system-company a, #appnav a[data-toggle="modal"]').modaltrigger(); // set active item on #appnav var $appnav = $('#appnav'); var activednav = v.activednav; if(!activednav) { if(config && config.currentmodule) { var modulename = config.currentmodule; if(modulename === 'article' || modulename === 'product' || modulename === 'blog') { var lifinded = false; $appnav.find('li > a').each(function() { var $a = $(this); var href = $a.attr('href'), $li = $a.parents('li'), pathname = document.location.pathname; var hrefindex = href.indexof(pathname); if(href !== '/' && hrefindex === 0 && !$li.hasclass('active')) { $li.addclass('active'); lifinded = true; } }); if(!lifinded) activednav = '.nav-' + modulename + '-0'; } else activednav = '.nav-system-' + (modulename === 'index' ? 'home' : modulename); } } $appnav.find(activednav).addclass('active'); // init deleter $(document).on('click', '.deleter', function(e) { var $this = $(this); var options = $.extend({url: $this.attr('href'), confirm: window.v.lang.confirmdelete}, $this.data()); e.preventdefault(); $.ajaxaction(options, $this); }); function tidycardsrow($row) { var $cards = $row.children('.col'); if($cards.length < 2) { $cards.css('width', '100%'); return; } var contentheight = 0, minimgheight = 9999, maximgheight = 0; var width = 100.0 / $cards.length; $cards.each(function() { var $col = $(this).css('width', width + '%'); contentheight = math.max(contentheight, $col.find('.card-content').height()); var $img = $col.find('.card-img').css('height', 'auto'); var imgheight = $img.height(); if(!$img.find('.media-placeholder').length) minimgheight = math.min(minimgheight, imgheight); maximgheight = math.max(maximgheight, imgheight); }); if(minimgheight === 9999) return; $cards.find('.card-content').css('height', contentheight); if(minimgheight > 20) { $cards.find('.card-img').css({'height': minimgheight}) .find('.media-placeholder').css({'height': minimgheight, 'line-height': minimgheight + 'px'}); } if(maximgheight !== minimgheight || minimgheight <= 20) {settimeout(function(){tidycardsrow($row);}, 500);} }; $.fn.tidycards = function() { return $(this).each(function() { $(this).children('.row').each(function(){tidycardsrow($(this));}); }); }; $('.cards-products').tidycards(); $(window).on('lazyloaded', function(e, $img) { var $row = $img.closest('.row'); if($row.parent().hasclass('cards-products')) tidycardsrow($row); }) });