Skip to content

Node.js based forum software built for the modern web

took out some overrides out utils to a new overrides.js

akhouryb59c10a1e979
diff --git a/public/src/overrides.js b/public/src/overrides.js
new file mode 100644
index 0000000000..df4ab27f24
--- /dev/null
+++ b/public/src/overrides.js
@@ -0,0 +1,51 @@
+if ('undefined' !== typeof window) {
+
+ (function ($, undefined) {
+ $.fn.getCursorPosition = function() {
+ var el = $(this).get(0);
+ var pos = 0;
+ if('selectionStart' in el) {
+ pos = el.selectionStart;
+ } else if('selection' in document) {
+ el.focus();
+ 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();
+ }
+ });
+ };
+
+ //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;
+ });
+ };
+
+ })(jQuery || {fn:{}});
+}
\ No newline at end of file
diff --git a/public/templates/admin/header.tpl b/public/templates/admin/header.tpl
index 6e04b32dc5..ba4ec0425c 100644
--- a/public/templates/admin/header.tpl
+++ b/public/templates/admin/header.tpl
@@ -35,9 +35,9 @@
});
</script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
+ <script src="{relative_path}/src/overrides.js"></script>
<script src="{relative_path}/src/utils.js"></script>
- <link rel="stylesheet" type="text/css" href="{relative_path}/stylesheet.css?{cache-buster}" />
</head>
<body class="admin">
diff --git a/src/meta.js b/src/meta.js
index cb8f43c3fb..f4411904fd 100644
--- a/src/meta.js
+++ b/src/meta.js
@@ -239,6 +239,7 @@ var fs = require('fs'),
'src/templates.js',
'src/ajaxify.js',
'src/translator.js',
+ 'src/overrides.js',
'src/utils.js'
],
minFile: nconf.get('relative_path') + 'nodebb.min.js',