Skip to content

Instantly share code, notes, and snippets.

@MrSwed
MrSwed / shorttext.js
Created March 15, 2017 06:28
Сокращение текста с добавлением ссылки "далее"
jQuery(function($) {
(function(st){
st = $(st);
if (st.size()) {
if ($("p",st).size()>1 ){
$("p:first",st).append(" <span class='hidetext_swith'>Далее &gt;&gt;</span>");
var str = st.html();
var lens = str.indexOf("hidetext_swith")+ $(".hidetext_swith").html().length + 27 ;
$(st).html(str.replace(str.substr(lens),
@MrSwed
MrSwed / ajax.php
Last active February 28, 2017 11:58
MODx EVO Ajax. More correct method. http://modx.im/blog/triks/2103.html
<?php
/*
* More functional and correct ajax api for MODx EVO
* Propose: http://modx.im/blog/triks/2103.html
* Author: Agel_Nash (http://modx.im/profile/Agel_Nash/)
* Author: Swed (http://modx.im/profile/swed/)
*
* Version: 0.2
* https://gist.github.com/MrSwed/710656f4ba6ad0d4272d4515d9e95f63
*
@MrSwed
MrSwed / jQuery.toTopAnchor.css
Created February 14, 2017 11:16
Ссылка наверх с плавным скроллингом
.toTopAnchor {
background: #e8e8e8;
cursor: pointer;
display: none;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 40px;
z-index: 20;
@MrSwed
MrSwed / bookmark-tab-size.txt
Created December 16, 2016 15:01
Set tab size in github and etc
#Set Tab size - 1
javascript:(function(){var style=document.createElement('style'),css=document.createTextNode('*{-moz-tab-size:1;tab-size:1;}');style.appendChild(css);document.getElementsByTagName('head')[0].appendChild(style);})(); Raw
@set Tab size -2
javascript:(function(){var style=document.createElement('style'),css=document.createTextNode('*{-moz-tab-size:2;tab-size:2;}');style.appendChild(css);document.getElementsByTagName('head')[0].appendChild(style);})(); Raw
@MrSwed
MrSwed / jQuery-spinButtons-extend.js
Created December 16, 2016 14:56
jQuery input number custom style
$.fn.extend({
"spinButtons": function(p){
return $(this).each(function(){
var t = this;
t.p = $.extend({}, {}, p);
t._props = function(){
t.p.max = $(t).prop("max");
t.p.min = $(t).prop("min");
t.p.step = parseFloat($(t).prop("step")) || 1;
};
@MrSwed
MrSwed / evoTotal.tpl
Created November 29, 2016 18:01
EvoGallery snippet for get count of images in gallery
<?php
$id = isset($id)?$id:$modx->documentIdentifier; //берем id текущей страницы
$out = isset($out)?$out:"%s";
//формируем запрос к базе
$res = $modx->db->select("count(`content_id`)",$modx->getFullTableName('portfolio_galleries'),"content_id='{$id}'");
$row = $modx->db->getRow($res,'both');
return (1 * $row[0] ? sprintf($out,$row[0]):"");
?>
@MrSwed
MrSwed / .htaccess
Last active November 28, 2016 08:19
deny php run from media folders
order deny,allow
allow from all
<FilesMatch "\.(php*|phtml)$">
Order Deny,Allow
Deny from all
</FilesMatch>
@MrSwed
MrSwed / maxygallery-to-mm_ddMultipleFields.sql
Created September 9, 2016 12:16
MODX EVO. convert maxygallery gallery to mm_ddMultipleFields tv use
-- usable for convert maxygallery gallery to mm_ddMultipleFields tv use:
-- mm_ddMultipleFields('gallery', '', '', 'image,text,text', 'Image,Name,...');
-- also you need to move /assets/galleries to /assets/images/galleries
insert into modx_site_tmplvar_contentvalues
SELECT null, 13, gal_id,
GROUP_CONCAT(DISTINCT concat('assets/images/galleries/',gal_id,'/',filename,'::',title) separator '||')
as tline
FROM `modx_maxigallery`
@MrSwed
MrSwed / git-hooks.sh
Last active July 12, 2023 14:06
Enable or Disable git hooks
#!/usr/bin/env bash
# Enable or disable git hooks
#find .git/hooks/ -type f ! -name "*.*"
gitHooks=.git/hooks/
echo "git Hooks $gitHooks"
option="${1}"
@MrSwed
MrSwed / jQuery-ajax-form.js
Last active December 27, 2018 12:56
jQuery extender submit form with ajax without reload page.
$(function(){
$.fn.extend({
/* A kit of jQuery extensions for an forms manipulation via Ajax
* https://gist.github.com/MrSwed/2d86f2f0fd96fdc1e81aa414f0d53881
*/
"class": function(){
/* jQuery-class-extender: Get className even is empty jQuery object https://gist.github.com/MrSwed/0a837b3acbfbf8cfb19e */
return $(this).attr("class") ||
$(this).selector.toString().replace(/^.*[\s]+([^\s])/, "$1").replace(/(^[^\.]+\.|[:][^\s]+)/, "").split(".")
.join(" ").trim();