Procházet zdrojové kódy

Add slide effect to hidden information.

tags/v1.0^2
Benjamin Attal před 12 roky
rodič
revize
fa148237c5
2 změnil soubory, kde provedl 53 přidání a 55 odebrání
  1. +20
    -25
      static/js/index.js
  2. +33
    -30
      static/sass/index.sass

+ 20
- 25
static/js/index.js Zobrazit soubor

@@ -35,15 +35,6 @@ var testCodelet = {
'language': 'Python', 'language': 'Python',
'date_created': 'May 10, 2014', 'date_created': 'May 10, 2014',
'date_modified': '2 days ago', 'date_modified': '2 days ago',
'symbols': {
'vars': [
['app', [ [12, -1, 12, -1] ],
[ [13, -1, 13, -1],
[15, -1, 15, -1],
[16, -1, 16, -1],
[17, -1, 17, -1] ]]
]
},
'origin': ['GitHub', 'https://github.com', ''], 'origin': ['GitHub', 'https://github.com', ''],
'authors': ['sevko', 'earwig'], 'authors': ['sevko', 'earwig'],
'html_code': codeExample 'html_code': codeExample
@@ -146,14 +137,15 @@ function createResult(codelet) {
var displayInfo = document.createElement("div"), var displayInfo = document.createElement("div"),
sidebar = document.createElement("td"), sidebar = document.createElement("td"),
codeElt = document.createElement("td"), codeElt = document.createElement("td"),
hiddenInfo = document.createElement("td");
displayButton = document.createElement("td"),
hiddenInfoContainer = document.createElement("td"),
hiddenInfo = document.createElement("div");
//Level 3 //Level 3
var title = document.createElement("span"), var title = document.createElement("span"),
site = document.createElement("span"), site = document.createElement("span"),
dateModified = document.createElement("span"), dateModified = document.createElement("span"),
language = document.createElement("span"), language = document.createElement("span"),
dateCreated = document.createElement("span"), dateCreated = document.createElement("span"),
matches = document.createElement("div"),
authors = document.createElement("div"); authors = document.createElement("div");


//Classes and ID's //Classes and ID's
@@ -162,6 +154,7 @@ function createResult(codelet) {
displayInfo.id = 'display-info'; displayInfo.id = 'display-info';
sidebar.id = 'sidebar'; sidebar.id = 'sidebar';
codeElt.id = 'code'; codeElt.id = 'code';
displayButton.id = 'display-button';
hiddenInfo.id = 'hidden-info'; hiddenInfo.id = 'hidden-info';


title.id = 'title'; title.id = 'title';
@@ -169,7 +162,6 @@ function createResult(codelet) {
dateModified.id = 'date-modified'; dateModified.id = 'date-modified';
language.id = 'language'; language.id = 'language';
dateCreated.id = 'date-created'; dateCreated.id = 'date-created';
matches.id = 'matches';
authors.id = 'authors'; authors.id = 'authors';


//Add the bulk of the html //Add the bulk of the html
@@ -180,35 +172,38 @@ function createResult(codelet) {
// Needs to be changed from int to string on the server // Needs to be changed from int to string on the server
language.innerHTML = codelet.language; language.innerHTML = codelet.language;
dateCreated.innerHTML = 'Created ' + codelet.date_created; dateCreated.innerHTML = 'Created ' + codelet.date_created;
matches.innerHTML = 'Symbol matches: ';
$.each(Object.keys(codelet.symbols), function(i, t) {
$.each(codelet.symbols[t], function(i, s) {
matches.innerHTML += '<span>' + s[0] + '</span>';
});
});
authors.innerHTML = 'Authors: '; authors.innerHTML = 'Authors: ';
$.each(codelet.authors, function(i, a) { $.each(codelet.authors, function(i, a) {
authors.innerHTML += '<span>' + a + '; </span>';
authors.innerHTML += '<a href=#>' + a + '; </a>';
}); });


sidebar.innerHTML = ''; sidebar.innerHTML = '';
// Needs to be processed on the server // Needs to be processed on the server
codeElt.innerHTML = '<div id=tablecontainer>' + codelet.html_code + '</div>'; codeElt.innerHTML = '<div id=tablecontainer>' + codelet.html_code + '</div>';


//Event binding
$(displayButton).click(function(e) {
$(hiddenInfo).toggleClass('visible');
$(this).toggleClass('active');
});

//Finish and append elements to parent elements //Finish and append elements to parent elements
hiddenInfo.appendChild(dateCreated);
hiddenInfo.appendChild(dateModified);
hiddenInfo.appendChild(authors);
hiddenInfo.appendChild(language);

hiddenInfoContainer.appendChild(hiddenInfo);

row.appendChild(sidebar); row.appendChild(sidebar);
row.appendChild(codeElt); row.appendChild(codeElt);
row.appendChild(hiddenInfo);
row.appendChild(hiddenInfoContainer);
row.appendChild(displayButton);
table.appendChild(row); table.appendChild(row);


displayInfo.appendChild(title); displayInfo.appendChild(title);
displayInfo.appendChild(site); displayInfo.appendChild(site);


hiddenInfo.appendChild(dateCreated);
hiddenInfo.appendChild(language);
hiddenInfo.appendChild(matches);
hiddenInfo.appendChild(authors);

newDiv.appendChild(displayInfo); newDiv.appendChild(displayInfo);
newDiv.appendChild(table); newDiv.appendChild(table);




+ 33
- 30
static/sass/index.sass Zobrazit soubor

@@ -9,7 +9,7 @@ $minSearchFieldsWidth: 490px
$resultWidth: 830px $resultWidth: 830px
$sidebarWidth: 30px $sidebarWidth: 30px
$codeWidth: 500px $codeWidth: 500px
$hiddenInfoWidth: 300px
$hiddenInfoWidth: 250px


.ui-datepicker .ui-datepicker
font-size: 70% font-size: 70%
@@ -291,16 +291,9 @@ div#results
- Add way to cycle through hits in the code. - Add way to cycle through hits in the code.
2) Hidden info 2) Hidden info
- Use effect to make it transition into view. - Use effect to make it transition into view.
- Add date modified.
- Get rid of symbols matches.
- Don't use monospace.
- Add links for authors. - Add links for authors.
- Cross out search terms based on what's in the codelet.
3) Header 3) Header
- Remove date modified.
- Make the title bigger.
- Add an icon for the website. - Add an icon for the website.
- Change the spacing.
4) Code body 4) Code body
- Add highlighting.*/ - Add highlighting.*/
div.result div.result
@@ -310,6 +303,8 @@ div#results
margin-bottom: 6% margin-bottom: 6%


