Giter VIP home page Giter VIP logo

template's Introduction

template

A class-based user interface development framework.

It is super brilliant! It is really simple to work with your framework. I am really your fan ;) – Dmitri Dudin

CSS

.layer

Layers are absolutely positioned elements that fill their parents' width and height, and are used to create screens behind popups and loading icons, among other things. Layers inherit their parent's border-radius so to avoid sharp corners over parents that have rounded corners.

Popdowns, dropdowns, tabs and slides

Popdowns, dropdowns, tabs and slides are class-based ui elements with two states. When they are visible, they have the class active. When they are not, they don't.

They share a common API for triggering active state. Firstly, they are activated when the user clicks on a link that refers to them by id:

<a href="#id_of_dropdown">Open dropdown</a>

Secondly, they can also be activated and deactivated programmatically:

jQuery('.dropdown').eq(2).trigger('activate');
jQuery('.dropdown').eq(2).trigger('deactivate');

Links that refer to popdowns, dropdowns, tabs and slides are also given the class active, making it easy to create stateful buttons. Transitions to and from active state are defined using CSS transitions.

Creating a popdown, dropdown, set of tabs or a slide is as easy as adding a class to a node. Here we add the class popdown to a div:

<a href="#arthur">Open dropdown</a>
<div class="popdown" id="arthur">
	<p>Ford, there is an infinite number of monkeys outside, who want to
	talk to us about this script for Hamlet they have worked out.</p>
</div>

In addition to the common functionality, each of these ui classes has some specific behaviour.

.dropdown

Dropdowns are used to make menus and navigation. Once active, they deactivate when the user touches or mousedowns outside them, or when the user clicks on or inside them.

.popdown

Popdowns are used to make menus, drawers, and elements that require explicit deactivation. Once active, they deactivate when the user touches or mousedowns outside them, or when a #close link is clicked inside them:

<a href="#close">Close</a>

.tab
.slide

Tabs and slides are functionally identical. Two classes are provided for convenience, as tabs and slides tend to be styled very differently. Where we refer to 'tabs' below, assume that we also mean slides.

In any group of tabs, only one can be active at any one time. Normally, all .tab or .slide siblings of the tab or slide currently being activated automatically become a group.

To be more explicit, the grouping can be overridden with a data-selector attribute containing a selector for all other tabs in the group. The selector can be any that jQuery understands. Here are two tabs grouped using a data-selector attribute:

<div class="quote_tab tab" id="ford" data-selector=".quote_tab">
	<p>Time is an illusion. Lunchtime, doubly so.</p>
</div

><div class="quote_tab tab" id="zaphod" data-selector=".quote_tab">
	<p>I'm a great and amazing guy, didn't I tell you baby?</p>
</div>

Of course, this means you can create tab groups from non-sibling elements. A little care must be taken, however; all tabs in a group must share the same data-selector: a tab can only belong to one group, and if it is inadvertently selected by another group it will cause some odd behaviour.

Inside tabs and slides, a couple of special links can be used for navigation:

<a href="#prev">Previous slide</a>
<a href="#next">Next slide</a>

…navigating backwards and forwards through the group respectively.

jQuery

Template extends jQuery with events and methods.

activate event

Popdowns, dropdowns, tabs and slides are all activated by triggering the jQuery special event activate. The definition of this event can be found in js/jquery.event.activate.js. By default, the activate event adds the class active to the element it is triggered on, plus any links that reference that element's id via their href attribute.

The activate event greatly simplifies the code needed to make dropdowns and tabs respond both to user actions and programmatically. Using the activate event as an abstraction, the code that makes dropdowns, popdowns, tabs and slides respond to user events can be found in js/template.ui.js.

.addLoadingIcon()

Inserts a .loading_layer with a canvas-animated loading icon into the first element in the collection.

.removeLoadingIcon()

Removes a loading icon from the first element in the current collection. It is important to use this method to cancel loading layers created with .addLoadingIcon() as it also cleans up the animation timer.

.addTransitionClass(class [, fn || options])

Adds the class class. Analogous to .addClass(), only during a CSS transition caused by adding class, the class transition is also present on the node. This allows for styles that require, for example, display: none; to be applied at the end of a transition, where the class transition can be used to override the display value during the transition.

This is probably more clearly explained with a bit of CSS:

.popup_layer {
	opacity: 0;
	display: none;
	
	-webkit-transition: opacity 0.06s ease-in;
	   -moz-transition: opacity 0.06s ease-in;
	        transition: opacity 0.06s ease-in;
}

.popup_layer.active {
	opacity: 1;
	display: block;
}

.popup_layer.transition {
	display: block;
}

For more information, and description of options object, have a look at the repository github.com/stephband/jquery.transitions.

.removeTransitionClass(class [, fn || options])

As .addTransitionClass(), only it removes the class class.

For more information, and description of options object, have a look at the repository github.com/stephband/jquery.transitions.

Shims

details

master branch

A base template as used for webdoc.

app branch

Template for creating app iframes.

inspector branch

Template for creating inspector iframes.

template's People

Contributors

stephband avatar

Stargazers

 avatar  avatar Rashaad Essop avatar  avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.