From 36a7f2cc259b62b2971c778ac562914f619eef61 Mon Sep 17 00:00:00 2001 From: Istvan Halmen Date: Tue, 15 May 2018 12:01:27 +0300 Subject: [PATCH] Merging 4.2.2 changes --- src/js/classes/frame.js | 52 ++++++++------------- src/js/classes/select.js | 13 ++---- src/js/classes/textarea.js | 12 +++-- src/js/core/core.js | 4 +- src/js/forms.angular.ts | 4 +- src/js/frameworks/angular.ts | 2 +- src/less/notifications.less | 3 +- src/less/themes/ios.notifications.less | 3 +- src/less/themes/material.notifications.less | 3 +- 9 files changed, 42 insertions(+), 54 deletions(-) diff --git a/src/js/classes/frame.js b/src/js/classes/frame.js index fbad8157..a0d438e7 100644 --- a/src/js/classes/frame.js +++ b/src/js/classes/frame.js @@ -1,7 +1,6 @@ import { $, extend, Base, mobiscroll, classes, instances } from '../core/core'; import { os, majorVersion, isBrowser, userAgent } from '../util/platform'; import { animEnd } from '../util/dom'; -import { getCoord, preventClick } from '../util/tap'; import { constrain, isString, noop } from '../util/misc'; var $activeElm, @@ -221,6 +220,12 @@ export const Frame = function (el, settings, inherit) { $markup .on('selectstart mousedown', prevdef) // Prevents blue highlight on Android and text selection in IE .on('click', '.mbsc-fr-btn-e', prevdef) + .on('touchstart mousedown', function (ev) { + // Need this to prevent opening of sidemenus or similar + if (s.stopProp) { + ev.stopPropagation(); + } + }) .on('keydown', '.mbsc-fr-btn-e', function (ev) { if (ev.keyCode == 32) { // Space ev.preventDefault(); @@ -811,37 +816,20 @@ export const Frame = function (el, settings, inherit) { } if (s.closeOnOverlayTap) { - var moved, - target, - startX, - startY; - - $overlay - .on('touchstart mousedown', function (ev) { - if (!target && ev.target == $overlay[0]) { - target = true; - moved = false; - startX = getCoord(ev, 'X'); - startY = getCoord(ev, 'Y'); - } - }) - .on('touchmove mousemove', function (ev) { - if (target && !moved && (Math.abs(getCoord(ev, 'X') - startX) > 9 || Math.abs(getCoord(ev, 'Y') - startY) > 9)) { - moved = true; - } - }) - .on('touchcancel', function () { - target = false; - }) - .on('touchend touchcancel mouseup', function (ev) { - if (target && !moved) { - that.cancel(); - if (ev.type != 'mouseup') { - preventClick(); - } - } - target = false; - }); + var target; + + $overlay.on('touchstart mousedown', function (ev) { + target = ev.target == overlay; + }).on('mouseup', function (ev) { + target = target && ev.target == overlay; + }); + + that.tap(overlay, function (ev) { + if (target && ev.target == overlay) { + that.cancel(); + } + target = false; + }); } } diff --git a/src/js/classes/select.js b/src/js/classes/select.js index 832e54ca..c8035ee3 100644 --- a/src/js/classes/select.js +++ b/src/js/classes/select.js @@ -11,6 +11,7 @@ export class Select extends Input { const $input = $existing.length ? $existing : $(''); this._$input = $input; + this._setText = this._setText.bind(this); $parent.addClass('mbsc-select' + (this._$frame ? ' mbsc-select-inline' : '')); @@ -20,7 +21,7 @@ export class Select extends Input { // Check if select and mobiscroll select was not initialized if (!$elm.hasClass('mbsc-comp')) { - elm.addEventListener('change', this); + $elm.on('change', this._setText); this._setText(); } } @@ -28,15 +29,7 @@ export class Select extends Input { destroy() { super.destroy(); this._$parent.find('.mbsc-select-ic').remove(); - this._elm.removeEventListener('change', this); - } - - handleEvent(ev) { - super.handleEvent(ev); - - if (ev.type == 'change') { - this._setText(); - } + this._$elm.off('change', this._setText); } _setText() { diff --git a/src/js/classes/textarea.js b/src/js/classes/textarea.js index 423f7537..cb396c84 100644 --- a/src/js/classes/textarea.js +++ b/src/js/classes/textarea.js @@ -28,7 +28,7 @@ function sizeTextArea(control) { lineNr = Math.round(height / 24); if (lineNr > rowNr) { - control.scrollTop = height; + //control.scrollTop = height; height = 24 * rowNr + (height - lineNr * 24); $(control).addClass('mbsc-textarea-scroll'); } else { @@ -46,10 +46,14 @@ function scrollTextArea(elm) { if (!$elm.hasClass('mbsc-textarea-scroll')) { let line = elm.scrollHeight - elm.offsetHeight, - height = elm.offsetHeight + line; + height = elm.offsetHeight + line, + lineNr = Math.round(height / 24), + rowNr = $elm.attr('rows') || 6; - elm.scrollTop = 0; - elm.style.height = height + 'px'; + if (lineNr <= rowNr) { + elm.scrollTop = 0; + elm.style.height = height + 'px'; + } } } diff --git a/src/js/core/core.js b/src/js/core/core.js index 32488ce3..635493de 100644 --- a/src/js/core/core.js +++ b/src/js/core/core.js @@ -1,5 +1,5 @@ /*! - * Mobiscroll v4.2.1 + * Mobiscroll v4.2.2 * http://mobiscroll.com * * Copyright 2010-2018, Acid Media @@ -69,7 +69,7 @@ extend(util, { ms = extend(mobiscroll, { $: $, - version: '4.2.1', + version: '4.2.2', autoTheme: 'mobiscroll', themes: { form: {}, diff --git a/src/js/forms.angular.ts b/src/js/forms.angular.ts index 28ff014f..3515fdcf 100644 --- a/src/js/forms.angular.ts +++ b/src/js/forms.angular.ts @@ -123,7 +123,7 @@ export class MbscFormBase extends MbscBase implements OnInit { } export class MbscFormValueBase extends MbscFormBase implements ControlValueAccessor { - protected _value: any; + _value: any; set innerValue(v: any) { this._value = v; @@ -908,7 +908,7 @@ export class MbscRadioGroupBase extends MbscFormValueBase { this._radioService.changeValue(v); } - constructor(hostElement: ElementRef, @Optional() formService: MbscOptionsService, protected _radioService: MbscRadioService, control: NgControl) { + constructor(hostElement: ElementRef, @Optional() formService: MbscOptionsService, public _radioService: MbscRadioService, control: NgControl) { super(hostElement, formService, control, null); this._radioService.onValueChanged().subscribe(v => { this.innerValue = v; diff --git a/src/js/frameworks/angular.ts b/src/js/frameworks/angular.ts index f169dcd9..75d18ca7 100644 --- a/src/js/frameworks/angular.ts +++ b/src/js/frameworks/angular.ts @@ -177,7 +177,7 @@ class MbscBase implements AfterViewInit, OnDestroy { } } - constructor(protected initialElem: ElementRef) { } + constructor(public initialElem: ElementRef) { } /* AfterViewInit Interface */ diff --git a/src/less/notifications.less b/src/less/notifications.less index b490fbd9..21694765 100644 --- a/src/less/notifications.less +++ b/src/less/notifications.less @@ -116,7 +116,8 @@ } &.mbsc-toast .mbsc-toast-msg { - background: rgba(120, 120, 120, .9); + background: #787878; + opacity: .9; border-radius: .5em; color: #fff; } diff --git a/src/less/themes/ios.notifications.less b/src/less/themes/ios.notifications.less index 334bed81..96aee851 100644 --- a/src/less/themes/ios.notifications.less +++ b/src/less/themes/ios.notifications.less @@ -45,9 +45,10 @@ /* Toast */ &.mbsc-toast .mbsc-toast-msg { - background: rgba(100, 100, 100, .9); + background: #646464; border-radius: .5em; color: #fff; + opacity: .9; } /* Snackbar and Toast color presets */ diff --git a/src/less/themes/material.notifications.less b/src/less/themes/material.notifications.less index 7eecb3db..5f8d5982 100644 --- a/src/less/themes/material.notifications.less +++ b/src/less/themes/material.notifications.less @@ -17,7 +17,8 @@ /* Toast */ &.mbsc-toast .mbsc-toast-msg { - background: rgba(80, 80, 80, .9); + background: #505050; + opacity: .9; border-radius: 1.571429em; color: #fff; }