Coder Social home page Coder Social logo

designcode / mui Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 852 KB

MUI (Mobile UI) is a javascript library that let you build interface for mobile. The best thing about this library is, its damn easy to modify the look and feel of the UI.

License: MIT License

JavaScript 100.00%

mui's Introduction

MUI

MUI (Mobile UI) is a JavaScript library to easily make UIs for Mobile Devices.

Overview

There are already comprehensive libraries like jQuery mobile and Sencha Touch, so why another library? This library is written for designers and keeps the design layer totally separate from code.

Demo

http://designcode.me/mui/examples/index.html

Getting Started

MUI comes with base.css, this is the file where the structure of elements is defined. You play with look and feel of the UI in your separate CSS file. MUI uses jQuery for DOM manipulation. You must include latest copy of jQuery in your html.

Usage

First you must include jquery and mui.js in your html

<script type="text/javascript" src="js/jquery-latest.js"></script>
<script type="text/javascript" src="js/mui.js"></script>

Initializing

ui = new MUI(PATHTOCSS, YOURCSSFILE);

PATHTOCSS is the path where you have put base.css and your css file. YOURCSSFILE is the css file where you have made look and feel changes. MUI loads css files dynamically so you must wait until loading is completed before doing any operation. MUI comes with onReady method.

ui = new MUI('css', 'ios.css');
ui.onReady(function () {
	// Lets build some mobile ui here
	// All the example code below, that needs to be put within this function
});

Viewport

Viewport is a rectangle that touches the corner of your browser/mobile screen or the element provided in parameter. All the elements are encapsulate within viewport.

viewport = ui.viewPort();

Attach viewport to an existing element in document

viewport = ui.viewPort({
	ele: '#iphone'
});

Header, Body and Footer

Viewport have three components: header, body and footer. Each components have its methods and properties. Let's take a look at each one.

Header

header = viewport.header() // Creates new header
header.setTitle('MyTitle') // Set the title of title
header.setHeight(100) // Set the height of header
header.attach(someButton) // Attach a UI element to header
// OR
header = viewport.header().setTitle('MyTitle').setHeight(100).attach(someButton)

Body

body = viewport.body() // Creates new body
body.setContent(text, function () {
	// This is called when the content is set
	console.log(this.ele.get(0))
}); // Set the content (html etc) of body

Footer

footer = viewport.footer() // Creates new footer
footer.setHeight(100) // Set the height of footer
footer.attach(someButton) // Attach a UI element to footer

Other UI Elements

MUI comes with following UI elements. Please note that header, footer, body and all the UI elements support method chainability.

Button

btn = ui.button(); // Creates new button
btn.setTitle('Help') // Set button title
btn.setPosition('right') // Set button position
btn.click(function () {
	console.log(arguments, 'clicked 2');
}); // What happens when button is clicked

header.attach(btn) // Attach the button we just created to header

Form Elements

form = ui.form('Jump In'); // Creates new form and set heading to "Jump In"
form.fieldSet(form.label('Nick'), form.textField('nick', {id: 'nick'})); // Create a new fieldset with label and a text field
form.fieldSet(form.label('Nick'), form.seletBox('country', {id: 'country_list'}, 'Pakistan')); // Create a new fieldset with label and a select box (with Pakistan as selected country)

Lists

list = ui.list(); // Creates new list
l1 = list.add('ITEM 1') // Adds new item "ITEM 1" in list
l2 = list.add('ITEM 2', {
	click: function () {
		console.log(this);
	}
}); // Adds new item "ITEM 2" in list, also attach onclick handler to that item

list.add('ITEM 2.1', {}, l2) // Adds new item "ITEM 2.1" as child of ITEM 2 in list
list_html = list.html() // Gets the HTML of list we prepared above
list_object = list.get() // Gets the list object we prepared above

Slides

Slides are basically segments of page, only one visible at a time.

slides = ui.slides(); // Creates new slide
slides.add('Slide 1') // Adds new slide
slides.add('Slide 2') // Adds new slide
slides.add('Slide 3') // Adds new slide
slides.moveTo(2) // Makes the 2nd slide appear on screen
slide_object = slides.get(); // Gets the slide object we prepared above

Tabs

tabs = ui.tabs(); // Creates new tab
tabs.add('Tab 1', {
	click: function () {
		console.log('Tab 1 Clicked');
	}
}) // Adding more tab and attaching onclick handler to that tab
tabs.add('Tab 2').add('Tab 3').add('Tab 4').add('Tab 5').add('Tab 6'); // Adding more tabs

tabs.hook(slides.get()) // Hooking the slides with tabs, so clicking the tabs will change the slides

TODO

Icons, List Binding and apparently a lot :)

mui's People

Contributors

designcode avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.