|
|
@ -1,86 +1,82 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
/* global bootbox, translator */
|
|
|
|
/* global bootbox */
|
|
|
|
|
|
|
|
|
|
|
|
var overrides = overrides || {};
|
|
|
|
var overrides = overrides || {};
|
|
|
|
|
|
|
|
|
|
|
|
if ('undefined' !== typeof window) {
|
|
|
|
if ('undefined' !== typeof window) {
|
|
|
|
|
|
|
|
|
|
|
|
(function ($, undefined) {
|
|
|
|
(function ($, undefined) {
|
|
|
|
var translator;
|
|
|
|
require(['translator'], function(translator) {
|
|
|
|
require(['translator'], function(_translator) {
|
|
|
|
$.fn.getCursorPosition = function() {
|
|
|
|
translator = _translator;
|
|
|
|
var el = $(this).get(0);
|
|
|
|
});
|
|
|
|
var pos = 0;
|
|
|
|
|
|
|
|
if('selectionStart' in el) {
|
|
|
|
$.fn.getCursorPosition = function() {
|
|
|
|
pos = el.selectionStart;
|
|
|
|
var el = $(this).get(0);
|
|
|
|
} else if('selection' in document) {
|
|
|
|
var pos = 0;
|
|
|
|
el.focus();
|
|
|
|
if('selectionStart' in el) {
|
|
|
|
var Sel = document.selection.createRange();
|
|
|
|
pos = el.selectionStart;
|
|
|
|
var SelLength = document.selection.createRange().text.length;
|
|
|
|
} else if('selection' in document) {
|
|
|
|
Sel.moveStart('character', -el.value.length);
|
|
|
|
el.focus();
|
|
|
|
pos = Sel.text.length - SelLength;
|
|
|
|
var Sel = document.selection.createRange();
|
|
|
|
|
|
|
|
var SelLength = document.selection.createRange().text.length;
|
|
|
|
|
|
|
|
Sel.moveStart('character', -el.value.length);
|
|
|
|
|
|
|
|
pos = Sel.text.length - SelLength;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.selectRange = function(start, end) {
|
|
|
|
|
|
|
|
if(!end) {
|
|
|
|
|
|
|
|
end = start;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.each(function() {
|
|
|
|
|
|
|
|
if (this.setSelectionRange) {
|
|
|
|
|
|
|
|
this.focus();
|
|
|
|
|
|
|
|
this.setSelectionRange(start, end);
|
|
|
|
|
|
|
|
} else if (this.createTextRange) {
|
|
|
|
|
|
|
|
var range = this.createTextRange();
|
|
|
|
|
|
|
|
range.collapse(true);
|
|
|
|
|
|
|
|
range.moveEnd('character', end);
|
|
|
|
|
|
|
|
range.moveStart('character', start);
|
|
|
|
|
|
|
|
range.select();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return pos;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element
|
|
|
|
$.fn.selectRange = function(start, end) {
|
|
|
|
$.fn.putCursorAtEnd = function() {
|
|
|
|
if(!end) {
|
|
|
|
return this.each(function() {
|
|
|
|
end = start;
|
|
|
|
$(this).focus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.setSelectionRange) {
|
|
|
|
|
|
|
|
var len = $(this).val().length * 2;
|
|
|
|
|
|
|
|
this.setSelectionRange(len, len);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(this).val($(this).val());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.scrollTop = 999999;
|
|
|
|
return this.each(function() {
|
|
|
|
});
|
|
|
|
if (this.setSelectionRange) {
|
|
|
|
};
|
|
|
|
this.focus();
|
|
|
|
|
|
|
|
this.setSelectionRange(start, end);
|
|
|
|
$.fn.translateHtml = function(str) {
|
|
|
|
} else if (this.createTextRange) {
|
|
|
|
return translate(this, 'html', str);
|
|
|
|
var range = this.createTextRange();
|
|
|
|
};
|
|
|
|
range.collapse(true);
|
|
|
|
|
|
|
|
range.moveEnd('character', end);
|
|
|
|
$.fn.translateText = function(str) {
|
|
|
|
range.moveStart('character', start);
|
|
|
|
return translate(this, 'text', str);
|
|
|
|
range.select();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.translateVal = function(str) {
|
|
|
|
|
|
|
|
return translate(this, 'val', str);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function translate(elements, type, str) {
|
|
|
|
|
|
|
|
return elements.each(function() {
|
|
|
|
|
|
|
|
var el = $(this);
|
|
|
|
|
|
|
|
translator.translate(str, function(translated) {
|
|
|
|
|
|
|
|
el[type](translated);
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element
|
|
|
|
|
|
|
|
$.fn.putCursorAtEnd = function() {
|
|
|
|
|
|
|
|
return this.each(function() {
|
|
|
|
|
|
|
|
$(this).focus();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.setSelectionRange) {
|
|
|
|
|
|
|
|
var len = $(this).val().length * 2;
|
|
|
|
|
|
|
|
this.setSelectionRange(len, len);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$(this).val($(this).val());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.scrollTop = 999999;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.translateHtml = function(str) {
|
|
|
|
|
|
|
|
return translate(this, 'html', str);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.translateText = function(str) {
|
|
|
|
|
|
|
|
return translate(this, 'text', str);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$.fn.translateVal = function(str) {
|
|
|
|
|
|
|
|
return translate(this, 'val', str);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function translate(elements, type, str) {
|
|
|
|
|
|
|
|
return elements.each(function() {
|
|
|
|
|
|
|
|
var el = $(this);
|
|
|
|
|
|
|
|
translator.translate(str, function(translated) {
|
|
|
|
|
|
|
|
el[type](translated);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
})(jQuery || {fn:{}});
|
|
|
|
})(jQuery || {fn:{}});
|
|
|
|
|
|
|
|
|
|
|
|
(function(){
|
|
|
|
(function(){
|
|
|
@ -107,43 +103,40 @@ if ('undefined' !== typeof window) {
|
|
|
|
})();
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
overrides.overrideBootbox = function () {
|
|
|
|
overrides.overrideBootbox = function () {
|
|
|
|
var dialog = bootbox.dialog,
|
|
|
|
require(['translator'], function(translator) {
|
|
|
|
prompt = bootbox.prompt,
|
|
|
|
var dialog = bootbox.dialog,
|
|
|
|
confirm = bootbox.confirm;
|
|
|
|
prompt = bootbox.prompt,
|
|
|
|
|
|
|
|
confirm = bootbox.confirm;
|
|
|
|
var translator;
|
|
|
|
|
|
|
|
require(['translator'], function(_translator) {
|
|
|
|
function translate(modal) {
|
|
|
|
translator = _translator;
|
|
|
|
var header = modal.find('.modal-header'),
|
|
|
|
});
|
|
|
|
footer = modal.find('.modal-footer');
|
|
|
|
|
|
|
|
translator.translate(header.html(), function(html) {
|
|
|
|
function translate(modal) {
|
|
|
|
header.html(html);
|
|
|
|
var header = modal.find('.modal-header'),
|
|
|
|
});
|
|
|
|
footer = modal.find('.modal-footer');
|
|
|
|
translator.translate(footer.html(), function(html) {
|
|
|
|
translator.translate(header.html(), function(html) {
|
|
|
|
footer.html(html);
|
|
|
|
header.html(html);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
translator.translate(footer.html(), function(html) {
|
|
|
|
|
|
|
|
footer.html(html);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.dialog = function() {
|
|
|
|
|
|
|
|
var modal = $(dialog.apply(this, arguments)[0]);
|
|
|
|
|
|
|
|
translate(modal);
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.prompt = function() {
|
|
|
|
|
|
|
|
var modal = $(prompt.apply(this, arguments)[0]);
|
|
|
|
|
|
|
|
translate(modal);
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.confirm = function() {
|
|
|
|
bootbox.dialog = function() {
|
|
|
|
var modal = $(confirm.apply(this, arguments)[0]);
|
|
|
|
var modal = $(dialog.apply(this, arguments)[0]);
|
|
|
|
translate(modal);
|
|
|
|
translate(modal);
|
|
|
|
return modal;
|
|
|
|
return modal;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.prompt = function() {
|
|
|
|
|
|
|
|
var modal = $(prompt.apply(this, arguments)[0]);
|
|
|
|
|
|
|
|
translate(modal);
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bootbox.confirm = function() {
|
|
|
|
|
|
|
|
var modal = $(confirm.apply(this, arguments)[0]);
|
|
|
|
|
|
|
|
translate(modal);
|
|
|
|
|
|
|
|
return modal;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
overrides.overrideTimeago = function() {
|
|
|
|
overrides.overrideTimeago = function() {
|
|
|
|