Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    
    <title>Pertoo SearchBar</title>

    <link href="https://code.ionicframework.com/1.0.0-beta.7/css/ionic.css" rel="stylesheet">
    <script src="https://code.ionicframework.com/1.0.0-beta.7/js/ionic.bundle.js"></script>
  </head>

<body ng-app="starter" ng-controller="MainCtrl">
<ion-nav-view></ion-nav-view>
</body>

      <script id="noMenuState.html" type="text/ng-template">
        <ion-nav-bar class="bar-stable nav-title-slide-ios7"></ion-nav-bar>
        <ion-nav-view name="noMenuView" animation="slide-left-right"></ion-nav-view>
      </script>
      
      <script id="simplePage" type="text/ng-template">
        <ion-view title="Simple Page">
          <search-bar ng-model="search"></search-bar>
          <ion-content class="padding">
            <p>Simple page with no menu system.</p>
            <div class="button" ui-sref="app.state1">Back to Menu View</div>
            <div class="button" ui-sref="noMenu.simplePage2">Another Simple Page</div>
          </ion-content>
        </ion-view>
      </script>

      <script id="simplePage2" type="text/ng-template">
        <ion-view title="Simple Page 2">
          <ion-content class="padding">
            <p>Simple page 2 with no menu system.</p>
            <div class="button" ui-sref="noMenu.simplePage">Back to Simple Page 1</button>
          </ion-content>
        </ion-view>
      </script>
      
<script id="main.html" type="text/ng-template">
    <ion-side-menus>

        <ion-pane ion-side-menu-content>
            <ion-nav-bar class="bar-stable nav-title-slide-ios7">
                <ion-nav-buttons side="left">
                    <button class="button button-icon button-clear ion-navicon" ng-click="toggleLeft()">
                    </button>
                </ion-nav-buttons>

                <ion-nav-back-button class="button-clear"><i class="icon ion-chevron-left"></i> Back</ion-nav-back-button>

            </ion-nav-bar>
            <ion-nav-view name="menuContent" animation="slide-left-right"></ion-nav-view>
        </ion-pane>

        <ion-side-menu side="left">
            <header class="bar bar-header bar-stable">
                <h1 class="title">Left</h1>
            </header>
            <ion-content class="has-header">
                <ul class="list">
                    <a ui-sref="app.state1" menu-toggle="left" nav-clear class="item">State 1</a>
                    <a ui-sref="app.state2" menu-toggle="left" nav-clear class="item">State2</a>
                </ul>
            </ion-content>
        </ion-side-menu>
      
      <ion-side-menu side="right">
            <header class="bar bar-header bar-stable">
                <h1 class="title">Right</h1>
            </header>
            <ion-content class="has-header">
                <ion-nav-view name="right-menu"></ion-nav-view>
            </ion-content>
        </ion-side-menu>      

    </ion-side-menus>

</script>

<script id="state-1-center.html" type="text/ng-template">
    <ion-view title="State 1 Center">
      <search-bar ng-model="search"></search-bar>
        <ion-content class="has-header padding">
            <p>This is state 1</p>
          <p>Searchabled items:</p>
          <ul>
            <li ng-repeat="d in data|filter:search.txt">{{d}}</li>
          </ul>
          <br/><br/>
          <div class="button" ui-sref="noMenu.simplePage">Go To Simple Page</div>
        </ion-content>
    </ion-view>
</script>

<script id="state-2-center.html" type="text/ng-template">
    <ion-view title="State 2 Center">
        <ion-content class="has-header padding">
            <p>This is state 2</p>
        </ion-content>
    </ion-view>
</script>

<script id="state-1-right.html" type="text/ng-template">
    <p>Right Side State 1</p>
</script>

<script id="state-2-right.html" type="text/ng-template">
    <p>Right Side State 2</p>
</script>
</html>

              
            
!

CSS

              
                /* ------- SEARCH ----*/
.searchBar {
	color: #fff;
	margin: 0 !important;
	padding: 0;
}
.searchBar .icon {
	font-size: 27px;
	line-height: 1.2;
	padding-right: 6px;
	padding-left: 6px;
}
.searchBar .searchTxt {
	border-bottom: 1px solid #fff;
	left: 55px;
	width: calc(100% - 100px);
	position: fixed;
	height: calc(100% - 10px);
}
.searchBar.numicons2 .searchTxt {
	width: calc(100% - 135px);
}
.searchBar .searchTxt > .bgdiv {
	background-color: #aaa;
	width: 100%;
	height: 100%;
	position: absolute;
	opacity: 0.3;
}
.searchBar .searchTxt > .bgtxt {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}
.searchBar .searchTxt input {
	background-color: inherit;
	color: #fff;
	padding-left: 5px;
	padding-right:5px;
}
              
            
!