#display-info #display-info
font-size: 1.2em

a a
text-decoration: none text-decoration: none


@@ -317,16 +312,11 @@ div#results
color: orange color: orange


#title #title
margin-right: 50px
margin-right: 10px


#site #site
text-transform: capitalize text-transform: capitalize


#date-modified
font-style: italic
color: #777
display: block

table table
border-collapse: collapse border-collapse: collapse
border: 1px solid #ccc border: 1px solid #ccc
@@ -335,9 +325,6 @@ div#results
tr tr
height: inherit height: inherit


td
overflow: scroll

#sidebar #sidebar
width: $sidebarWidth width: $sidebarWidth
background-color: #eee background-color: #eee
@@ -361,33 +348,49 @@ div#results
border: none border: none
font-family: monospace font-family: monospace


#display-button
width: 25px
background: url(http://icons.iconarchive.com/icons/visualpharm/icons8-metro-style/512/Image-Edition-Tools-Arrow-icon.png)
background-size: 25px 25px
background-repeat: no-repeat
background-position: center

&:hover
background-color: #eee

&.active
@include vendor(transform, rotateY(180deg))

#hidden-info #hidden-info
width: $hiddenInfoWidth width: $hiddenInfoWidth
margin-left: -$hiddenInfoWidth
height: 100%
padding-top: 25px
text-align: center text-align: center
font-size: 1.2em font-size: 1.2em
font-family: monospace
line-height: 1.5em
@include vendor(transition, margin-left 0.2s ease-in-out)

&.visible
margin-left: 0px


#date-created #date-created
display: inline-block

#date-modified
display: block display: block


#language #language
display: inline-block display: inline-block
padding: 3px
@include vendor(border-radius, 3px)
background-color: #eee
font-weight: bold font-weight: bold
color: purple color: purple


&:hover
background-color: #ddd

#matches
span
color: red

#authors #authors
span
color: red
a
text-decoration: none

&:hover
color: orange


&.cascade &.cascade
@extend .t3 @extend .t3

Načítá se…
Zrušit
Uložit