diff --git a/apps/common/locale.js b/apps/common/locale.js
index 9cf5cbf96..d954165fc 100644
--- a/apps/common/locale.js
+++ b/apps/common/locale.js
@@ -38,7 +38,8 @@ Common.Locale = new(function() {
"use strict";
var l10n = null;
var loadcallback,
- apply = false;
+ apply = false,
+ currentLang = 'en';
var _applyLocalization = function(callback) {
try {
@@ -78,6 +79,10 @@ Common.Locale = new(function() {
return res || (scope ? eval(scope.name).prototype[prop] : '');
};
+ var _getCurrentLanguage = function() {
+ return (currentLang || 'en');
+ };
+
var _getUrlParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
@@ -87,9 +92,11 @@ Common.Locale = new(function() {
var _requireLang = function () {
var lang = (_getUrlParameterByName('lang') || 'en').split(/[\-_]/)[0];
+ currentLang = lang;
fetch('locale/' + lang + '.json')
.then(function(response) {
if (!response.ok) {
+ currentLang = 'en';
if (lang != 'en')
/* load default lang if fetch failed */
return fetch('locale/en.json');
@@ -130,7 +137,8 @@ Common.Locale = new(function() {
return {
apply: _applyLocalization,
- get: _get
+ get: _get,
+ getCurrentLanguage: _getCurrentLanguage
};
})();
diff --git a/apps/common/main/lib/component/CheckBox.js b/apps/common/main/lib/component/CheckBox.js
index 019c1013f..c42f26253 100644
--- a/apps/common/main/lib/component/CheckBox.js
+++ b/apps/common/main/lib/component/CheckBox.js
@@ -94,7 +94,8 @@ define([
checked : false,
value : 'unchecked',
- template : _.template(''),
+ template : _.template(''),
initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
@@ -106,19 +107,19 @@ define([
render: function (parentEl) {
var me = this;
if (!me.rendered) {
+ var elem = this.template({
+ labelText: this.options.labelText,
+ id: Common.UI.getId('chb-')
+ });
if (parentEl) {
this.setElement(parentEl, false);
- parentEl.html(this.template({
- labelText: this.options.labelText
- }));
+ parentEl.html(elem);
} else {
- me.$el.html(this.template({
- labelText: this.options.labelText
- }));
+ me.$el.html(elem);
}
- this.$chk = me.$el.find('input[type=button]');
- this.$label = me.$el.find('label');
+ this.$chk = me.$el.find('input[type=checkbox]');
+ this.$label = me.$el.find('label.checkbox-indeterminate');
this.$chk.on('click', this.onItemCheck.bind(this));
this.rendered = true;
@@ -166,18 +167,18 @@ define([
this.checked = (value === true || value === 'true' || value === '1' || value === 1 || value === 'checked');
this.indeterminate = (value === 'indeterminate');
- this.$chk.toggleClass('checked', this.checked);
- this.$chk.toggleClass('indeterminate', this.indeterminate);
-
this.value = this.indeterminate ? 'indeterminate' : (this.checked ? 'checked' : 'unchecked');
+ this.$chk.prop({indeterminate: this.indeterminate, checked: this.checked});
},
setValue: function(value, suspendchange) {
if (this.rendered) {
- this.lastValue = this.value;
- this.setRawValue(value);
- if (suspendchange !== true && this.lastValue !== value)
- this.trigger('change', this, this.value, this.lastValue);
+ if ( value != this.value ) {
+ this.lastValue = this.value;
+ this.setRawValue(value);
+ if (suspendchange !== true)
+ this.trigger('change', this, this.value, this.lastValue);
+ }
} else {
this.options.value = value;
}
diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js
index bd4229d95..6f27af0a2 100644
--- a/apps/common/main/lib/component/ComboBox.js
+++ b/apps/common/main/lib/component/ComboBox.js
@@ -355,6 +355,7 @@ define([
return false;
}
else if (e.keyCode == Common.UI.Keys.ESC && this.isMenuOpen()) {
+ this._input.val(this.lastValue);
this.closeMenu();
this.onAfterHideMenu(e);
return false;
@@ -420,6 +421,7 @@ define([
var me = this;
if (e.keyCode == Common.UI.Keys.ESC){
+ this._input.val(this.lastValue);
this.closeMenu();
this.onAfterHideMenu(e);
} else if (e.keyCode == Common.UI.Keys.UP || e.keyCode == Common.UI.Keys.DOWN) {
diff --git a/apps/common/main/lib/component/Menu.js b/apps/common/main/lib/component/Menu.js
index 6d0d0bd92..e5ee14ebc 100644
--- a/apps/common/main/lib/component/Menu.js
+++ b/apps/common/main/lib/component/Menu.js
@@ -523,7 +523,7 @@ define([
menuParent = this.menuAlignEl || menuRoot.parent(),
m = this.menuAlign.match(/^([a-z]+)-([a-z]+)/),
offset = menuParent.offset(),
- docW = Common.Utils.innerWidth(),
+ docW = Common.Utils.innerWidth() - 10,
docH = Common.Utils.innerHeight() - 10, // Yep, it's magic number
menuW = menuRoot.outerWidth(),
menuH = menuRoot.outerHeight(),
diff --git a/apps/common/main/lib/component/MetricSpinner.js b/apps/common/main/lib/component/MetricSpinner.js
index 673847da4..81cf96b1d 100644
--- a/apps/common/main/lib/component/MetricSpinner.js
+++ b/apps/common/main/lib/component/MetricSpinner.js
@@ -145,7 +145,12 @@ define([
if (!this.options.allowDecimal)
el.on('keypress', '.form-control', _.bind(this.onKeyPress, this));
el.on('focus', 'input.form-control', function() {
- me.$input && me.$input.select();
+ setTimeout(function(){me.$input && me.$input.select();}, 1);
+ });
+ Common.Utils.isGecko && el.on('blur', 'input.form-control', function() {
+ setTimeout(function(){
+ me.$input && (me.$input[0].selectionStart = me.$input[0].selectionEnd = 0);
+ }, 1);
});
this.switches = {
@@ -359,6 +364,9 @@ define([
} else {
this._fromKeyDown = true;
}
+
+ if (e.keyCode == Common.UI.Keys.ESC)
+ this.setRawValue(this.value);
if (e.keyCode==Common.UI.Keys.RETURN || e.keyCode==Common.UI.Keys.ESC)
this.trigger('inputleave', this);
},
diff --git a/apps/common/main/lib/component/RadioBox.js b/apps/common/main/lib/component/RadioBox.js
index 39fdcb585..b26e23aa8 100644
--- a/apps/common/main/lib/component/RadioBox.js
+++ b/apps/common/main/lib/component/RadioBox.js
@@ -71,7 +71,8 @@ define([
disabled : false,
rendered : false,
- template : _.template('<%= labelText %>'),
+ template : _.template('' +
+ '<%= labelText %>'),
initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
@@ -96,11 +97,12 @@ define([
var el = this.$el || $(this.el);
el.html(this.template({
labelText: this.options.labelText,
- name: this.name
+ name: this.name,
+ id: Common.UI.getId('rdb-')
}));
- this.$radio = el.find('input[type=button]');
- this.$label = el.find('label');
+ this.$radio = el.find('input[type=radio]');
+ this.$label = el.find('label.radiobox');
this.rendered = true;
return this;
@@ -129,8 +131,9 @@ define([
setRawValue: function(value) {
var value = (value === true || value === 'true' || value === '1' || value === 1 );
- $('input[type=button][name=' + this.name + ']').removeClass('checked');
+ $('input[type=radio][name=' + this.name + ']').removeClass('checked');
this.$radio.toggleClass('checked', value);
+ this.$radio.prop('checked', value);
},
setValue: function(value, suspendchange) {
@@ -138,14 +141,14 @@ define([
var lastValue = this.$radio.hasClass('checked');
this.setRawValue(value);
if (suspendchange !== true && lastValue !== value)
- this.trigger('change', this, this.$radio.hasClass('checked'));
+ this.trigger('change', this, this.$radio.is(':checked'));
} else {
this.options.checked = value;
}
},
getValue: function() {
- return this.$radio.hasClass('checked');
+ return this.$radio.is(':checked');
},
setCaption: function(text) {
diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js
index 44e58de0b..9b77da678 100644
--- a/apps/common/main/lib/component/TabBar.js
+++ b/apps/common/main/lib/component/TabBar.js
@@ -123,183 +123,6 @@ define([
}
},
- setAbsTabs: function () {
- var me = this, tab = null, length = this.bounds.length;
-
- for (var i = 0; i < length; ++i) {
- tab = me.bar.tabs[i].$el;
- tab.css('position', 'absolute');
- tab.css('left', (me.bounds[i].left - me.tabBarLeft - this.scrollLeft) + 'px');
-
- if (tab.hasClass('active')) {
- tab.css('top', '1px');
- } else {
- tab.css('top', '0px');
- }
- }
- },
-
- updatePositions: function () {
- this.drag.place = undefined;
-
- var i, tabBound, center, place = -1, next = -this.scrollLeft,
- tabsCount = this.bounds.length,
- dragBound = this.drag.tab.$el.get(0).getBoundingClientRect();
-
- if (this.drag.moveX - this.drag.mouseX > 0) {
- for (i = tabsCount - 1; i >= 0; --i) {
- tabBound = this.bounds[i];
- center = (tabBound.right + tabBound.left) * 0.5;
- if (dragBound.left < center && center < dragBound.right) {
- place = i;
- break;
- }
- }
-
- if (-1 === place) {
- for (i = tabsCount - 1; i >= 0; --i) {
- tabBound = dragBound;
- center = (tabBound.right + tabBound.left) * 0.5;
- if (this.bounds[i].left < center && center < this.bounds[i].right) {
- place = i;
- break;
- }
- }
- }
-
- } else {
- for (i = 0; i < tabsCount; ++i) {
- tabBound = this.bounds[i];
- center = (tabBound.right + tabBound.left) * 0.5;
- if (dragBound.left < center && center < dragBound.right) {
- place = i;
- break;
- }
- }
-
- if (-1 === place) {
- for (i = 0; i < tabsCount; ++i) {
- tabBound = dragBound;
- center = (tabBound.right + tabBound.left) * 0.5;
- if (this.bounds[i].left < center && center < this.bounds[i].right) {
- place = i;
- break;
- }
- }
- }
- }
-
- if (-1 !== place) {
-
- this.drag.place = place;
-
- for (i = 0; i < tabsCount; ++i) {
- if (i === place) {
- if (place < this.drag.index) {
- next += this.drag.tabWidth;
- }
- }
-
- if (place > this.drag.index) {
- if (i === place + 1) {
- next += this.drag.tabWidth;
- }
- }
-
- if (i !== this.drag.index) {
- this.bar.tabs[i].$el.css('left', next + 'px');
- } else {
- if (this.drag.index === place) {
- next += this.drag.tabWidth;
- }
-
- continue;
- }
-
- next += this.bounds[i].width;
- }
- }
- },
-
- setHook: function(e, bar, tab) {
- var me = this;
-
- function dragComplete() {
- if (!_.isUndefined(me.drag)) {
- me.drag.tab.removeClass('dragged');
- me.drag.tab.$el.css('z-index', '');
- me.bar.dragging = false;
- var tab = null;
- for (var i = me.bar.tabs.length - 1; i >= 0; --i) {
- tab = me.bar.tabs[i].$el;
- if (tab) {
- tab.css('top', '');
- tab.css('position', '');
- tab.css('left', '');
- }
- }
-
- if (!_.isUndefined(me.drag.place)) {
- me.bar.trigger('tab:move', me.drag.index, me.drag.place);
- me.bar.$bar.scrollLeft(me.scrollLeft);
- me.bar.scrollX = undefined;
- } else {
- me.bar.trigger('tab:move', me.drag.index);
- me.bar.$bar.scrollLeft(me.scrollLeft);
- me.bar.scrollX = undefined;
- }
-
- me.drag = undefined;
- }
- }
-
- function dragMove (e) {
- if (!_.isUndefined(me.drag)) {
- me.drag.moveX = e.clientX*Common.Utils.zoom();
- var leftPos = Math.max(me.drag.moveX - me.drag.anchorX - me.tabBarLeft - me.scrollLeft, 0);
- leftPos = Math.min(leftPos, me.tabBarRight - me.tabBarLeft - me.drag.tabWidth - me.scrollLeft);
-
- me.drag.tab.$el.css('left', leftPos + 'px');
- me.drag.tab.$el.css('z-index','100');
-
- me.updatePositions();
- }
- }
-
- function dragDropText (e) { // disable firefox drag&drop
- e.preventDefault();
- }
-
- if (!_.isUndefined(bar) && !_.isUndefined(tab) && bar.tabs.length > 1) {
- tab.addClass('dragged');
-
- var index = bar.tabs.indexOf(tab),
- _clientX = e.clientX*Common.Utils.zoom();
- me.bar = bar;
- me.drag = {tab: tab, index: index};
- bar.dragging = true;
-
- this.calculateBounds();
- this.setAbsTabs();
-
- me.drag.moveX = _clientX;
- me.drag.mouseX = _clientX;
- me.drag.anchorX = _clientX - this.bounds[index].left;
- me.drag.tabWidth = this.bounds[index].width;
-
- document.addEventListener('dragstart',dragDropText);
-
- $(document).on('mousemove.tabbar', dragMove);
- $(document).on('mouseup.tabbar', function (e) {
- dragComplete(e);
- $(document).off('mouseup.tabbar');
- $(document).off('mousemove.tabbar');
-
- document.removeEventListener('dragstart',dragDropText);
- });
- }
- },
-
setHookTabs: function (e, bar, tabs) {
var me = this;
function dragComplete() {
@@ -410,11 +233,9 @@ define([
mousedown: $.proxy(function (e) {
if (this.bar.options.draggable && !_.isUndefined(dragHelper) && (3 !== e.which)) {
if (!tab.isLockTheDrag) {
- if (this.bar.selectTabs.length > 1) {
- dragHelper.setHookTabs(e, this.bar, this.bar.selectTabs);
- } else {
- dragHelper.setHook(e, this.bar, tab);
- }
+ if (!e.ctrlKey && !e.metaKey && !e.shiftKey)
+ tab.changeState();
+ dragHelper.setHookTabs(e, this.bar, this.bar.selectTabs);
}
}
}, this)
diff --git a/apps/common/main/lib/component/Window.js b/apps/common/main/lib/component/Window.js
index e90270a40..0f4583993 100644
--- a/apps/common/main/lib/component/Window.js
+++ b/apps/common/main/lib/component/Window.js
@@ -601,6 +601,9 @@ define([
this.$window = $('#' + this.initConfig.id);
+ if (Common.Locale.getCurrentLanguage() !== 'en')
+ this.$window.attr('applang', Common.Locale.getCurrentLanguage());
+
this.binding.keydown = _.bind(_keydown,this);
// $(document).on('keydown', this.binding.keydown);
diff --git a/apps/common/main/lib/util/utils.js b/apps/common/main/lib/util/utils.js
index 2268d5764..50e6430b7 100644
--- a/apps/common/main/lib/util/utils.js
+++ b/apps/common/main/lib/util/utils.js
@@ -123,20 +123,19 @@ Common.Utils = _.extend(new(function() {
// считаем: 0 < window.devicePixelRatio < 2 => _devicePixelRatio = 1; zoom = window.devicePixelRatio / _devicePixelRatio;
// считаем: window.devicePixelRatio >= 2 => _devicePixelRatio = 2; zoom = window.devicePixelRatio / _devicePixelRatio;
if (window.devicePixelRatio > 0.1) {
- var _fraction = window.devicePixelRatio % 1;
- var _devicePixelRatio = Math.floor(window.devicePixelRatio);
-
- if ( !(_fraction < .5) ) {
- _devicePixelRatio += .5;
+ if (window.devicePixelRatio < 1.99)
+ {
+ var _devicePixelRatio = 1;
+ me.zoom = window.devicePixelRatio / _devicePixelRatio;
}
-
- me.zoom = window.devicePixelRatio / _devicePixelRatio;
- document.firstElementChild.style.zoom = 1.0 / me.zoom;
-
- if ( _devicePixelRatio % 1 > 0 )
- $('#editor_sdk').css('zoom', 1.0 / _devicePixelRatio);
- else $('#editor_sdk').css('zoom', '');
- }
+ else
+ {
+ var _devicePixelRatio = 2;
+ me.zoom = window.devicePixelRatio / _devicePixelRatio;
+ }
+ // chrome 54.x: zoom = "reset" - clear retina zoom (windows)
+ //document.firstElementChild.style.zoom = "reset";
+ document.firstElementChild.style.zoom = 1.0 / me.zoom; }
else
document.firstElementChild.style.zoom = "normal";
}
diff --git a/apps/common/main/lib/view/LanguageDialog.js b/apps/common/main/lib/view/LanguageDialog.js
index cee215f17..efd4bf487 100644
--- a/apps/common/main/lib/view/LanguageDialog.js
+++ b/apps/common/main/lib/view/LanguageDialog.js
@@ -86,13 +86,13 @@ define([
template: _.template([
'',
'',
- '',
+ '',
'',
'