Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
@mircobabini
mircobabini / Angular.SideMenu.NavController.js
Last active August 29, 2015 14:03
Simple Navigation Controller for AngularJS + Ionic (SideMenu); provides toggleMenu(), hideMenu(), showMenu() for left and right sidemenus
angular.module('app.controllers', [])
.controller('NavController', function($scope, $ionicSideMenuDelegate) {
$scope.toggleMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
};
$scope.showMenu = function () {
$ionicSideMenuDelegate.toggleLeft(true);
};
$scope.hideMenu = function () {
$ionicSideMenuDelegate.toggleLeft(false);
@mircobabini
mircobabini / Angular.Navigator.js
Last active August 29, 2015 14:03
Simple Navigation Controller for AngularJS + Ionic; provides goBack(), goHome()
angular.module('app.controllers', [])
.controller('NavController', function($scope, $ionicSideMenuDelegate, Navigator) {
$scope.goBack = function() {
$ionicNavBarDelegate.back();
};
// just for this demo
$scope.goHome = function() {
Navigator.home();
};
@mircobabini
mircobabini / JustNavigateTo.js
Last active August 29, 2015 14:03
Angular.js Navigation (refresh) library: Just navigate (and "refresh" the view [and the sidemenu too]) everywhere getting rid of $route.reload(), $scope.$apply(), $timeout, $window.location.reaload() and so on.. just go and refresh with no headache
// 1. add the specific state
$stateProvider.state('justnav', {
url : '/justnav',
templateUrl: 'justnav.html',
controller : 'JustNavigate'
})
// 2. add the controller and factory
.controller('JustNavigate', function($scope, $ionicViewService, JustNavigate) {
$ionicViewService.nextViewOptions({ disableBack: true });
@mircobabini
mircobabini / $ionicListDelegate.toggleDelete.js
Created July 18, 2014 14:34
Adds the toggleDelete ability to the current $scope, useful when working with $ionicListDelegate
$scope.toggleDelete = function(){
if( $ionicListDelegate.showDelete() ){
$ionicListDelegate.showDelete(false);
}else{
$ionicListDelegate.showDelete(true);
}
}
<?php
class JSON_API_Controller_Helper {
/**
* @global json_api $json_api
* @return array
*/
protected function _get () {
global $json_api;
$args = func_get_args ();
@mircobabini
mircobabini / spacers.css
Last active August 29, 2015 14:04
Some CSS classes useful to space elements; pattern (doc in comments): [p]{direction}{amount}
/**
* @author Mirco Babini, Web & Mobile App Developer
* @version 1.2.7
* https://gist.github.com/mircobabini/0d0410498c975f30d6fb
*
* pattern for margins: [m]{direction}{amount}, the m is optional
* pattern for paddings: p{direction}{amount}, the p is NOT optional
*
* the directions are top, right, bottom, left, horizontal (left and right) and vertical (top and bottom)
* you can also use the short directions, that are t, r, b, l, h and v
User-agent: *
noindex: /wp-admin/
noindex: /wp-includes/
noindex: /wp-content/plugins/revslider/
@mircobabini
mircobabini / recursive_do_shortcode.php
Created August 12, 2014 09:56
Recursive do_shortcode WordPress function
<?php
function dodo_shortcode( $string ){
$compiled = do_shortcode( $string );
if( $compiled != $string ){
return dodo_shortcode( $string );
}
return $compiled;
}
$scope.getBrickHeight = function(){
if( $scope.brickHeight === undefined ){
$scope.brickHeight = ( ( jQuery(document).width() / jQuery(document).height() ) * 40 ) + '%';
}
return $scope.brickHeight;
}