diff options
author | Bart Visscher <bartv@thisnet.nl> | 2014-01-31 16:43:12 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2014-01-31 16:43:12 +0100 |
commit | bca725dc32e159d756f023d428816b8f9821b732 (patch) | |
tree | c3e1910e952728433c2572cea96fa8024c79d1d5 /core/js/js.js | |
parent | 09d2ba017e603fe6ac237da7830d86d74b2da61c (diff) | |
parent | 271088a7a23ffcdb2082b6dfc5b6f50833612a0f (diff) | |
download | nextcloud-server-bca725dc32e159d756f023d428816b8f9821b732.tar.gz nextcloud-server-bca725dc32e159d756f023d428816b8f9821b732.zip |
Merge branch 'master' into setup
Conflicts:
core/setup.php
Diffstat (limited to 'core/js/js.js')
-rw-r--r-- | core/js/js.js | 85 |
1 files changed, 64 insertions, 21 deletions
diff --git a/core/js/js.js b/core/js/js.js index b7f7ff1ac15..1c7d89ea055 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -12,7 +12,14 @@ var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('dat var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken'); if (typeof oc_webroot === "undefined") { - oc_webroot = location.pathname.substr(0, location.pathname.lastIndexOf('/')); + oc_webroot = location.pathname; + var pos = oc_webroot.indexOf('/index.php/'); + if (pos !== -1) { + oc_webroot = oc_webroot.substr(0, pos); + } + else { + oc_webroot = oc_webroot.substr(0, oc_webroot.lastIndexOf('/')); + } } if (oc_debug !== true || typeof console === "undefined" || typeof console.log === "undefined") { if (!window.console) { @@ -41,8 +48,8 @@ function initL10N(app) { t.cache[app] = []; } } - if (typeof t.plural_function == 'undefined') { - t.plural_function = function (n) { + if (typeof t.plural_function[app] == 'undefined') { + t.plural_function[app] = function (n) { var p = (n != 1) ? 1 : 0; return { 'nplural' : 2, 'plural' : p }; }; @@ -67,7 +74,7 @@ function initL10N(app) { Gettext._locale_data[domain].head.plural_func = eval("("+code+")"); */ var code = 'var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) };'; - t.plural_function = new Function("n", code); + t.plural_function[app] = new Function("n", code); } else { console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]"); } @@ -103,6 +110,10 @@ function t(app, text, vars, count){ } } t.cache = {}; +// different apps might or might not redefine the nplurals function correctly +// this is to make sure that a "broken" app doesn't mess up with the +// other app's plural function +t.plural_function = {}; /** * translate a string @@ -115,11 +126,11 @@ t.cache = {}; */ function n(app, text_singular, text_plural, count, vars) { initL10N(app); - var identifier = '_' + text_singular + '__' + text_plural + '_'; + var identifier = '_' + text_singular + '_::_' + text_plural + '_'; if( typeof( t.cache[app][identifier] ) !== 'undefined' ){ var translation = t.cache[app][identifier]; if ($.isArray(translation)) { - var plural = t.plural_function(count); + var plural = t.plural_function[app](count); return t(app, translation[plural.plural], vars, count); } } @@ -242,6 +253,12 @@ var OC={ return link; }, /** + * Redirect to the target URL, can also be used for downloads. + */ + redirect: function(targetUrl) { + window.location = targetUrl; + }, + /** * get the absolute path to an image file * @param app the app id to which the image belongs * @param file the name of the image file @@ -353,6 +370,34 @@ var OC={ } return result; }, + + /** + * Builds a URL query from a JS map. + * @param params parameter map + * @return string containing a URL query (without question) mark + */ + buildQueryString: function(params) { + var s = ''; + var first = true; + if (!params) { + return s; + } + for (var key in params) { + var value = params[key]; + if (first) { + first = false; + } + else { + s += '&'; + } + s += encodeURIComponent(key); + if (value !== null && typeof(value) !== 'undefined') { + s += '=' + encodeURIComponent(value); + } + } + return s; + }, + /** * Opens a popup with the setting for an app. * @param appid String. The ID of the app e.g. 'calendar', 'contacts' or 'files'. @@ -405,6 +450,9 @@ var OC={ throw e; }); } + if(!SVGSupport()) { + replaceSVG(); + } }).show(); }, 'html'); } @@ -471,11 +519,11 @@ OC.Breadcrumb={ }, _show:function(container, dir, leafname, leaflink){ var self = this; - + this._clear(container); - + // show home + path in subdirectories - if (dir && dir !== '/') { + if (dir) { //add home var link = OC.linkTo('files','index.php'); @@ -502,7 +550,7 @@ OC.Breadcrumb={ } }); } - + //add leafname if (leafname && leaflink) { this._push(container, leafname, leaflink); @@ -746,15 +794,7 @@ $(document).ready(function(){ }); var setShowPassword = function(input, label) { - input.showPassword().keyup(function(){ - if (input.val().length == 0) { - label.hide(); - } - else { - label.css("display", "inline").show(); - } - }); - label.hide(); + input.showPassword().keyup(); }; setShowPassword($('#adminpass'), $('label[for=show]')); setShowPassword($('#pass2'), $('label[for=personal-show]')); @@ -833,7 +873,10 @@ function humanFileSize(size) { order = Math.min(humanList.length - 1, order); var readableFormat = humanList[order]; var relativeSize = (size / Math.pow(1024, order)).toFixed(1); - if(relativeSize.substr(relativeSize.length-2,2)=='.0'){ + if(order < 2){ + relativeSize = parseFloat(relativeSize).toFixed(0); + } + else if(relativeSize.substr(relativeSize.length-2,2)==='.0'){ relativeSize=relativeSize.substr(0,relativeSize.length-2); } return relativeSize + ' ' + readableFormat; @@ -941,7 +984,7 @@ jQuery.fn.selectRange = function(start, end) { */ jQuery.fn.exists = function(){ return this.length > 0; -} +}; /** * Calls the server periodically every 15 mins to ensure that session doesnt |