Skip to content

Commit

Permalink
Merging 4.4.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dioslaska committed Sep 28, 2018
1 parent cd78ca8 commit 7551454
Show file tree
Hide file tree
Showing 82 changed files with 5,803 additions and 3,040 deletions.
676 changes: 146 additions & 530 deletions examples/angular/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@angular/platform-browser": "^5.2.11",
"@angular/platform-browser-dynamic": "^5.2.11",
"@angular/router": "^5.2.11",
"@mobiscroll/angular-lite": "^4.3.2",
"@mobiscroll/angular-lite": "^4.4.0",
"core-js": "^2.5.7",
"rxjs": "^5.5.11",
"zone.js": "^0.8.26"
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<mbsc-page>
<mbsc-form>
<mbsc-form label-style="floating">
<div class="mbsc-form-group">
<div class="mbsc-form-group-title">Account information</div>
<mbsc-input [(ngModel)]="firstName" placeholder="What's your first name?">First Name</mbsc-input>
Expand Down Expand Up @@ -48,4 +48,4 @@
<mbsc-button>Save Settings</mbsc-button>
</div>
</mbsc-form>
</mbsc-page>
</mbsc-page>
8 changes: 4 additions & 4 deletions examples/kitchen-sink/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
<div class="mbsc-col-sm-6">
<label>
First Name
<input type="text" id="first" placeholder="What's your first name?" />
<input type="text" id="first" data-label-style="floating" placeholder="What's your first name?" />
</label>
<label>
Last Name
<input type="text" id="last" placeholder="What's your last name?" />
<input type="text" id="last" data-label-style="floating" placeholder="What's your last name?" />
</label>
</div>
<div class="mbsc-col-sm-6">
<label>
Email
<input type="email" id="email" placeholder="[email protected]" />
<input type="email" id="email" data-label-style="floating" placeholder="[email protected]" />
</label>
<label>
Password
<input type="password" id="password" placeholder="Minimum 6 characters" data-password-toggle="true" />
<input type="password" id="password" data-label-style="floating" placeholder="Minimum 6 characters" data-password-toggle="true" />
</label>
</div>
</div>
Expand Down
39 changes: 27 additions & 12 deletions examples/react/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@mobiscroll/react-lite": "^4.3.2",
"@mobiscroll/react-lite": "^4.4.0",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-scripts": "^1.1.4"
Expand Down
22 changes: 5 additions & 17 deletions examples/react/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Page, Form, Rating, Stepper, Switch } from '@mobiscroll/react-lite';
import { Page, Form, Rating, Stepper, Switch, Input } from '@mobiscroll/react-lite';
import '@mobiscroll/react-lite/dist/css/mobiscroll.min.css';
import logo from './logo.svg';
import './App.css';
Expand All @@ -17,22 +17,10 @@ class App extends Component {
<Form>
<div className="mbsc-form-group">
<div className="mbsc-form-group-title">Account information</div>
<label>
First Name
<input type="text" placeholder="What's your first name?" />
</label>
<label>
Last Name
<input type="text" placeholder="What's your last name?" />
</label>
<label>
Email
<input type="email" placeholder="[email protected]" />
</label>
<label>
Password
<input type="password" placeholder="Minimum 6 characters" data-password-toggle="true" />
</label>
<Input type="text" placeholder="What's your first name?" labelStyle="floating">First Name</Input>
<Input type="text" placeholder="What's your last name?" labelStyle="floating">Last Name</Input>
<Input type="email" placeholder="[email protected]" labelStyle="floating">Email</Input>
<Input type="password" placeholder="Minimum 6 characters" labelStyle="floating" passwordToggle={true}>Password</Input>
<Rating value={4}>
Rating
</Rating>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobiscroll",
"version": "4.3.2",
"version": "4.4.0",
"description": "Cross platform UI controls for progressive web an hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobiscroll/angular-lite",
"version": "4.3.2",
"version": "4.4.0",
"description": "Angular UI library for progressive web and hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/angularjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobiscroll/angularjs-lite",
"version": "4.3.2",
"version": "4.4.0",
"description": "AngularJS UI library for progressive web and hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobiscroll/javascript-lite",
"version": "4.3.2",
"version": "4.4.0",
"description": "Framework agnostic UI library for progressive web and hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jquery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobiscroll/jquery-lite",
"version": "4.3.2",
"version": "4.4.0",
"description": "jQuery and jQuery Mobile UI library for progressive web and hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobiscroll/react-lite",
"version": "4.3.2",
"version": "4.4.0",
"description": "React UI library for progressive web and hybrid apps",
"homepage": "https://mobiscroll.com/",
"license": "Apache-2.0",
Expand Down
20 changes: 17 additions & 3 deletions src/js/classes/form-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ function addIconToggle(that, $parent, $control) {
}
}

