JSFiddle - React, Tailwind, and code Playground

by cckugang

HTML

<form class="navbar-form navbar-right navbar-input-group" name="form" ng-submit="form.$valid && model.sn != undefined && model.sn !=0 && quickLookup() " novalidate>
                <div class="input-group" ng-class="{'has-error':form.search.$invalid}" >                            
                    <input type="search" class="form-control" id="search" name="search" placeholder="serial number lookup" ng-model="model.sn" ng-minlength="12" ng-maxlength="12" ng-pattern="/^\d{12}$/" popover="{{model.popoverText}}" popover-trigger="{{{true: 'keypress', false: 'never'}[form.search.$valid && model.sn.length != 0]}}" popover-placement="bottom">
                    <span class="input-group-addon glyphicon glyphicon-search" ng-click="form.$valid && model.sn != undefined && model.sn !=0 && quickLookup()" ng-style="{'cursor':'pointer'}" />
                </div>
            </form>

JavaScript

angular.module('App', [])
.config(['$tooltipProvider', function($tooltipProvider) {

	$tooltipProvider.setTriggers({
		'keypress': 'mouseleave',
		'click': 'click',
		'focus': 'blur',
		'never': 'mouseleave'
  	});
}])
.controller('HeaderCtrl', ['$scope', function($scope) {
$scope.quickLookup = function() {
		UnitDetails.get({
			sn: $scope.model.sn,
			packList: true,
			testLatest: true,
			repair: true,
			history: true
		}, function(data) {
			var modalInstance = $modal.open({
				templateUrl: 'header/quick-lookup/quick-lookup.tpl.html',
				controller: 'QuickLookupCtrl',
				backdrop: true,
				windowClass: 'modal',
				resolve: {
					unitDetail: function() {
						return data;
					},
				}
			});
			modalInstance.result.then(function() {
				$scope.model.sn = undefined;	// The user hit OK: done with the look-up, let's clear the search box.
				$scope.model.popoverText = undefined;
			}, function() {
				$scope.model.sn = undefined;	// The user clicked outside of the modal: done with the look-up, let's clear the search box.
				$scope.model.popoverText = undefined;
			});
		}, function(data) {
			$scope.model.popoverText = "SN: "+ $scope.model.sn + " is not found";
		});
	};
}]);