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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                
<main ng-app="WikiApp" ng-controller="MainCtrl">
  <div class="wrapper fullHeight" id="search">
    <a class="white-text random" href="https://en.wikipedia.org/wiki/Special:Random" 
       target="_blank">Click here for a random article</a><br/>
    <form class="white-text" ng-submit="search()">
      <input type="text" ng-model="searchTxt" ng-click="changeCloseBtn(); deleteFocus()" />
      <a ng-class = "closeBtn" ng-click="btnClose(); deleteFocus()" class = "close"></a>
    </form>
    <p class="white-text" id="help">Click in form box to search</p>
  </div>
  <div class="wrapper" id="wrapper">
    <ul>
        <a ng-href="{{result.page}}" target="_blank" ng-repeat="result in results">
          <li>
            <h1>{{result.title}}</h1>
            <div class="wrapper-left">
              <img width="120px" height="100%" src={{result.image}} >
              <p>{{result.body}}<br><span>Source: {{result.page}}</span></p>
            </div>
          </li>
        </a>
    </ul>
  </div>
</main>
              
            
!

CSS

              
                @import "bourbon";

@import url(https://fonts.googleapis.com/css?family=Rokkitt:700);

// Colors
$blue: #092B40;
$lightBlue: #85DEF2;
$water: #52A5D9;
$sky: #5BB5D9;
$orange: #D96F32;

* { 
  box-sizing: border-box;
}

html, body, main {
  font-family: "Lucida Grande","Lucida Sans Unicode", Tahoma, Sans-Serif;
  margin: 10px; padding: 0;
  padding-top: 10px;
  width: 98%; height: 90%;
  background-color: $blue;
}

form {
  margin-top: 60px;
  margin-bottom: 10px;
  width: 320px;
}

form::before {
  font-family: "FontAwesome";
  content: "\f002";
  font-size: 1.6rem;
  margin-right: 10px;
  border: 2px solid #fff;
  padding: 10px;
  border-radius: 40px;
}

input[type='text'] {
  -webkit-appearance: none;
  outline: none;
  border: none;
  border-radius: 6px;
  padding: 10px;
  width: 250px;
}

.wrapper {
  display: flex;
  width: 100%;
  @include display(flex);
	@include flex-direction(column);
	@include align-items(center);
	@include justify-content(center);
  @include transition(all 2s linear);
}

.wrapper-left {
  display: flex;
  width: 100%;
  @include display(flex);
	@include flex-direction(row);
	@include align-items(left);
	@include justify-content(left);
  @include transition(all 2s linear);
}

.fullHeight { 
  height: 100%; 
  @include transition-duration(2s);
}

.white-text {
  color: white;
  text-decoration: none;
}

.random::before {
  font-family: "FontAwesome";
  content: "\f074";
  font-size: 1.6rem;
  margin-right: 10px;
  border: 2px solid #fff;
  padding: 10px;
  border-radius: 40px;
}

ul {
  margin-left: 0; padding-left: 0;
  width: 80%;
  
  a {
    text-decoration: none;
    color: black;
    
    h1 {
      font-size: 18px;
    }
    p {
      font-size: 14px;
      margin: 0px;
      margin-bottom: 10px;
    }
    span {
      font-weight:bold;
      font-size: 0.8rem;
      font-style: italic;
    }
    img {
      margin-right: 20px;
    }
  }
  li {
    list-style-type: none;
    display: block;
    margin-bottom: 10px;
    padding: 15px 30px 15px 30px;
    background-color: #E7E7E8;
    opacity: 0;
    @include animation(new-item 1s ease-in-out forwards);
    @include transition-timing-function(cubic-bezier(0.6, 0, 0.4, 1.0));
    border-radius: 10px;

    &:hover {
      border-left: 5px solid $orange;
      margin-left: -5px;
      background-color: $lightBlue;
    }
  }
}

@include keyframes(new-item) {
  0% { opacity: 0; 
    -webkit-transform: translateY(2000px); }
  80% { opacity: 0; }
  100% { opacity: 1;
    -webkit-transform: translateY(0); }
}

.closeBtnVisible {
  margin-left: 280px;
  margin-top: -30px;
  cursor: pointer;
  visibility: visible;
  display: block;
}

.closeBtnVisible::before {
  font-family: "FontAwesome";
  content: "\f057";
  font-size: 1.6rem;
  color: $blue;
}

.closeBtnInvisible {
   margin-left:-30px;
}

.invisible {
   display: none;
}
              
            
!

JS

              
                var app = angular.module('WikiApp', ['ngAnimate']);

app.controller('MainCtrl', function($scope, $http, $timeout) {
  var form = $('form');
  var input = $('input');

  var search = $("#search");
  var searchTxt = $("searchTxt");
  var wrapper = $("#wrapper");
  var search = $("#search");
  var close = $('.close');
  var urlImg = 'https://commons.wikimedia.org/wiki/Special:FilePath/'
  
  $scope.searchTxt = "Type a word and press enter";
  $scope.closeBtn = "closeBtnInvisible";
  
  $scope.changeCloseBtn = function(){
    if ($scope.closeBtn === "closeBtnInvisible")
      $scope.closeBtn = "closeBtnVisible";
    else
      $scope.closeBtn = "closeBtnInvisible";
  };
  
  $scope.deleteFocus = function(){
    if ($scope.searchTxt === "Type a word and press enter")
      $scope.searchTxt = "";
    else
      $scope.searchTxt = "Type a word and press enter";
  };
  
  $scope.btnClose = function(){
    if ($scope.closeBtn === "closeBtnVisible")
      $scope.closeBtn = "closeBtnInvisible";
    else
      $scope.closeBtn = "closeBtnVisible";
  };
  
  close.on('click', function() {
    wrapper.addClass("invisible");
    search.addClass("fullHeight");
  })
  
  $scope.results = [];

  $scope.search = function() {
    $scope.results = [];
    search.removeClass('fullHeight');
    
    var title = input.val();
    var api = 'https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=';
    var cb = '&callback=JSON_CALLBACK';
    var page = 'https://en.wikipedia.org/?curid=';
    
    wrapper.removeClass("invisible"); 
    
    $http.jsonp(api + title + cb).success(function(data) {
      if (typeof data.query == "undefined" || $scope.searchTxt == ''){
        console.log(data.query + " undefined");
        $scope.searchTxt = "Please, insert a legible word";
        $scope.closeBtn = "closeBtnInvisible";
        
        $scope.deleteFocus = function(){
          if ($scope.searchTxt === "Please, insert a legible word" || $scope.searchTxt === "Type a word and press enter"){
            $scope.searchTxt = "";
          } else {
            $scope.searchTxt = "Type a word and press enter";}
        };
        
        $scope.btnClose = function(){
          if ($scope.closeBtn === "closeBtnVisible")
            $scope.closeBtn = "closeBtnInvisible";
          else
            $scope.closeBtn = "closeBtnVisible";
        };
      }        
      
      var results = data.query.pages;
      
      angular.forEach(results, function(v,k) {
        if (v.pageimage !== undefined) {
          urlImg = 'https://commons.wikimedia.org/wiki/Special:FilePath/'
          $scope.results.push({title: v.title, body: v.extract, page: page + v.pageid, image: urlImg + v.pageimage})
        } else {
          urlImg = 'https://myaco.lemans.org/GED/content/4805C9CE-ECF4-4232-AEF4-3580948695DC.jpg'
          $scope.results.push({title: v.title, body: v.extract, page: page + v.pageid, image: urlImg})
        }
      })
    });
  }
});
              
            
!
999px

Console