function wrapLabel($parent, type) {
function wrapLabel($parent, type, inputStyle, labelStyle, elm) {
// Wrap non-empty text nodes in span with mbsc-label class
if (type != 'button' && type != 'submit' && type != 'segmented') {
$parent
.addClass('mbsc-control-w')
.addClass(inputStyle == 'box' ? 'mbsc-input-box' : '')
.addClass(inputStyle == 'outline' ? 'mbsc-input-outline' : '')
.addClass(labelStyle == 'inline' ? 'mbsc-label-inline' : '')
.addClass(labelStyle == 'stacked' ? 'mbsc-label-stacked' : '')
.addClass(labelStyle == 'floating' ? 'mbsc-label-floating' : '')
.addClass(labelStyle == 'floating' && elm.value ? 'mbsc-label-floating-active' : '')
.find('label')
.addClass('mbsc-label')
.each(function (i, v) {
Expand Down Expand Up @@ -110,22 +116,28 @@ function getRipple(theme) {
return ripple && ripple.addRipple ? ripple : null;
}

function getAttr($elm, attr, def) {
var v = $elm.attr(attr);
return v === undefined || v === '' ? def : v;
}

export class FormControl {
constructor(elm, settings) {

const s = extend({}, defaults, mobiscroll.settings, settings);
const $elm = $(elm);
const $p = $elm.parent();
const $parent = $p.hasClass('mbsc-input-wrap') ? $p.parent() : $p;
// Check for inline mobiscroll components
const $frame = $elm.next().hasClass('mbsc-fr') ? $elm.next() : null;
const type = getControlType($elm);
const inputStyle = getAttr($elm, 'data-input-style', s.inputStyle);
const labelStyle = getAttr($elm, 'data-label-style', s.labelStyle);

if ($frame) {
$frame.insertAfter($parent);
}

wrapLabel($parent, type);
wrapLabel($parent, type, inputStyle, labelStyle, elm);

$elm.addClass('mbsc-control');

Expand All @@ -143,6 +155,7 @@ export class FormControl {
this._$parent = $parent;
this._$frame = $frame;
this._ripple = getRipple(s.theme);
this._isFloating = labelStyle == 'floating' || $parent.hasClass('mbsc-label-floating');

elm.mbscInst = this;
}
Expand Down Expand Up @@ -175,6 +188,7 @@ export class FormControl {
case 'mouseup':
case 'mouseleave':
this._onEnd(ev);
break;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/js/classes/forms.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Base, MbscCoreOptions } from '../core/core';

export interface MbscFormOptions extends MbscCoreOptions { }
export interface MbscFormOptions extends MbscCoreOptions {
inputStyle?: string;
labelStyle?: string;
}

export class Form extends Base {
settings: MbscFormOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/js/classes/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export const Frame = function (el, settings, inherit) {
$wnd.on(posEvents, onPosition);

if (isModal) {
$markup.removeClass('mbsc-fr-pos');
if (doAnim && !prevAnim) {
$markup
.addClass('mbsc-anim-in mbsc-anim-trans mbsc-anim-trans-' + doAnim)
Expand Down Expand Up @@ -500,7 +501,6 @@ export const Frame = function (el, settings, inherit) {
css.left = Math.floor(left);

$popup.css(css);
$markup.removeClass('mbsc-fr-pos');

wndWidth = newWidth;
wndHeight = newHeight;
Expand Down
45 changes: 45 additions & 0 deletions src/js/classes/input.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,52 @@
import { FormControl, addIconToggle } from './form-control';

const events = ['focus', 'change', 'blur'];

export class Input extends FormControl {
constructor(elm, settings) {
super(elm, settings);

addIconToggle(this, this._$parent, this._$elm);
this._$parent.addClass('mbsc-input');

// Attach events
// Prevent 300ms click latency
events.forEach(ev => {
elm.addEventListener(ev, this);
});
}

handleEvent(ev) {
super.handleEvent(ev);
switch (ev.type) {
case 'focus':
this.onFocus();
break;
case 'change':
case 'blur':
this.onChange();
break;
}
}

refresh() {
this.onChange();
}

onChange() {
if (this._isFloating) {
if (!this._elm.value) {
this._$parent.removeClass('mbsc-label-floating-active');
} else {
this._$parent.addClass('mbsc-label-floating-active');
}
}
}

onFocus() {
if (this._isFloating) {
this._$parent.addClass('mbsc-label-floating-active');
}
}

destroy() {
Expand All @@ -14,5 +55,9 @@ export class Input extends FormControl {
.removeClass('mbsc-ic-left mbsc-ic-right')
.find('.mbsc-input-ic')
.remove();

events.forEach(ev => {
this._elm.removeEventListener(ev, this);
});
}
}
5 changes: 4 additions & 1 deletion src/js/classes/popup.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Frame, MbscFrameOptions } from './frame';

export interface MbscPopupOptions extends MbscFrameOptions { }
export interface MbscPopupOptions extends MbscFrameOptions {
okText?: string;
onSet?(event: { valueText?: string }, inst: any): void;
}
export interface MbscWidgetOptions extends MbscPopupOptions { }

export class Popup extends Frame {
Expand Down
Loading

0 comments on commit 7551454

Please sign in to comment.