JS

              
                
angular.module('starter', ['ionic'])

    .run(function($ionicPlatform) {
        $ionicPlatform.ready(function() {
            if(window.StatusBar) {
                // org.apache.cordova.statusbar required
                StatusBar.styleDefault();
            }
        });
    })

    .config(function($stateProvider, $urlRouterProvider) {
        $stateProvider

            .state('noMenu', {
              "url" : "/noMenu",
              abstract : true,
              templateUrl : "noMenuState.html"
            })
        
            .state("noMenu.simplePage", {
              "url" : "/simplePage",
              views : {
                "noMenuView" : {
                  templateUrl : "simplePage"
                }
              }
            })

        
            .state("noMenu.simplePage2", {
              "url" : "/simplePage2",
              views : {
                "noMenuView" : {
                  templateUrl : "simplePage2"
                }
              }
            })        
            .state('app', {
                url: "/app",
                abstract: true,
                templateUrl: "main.html"
            })


            .state('app.state1', {
                url: "/state1",
                views: {
                    'menuContent' :{
                        templateUrl: "state-1-center.html",
                    },
                    'right-menu' : {
                        templateUrl : "state-1-right.html"
                    }
                }
            })

            .state('app.state2', {
                url: "/state2",
                views: {
                    'menuContent' :{
                        templateUrl: "state-2-center.html"
                    },
                    'right-menu' : {
                        templateUrl : "state-2-right.html"
                    }
                }
            })

        // if none of the above states are matched, use this as the fallback
        $urlRouterProvider.otherwise('/app/state1');
    })

    .controller('MainCtrl', function($scope, $ionicSideMenuDelegate) {
        console.log('MainCtrl');

        $scope.toggleLeft = function() {
            $ionicSideMenuDelegate.toggleLeft();
        };
      
        $scope.data=["JavaScript","Java","Ruby","Python"];
    })

.directive('searchBar', [function () {
	return {
		scope: {
			ngModel: '='
		},
		require: ['^ionNavBar', '?ngModel'],
		restrict: 'E',
		replace: true,
		template: '<ion-nav-buttons side="right">'+
						'<div class="searchBar">'+
							'<div class="searchTxt" ng-show="ngModel.show">'+
						  		'<div class="bgdiv"></div>'+
						  		'<div class="bgtxt">'+
						  			'<input type="text" placeholder="Procurar..." ng-model="ngModel.txt">'+
						  		'</div>'+
					  		'</div>'+
						  	'<i class="icon placeholder-icon" ng-click="ngModel.txt=\'\';ngModel.show=!ngModel.show"></i>'+
						'</div>'+
					'</ion-nav-buttons>',
		
		compile: function (element, attrs) {
			var icon=attrs.icon
					|| (ionic.Platform.isAndroid() && 'ion-android-search')
					|| (ionic.Platform.isIOS()     && 'ion-ios7-search')
					|| 'ion-search';
			angular.element(element[0].querySelector('.icon')).addClass(icon);
			
			return function($scope, $element, $attrs, ctrls) {
				var navBarCtrl = ctrls[0];
				$scope.navElement = $attrs.side === 'right' ? navBarCtrl.rightButtonsElement : navBarCtrl.leftButtonsElement;
				
			};
		},
		controller: ['$scope','$ionicNavBarDelegate', function($scope,$ionicNavBarDelegate){
			var title, definedClass;
			$scope.$watch('ngModel.show', function(showing, oldVal, scope) {
				if(showing!==oldVal) {
					if(showing) {
						if(!definedClass) {
							var numicons=$scope.navElement.children().length;
							angular.element($scope.navElement[0].querySelector('.searchBar')).addClass('numicons'+numicons);
						}
						
						title = $ionicNavBarDelegate.getTitle();
						$ionicNavBarDelegate.setTitle('');
					} else {
						$ionicNavBarDelegate.setTitle(title);
					}
				} else if (!title) {
					title = $ionicNavBarDelegate.getTitle();
				}
			});
		}]
	};
}])
              
            
!
999px

Console