React and immutable example of a simple top down, one way data flow, single state app.
A Pen by Brian Emil Hartz on CodePen.
React and immutable example of a simple top down, one way data flow, single state app.
A Pen by Brian Emil Hartz on CodePen.
| ###APIs | |
| * http://www.programmableweb.com/ |
| angular.module('loginApp', []) | |
| .directive("loginForm", [ | |
| function () { | |
| return { | |
| restrict: 'E', | |
| scope: {}, | |
| template: '<div class="row"> <div class="col-xs-12"> <form name="loginForm"> <div class="form-group"> <label for="username">Username</label> <input type="text" name="username" ng-model="username" required="required" class="form-control"/> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" name="password" ng-model="password" required="required" class="form-control"/> </div> <button type="submit" ng-disabled="!loginForm.$valid" ng-class="{\'btn-default\':!loginForm.$valid,\'btn-success\':loginForm.$valid}" ng-click="login()" class="btn login">Login</button> <span ng-show="loginError && !loginForm.$valid" class="label label-danger"> <b>Error With Login</b> Please try again. </span></form> </div> </div>', | |
| replace: 'true', | |
| controller: ['$scope', '$http', '$window', |
| .directive('fileDownload', function ($compile) { | |
| var fd = { | |
| restrict: 'A', | |
| link: function (scope, iElement, iAttrs) { | |
| scope.$on("downloadFile", function (e, url) { | |
| // console.log('dl url-', url); | |
| var iFrame = iElement.find("iframe"); | |
| if (!(iFrame && iFrame.length > 0)) { | |
| iFrame = angular.element("<iframe style='position:fixed;display:none;top:-1px;left:-1px;'/>"); | |
| iElement.append(iFrame); |
| --reporter spec | |
| --watch | |
| --recursive |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <title>JavaScript Patterns</title> | |
| <meta charset="utf-8"> | |
| </head> | |
| <body> | |
| <script> | |
| /* Title: window scroll event | |
| * Description: avoid attaching handlers to the window scroll event |
| (function(){ | |
| 'use strict'; | |
| $(document).on('ready', function(){ | |
| var getGitHubSocialInfo = function(githubURLJSON, githubURL, containerEl) { | |
| $.ajax({ | |
| url: githubURLJSON, | |
| dataType: "jsonp", | |
| success: function(data) { | |
| var theCount = data.data.watchers_count; |
| // Hold functions related to client side password validation | |
| var password = function () { | |
| var minPasswordLength = 8; | |
| var _hasLowerCase = /[a-z]/; | |
| var _hasUpperCase = /[A-Z]/; | |
| var _hasDigit = /\d/; | |
| var _hasNonWord = /(_|[^\w\d])/; | |
| var password = []; |
[ Launch: Hello World ] 093144225f67c410e515 by hartzis
| var ngEnterDirectives = angular.module('ngEnterDirectives', []); | |
| /* | |
| This directive allows us to pass a function in on an enter key to do what we want. | |
| */ | |
| ngEnterDirectives.directive('ngEnter', function () { | |
| return function (scope, element, attrs) { | |
| element.bind("keydown keypress", function (event) { | |
| if(event.which === 13) { | |
| scope.$apply(function (){ | |
| scope.$eval(attrs.ngEnter); |