Skip to content

Instantly share code, notes, and snippets.

View lossendae's full-sized avatar

Stéphane Boulard lossendae

View GitHub Profile
@lossendae
lossendae / nested_quote_parser.php
Created May 4, 2011 21:38
nested quote parser example
<?php
function parse_quote($matches) {
$bbcode = '';
preg_match_all('/(\w*?)=\'(.*?)\'/msi', $matches[1], $attr_matches);
$attributes = array_combine($attr_matches[1], $attr_matches[2]);
if(!empty($attributes))
{
$attribute_strings = array();
foreach($attributes as $key => $value)
{
@lossendae
lossendae / gist:974151
Created May 16, 2011 09:41
Image Preloader with jQuery and wordpress
/*<![CDATA[*/
$(document).ready( function(){
var images = $(document).find('.to_load img');
$.each( images, function( idx, value){
var original = $(this);
$(this).addClass('hidden');
$('<span class="img_loader">&nbsp;</span>').insertBefore( original );
var src = $(this).attr('src');
var $img = new Image();
$($img).delay( 500 ).load( function(){
@lossendae
lossendae / linked_combobox.js
Created June 8, 2011 09:50
Combobox linké
var firstCombo = new Ext.form.ComboBox({
store: store_combo_1,
typeAhead: true,
forceSelection: true,
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
id:'combo1'
});
@lossendae
lossendae / plugin.php
Created July 20, 2011 09:49
Modxpress plugin scramble
<?php
/**
* Handles plugin events for ModxPress
*
* @package modxpress
*/
$corePath = $modx->getOption('modxpress.core_path',null,$modx->getOption('core_path').'components/modxpress/');
switch ($modx->event->name) {
case 'OnManagerPageInit':
@lossendae
lossendae / tpl.js
Created November 7, 2011 13:40
Un exemple ExtJS pour une petite classe avec un template
/**
* A template desc panel base class
*
* @class MODx.DescPanel
* @extends Ext.Panel
* @param {Object} config An object of options.
* @xtype modx-desc-panel
*/
MODx.DescPanel = function(config) {
config = config || {};
@lossendae
lossendae / test-speed.php
Created March 1, 2012 21:36 — forked from opengeek/test-speed.php
Simple benchmark for iterative MODX Chunk parsing
<?php
include 'config.core.php';
include MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$modx->setLogLevel(xPDO::LOG_LEVEL_INFO);
$tstart = $modx->getMicroTime();
@lossendae
lossendae / bbdd.js
Created March 13, 2012 09:15
PLugin Drag and drop between grid and target placeholder
Ext.namespace('Ext.ux.dd');
Ext.ux.dd.BigBrotherGridDD = Ext.extend(Ext.util.Observable, {
copy: true
,scrollable: true
,constructor: function(config){
if (config)
Ext.apply(this, config);
// this.addEvents({
@lossendae
lossendae / transport.menu.php
Last active October 3, 2015 08:58 — forked from splittingred/transport.menu.php
MODX menu transport file (for MODX 2.3)
<?php
/* will route to the first found of the following:
[namespace-path]controllers/[manager-theme]/index.class.php
[namespace-path]controllers/default/index.class.php
[namespace-path]controllers/index.class.php
*/
$menu= $modx->newObject('modMenu');
$menu->fromArray(array(
'text' => 'mycomponent',
@lossendae
lossendae / breacrumb.js
Created January 10, 2014 15:37
Exemple of an AngularJS breadcrumbs directive for use with ui-router
var breadcrumbs = function($state, $stateParams) {
return {
restrict: 'E',
templateUrl: '/path/to/breadcrumbs.html',
replace: true,
compile: function(tElement, tAttrs) {
return function($scope, $elem, $attr) {
$scope.show = function(state){
if(!angular.isDefined(state.data)){
return false;
@lossendae
lossendae / index.html
Last active July 4, 2019 20:22
Dynamic (single level) menu for Angular ui-router
<!DOCTYPE html>
<html ng-app>
<head>
<title>Example</title>
</head>
<body>
<nav class="main-nav" data-main-menu data-root="index"></nav>
<script type="text/javascript" src="angular.js"></script>