Last active
June 29, 2022 21:58
-
-
Save Kcko/3ffa443ba0dedc78f6cf to your computer and use it in GitHub Desktop.
Revisions
-
Kcko revised this gist
Aug 25, 2015 . 2 changed files with 118 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ (function($) { $.extend($.expr[':'], { group: jQuery.expr.createPseudo(function(num) { return function(elem) { if (isNaN(num)) { return false; } return ($(elem).index() - 1) % (num * 2) < num; }; }) }); })(jQuery); /****************************************************************************** :column() Vybírá všechny bunky tabulky ve stejném sloupci, v nemž se nachází definovaná bunka. ******************************************************************************/ (function($) { $.fn.column = function() { var $cells = $(); this.each(function() { var $td = $(this).closest('td, th'); if ($td.length) { var colNum = $td[0].cellIndex + 1; var $columnCells = $td .closest('table') .find('td, th') .filter(':nth-child(' + colNum + ')'); $cells = $cells.add($columnCells); } }); return this.pushStack($cells); }; })(jQuery); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,81 @@ (function($) { $.mathUtils = { sum: function(array) { var total = 0; $.each(array, function(index, value) { total += $.mathUtils.parseCzechFloat(value); }); return total; }, parseCzechFloat: function(string) { var value = $.trim(string); return parseFloat(value.replace(' ', '').replace(',', '.')) || 0; }, formatCzechFloat: function(number) { return String(number).replace('.', ','); }, average: function(array) { if ($.isArray(array)) { return $.mathUtils.sum(array) / array.length; } return ''; } }; })(jQuery); /****************************************************************************** .swapClass() Na vybraných elementech prepíná mezi uvedenými trídami. ******************************************************************************/ (function($) { $.fn.swapClass = function(class1, class2) { return this.each(function() { var $element = $(this); if ($element.hasClass(class1)) { $element.removeClass(class1).addClass(class2); } else if ($element.hasClass(class2)) { $element.removeClass(class2).addClass(class1); } }); }; })(jQuery); /****************************************************************************** .shadow() Dopnuje vržený stín k elementu prostým kopírováním. ******************************************************************************/ (function($) { $.fn.shadow = function(opts) { var options = $.extend({}, $.fn.shadow.defaults, opts); return this.each(function() { var $originalElement = $(this); for (var i = 0; i < options.copies; i++) { var offset = options.copyOffset(i); $originalElement .clone() .css({ position: 'absolute', left: $originalElement.offset().left + offset.x, top: $originalElement.offset().top + offset.y, margin: 0, zIndex: -1, opacity: options.opacity }) .appendTo('body'); } }); }; $.fn.shadow.defaults = { copies: 5, opacity: 0.1, copyOffset: function(index) { return {x: index, y: index}; } }; })(jQuery); -
Kcko created this gist
Aug 25, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ (function( $ ){ $.nette.init(); // simple function $.extend( { swapArticleMaskClasses: function(obj, classAttr) { if (obj.hasClass(classAttr)) { obj.removeClass(classAttr).addClass(classAttr + '--'); } }, swapArticleMaskClassesRevert: function(obj, classAttr) { if (obj.hasClass(classAttr + '--')) { obj.removeClass(classAttr + '--').addClass(classAttr); } }, exists: function(selector) { return ($(selector).length > 0); } }); // jqury fn $.fn.extend({ swapClass: function(class1, class2) { return this.each(function() { var $element = $(this); if ($element.hasClass(class1)) { $element.removeClass(class1).addClass(class2); } else if ($element.hasClass(class2)) { $element.removeClass(class2).addClass(class1); } }); }, // simplier way if ( $('#myDiv')[0] ) ;) exists: function() { return ($(this).length > 0); }, hasParent: function(a) { return this.filter(function() { return !!$(this).closest(a).length; }); } }); })( jQuery );