Skip to content

Instantly share code, notes, and snippets.

View SergeiGolos's full-sized avatar
🐢

Sergei Golos SergeiGolos

🐢
View GitHub Profile
'use strict';
/**
* @ngdoc service
* @name toPromiseApp.toPromise
* @description
* # toPromise
* # a service call for wrapping synchronous calls to result in a promise.
*/
angular.module('toPromiseApp')
@SergeiGolos
SergeiGolos / Bootstrap - Typeahead.prototype.dispose
Created October 2, 2014 12:16
Implementation of a dispose function for bootstraps typeahead control.
(function (typeahead) {
'use strict';
typeahead.prototype.dispose = function () {
if (this.eventSupported('keydown')) {
this.$element.off('keydown');
}
this.$element.off('focus').off('blur').off('keypress').off('keyup');
this.$element = null;
this.$menu.off('click').off('mouseenter').off('mouseleave');
@SergeiGolos
SergeiGolos / gist:6113551
Created July 30, 2013 14:44
AngularTemplateTransform
/// <summary>
/// Handles assembling html documents single set of ng-template items.
/// </summary>
public class AngularTempalteTransform : IBundleTransform
{
/// <summary>
/// Process the bundle.
/// </summary>
/// <param name="context">The current bundle context.</param>
/// <param name="response">The response object to write to.</param>
@SergeiGolos
SergeiGolos / gist:4520619
Created January 12, 2013 21:46
[AngularJS] [Module] RoutingEvents
/* The MIT License (MIT)
Copyright (c) 2013 Sergei Golos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECT
@SergeiGolos
SergeiGolos / gist:4250767
Created December 10, 2012 14:11
[BOOTSTRAP] Useful Snippits
<!--
************** Inline Forms ***********************
-->
<form class="form-inline">
<input type="text" class="input-small" placeholder="Email">
<input type="password" class="input-small" placeholder="Password">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button type="submit" class="btn">Sign in</button>
@SergeiGolos
SergeiGolos / gist:4248435
Created December 10, 2012 04:50
ScratchPad
/// Define the routes of the application.
var app = angular.module('Main', ['keyboardProvider', 'tasksProvider'], function($routeProvider, $locationProvider) {
$routeProvider.when('/details/:taskId', { controller: 'ctrl_Details', templateUrl: "view/details.html" });
$routeProvider.when('/new', { controller: 'ctrl_New', templateUrl: "view/new.html" });
$routeProvider.when('/', { controller: 'ctrl_List', templateUrl: 'view/home.html' });
$routeProvider.otherwise({redirectTo:'/'});
});
/// Displays the the full detail view of a task, also applys the filter to show only the history for the results list.
app.controller('ctrl_Details', function ($scope: DetailScope, $routeParams: any) {
@SergeiGolos
SergeiGolos / combotext.js
Created December 10, 2012 04:12
[APOLLO TRAINING] BindingBuilder - combotext
// <div class="siad-bind" data-model="" data-property="" data-binding="combotext|target=_cbPar" data-value="" style="display:none;"></div>
BindingBuilder.Add('combotext', function ($element, properties, options) {
var dropdown = window[options['target']];
var $dropdown = $(dropdown.Container).hide();
var length = dropdown.options.length;
var $el = $("<input>", {
'type' : 'text',
@SergeiGolos
SergeiGolos / gist:4204601
Created December 4, 2012 14:38
[C#] Raven Unity Bootstrap
public static class Bootstrapper
{
public static void Initialise()
{
var container = BuildUnityContainer();
DependencyResolver.SetResolver(new IoCContainer(container));
}
private static IUnityContainer BuildUnityContainer()
{
@SergeiGolos
SergeiGolos / gist:4204499
Created December 4, 2012 14:30
[C#] Raven Controller
using Microsoft.Practices.Unity;
using Raven.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace BeerPad.Controllers
{
@SergeiGolos
SergeiGolos / controller.js
Created November 26, 2012 00:01
[AngularStudent] Routing? Part1 (controller.js)
angular.module('ngViewTest', [],
function($routeProvider, $locationProvider) {
$routeProvider.when('/About', {
templateUrl: 'about.html' ,
controller : BasicPageCntl });
$routeProvider.when('/Details/:detailId', {
templateUrl: 'detailTemplate.html',
controller : DetailPageCntl});