server/core/js/js.js

1256 lines
35 KiB
JavaScript
Raw Normal View History

2012-11-15 18:43:10 +00:00
/**
* Disable console output unless DEBUG mode is enabled.
* Add
2013-02-09 16:20:08 +00:00
* define('DEBUG', true);
2012-11-15 18:43:10 +00:00
* To the end of config/config.php to enable debug mode.
2013-01-02 11:21:30 +00:00
* The undefined checks fix the broken ie8 console
2012-11-15 18:43:10 +00:00
*/
var oc_debug;
var oc_webroot;
var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user');
var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');
window.oc_config = window.oc_config || {};
2013-02-08 17:44:52 +00:00
if (typeof oc_webroot === "undefined") {
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('/'));
}
2013-02-08 17:44:52 +00:00
}
2013-01-02 11:21:30 +00:00
if (oc_debug !== true || typeof console === "undefined" || typeof console.log === "undefined") {
2012-11-15 18:43:10 +00:00
if (!window.console) {
window.console = {};
}
2014-03-17 18:39:19 +00:00
var methods = ['log', 'debug', 'warn', 'info', 'error', 'assert', 'time', 'timeEnd'];
2012-11-15 18:43:10 +00:00
for (var i = 0; i < methods.length; i++) {
2013-01-02 11:21:30 +00:00
console[methods[i]] = function () { };
2012-11-15 18:43:10 +00:00
}
}
function initL10N(app) {
if (!( t.cache[app] )) {
$.ajax(OC.filePath('core', 'ajax', 'translations.php'), {
async: false,//todo a proper solution for this without sync ajax calls
data: {'app': app},
type: 'POST',
success: function (jsondata) {
2012-01-15 23:09:43 +00:00
t.cache[app] = jsondata.data;
t.plural_form = jsondata.plural_form;
2012-09-23 01:16:52 +00:00
}
});
2011-06-19 21:33:34 +00:00
// Bad answer ...
if (!( t.cache[app] )) {
t.cache[app] = [];
2011-06-19 21:33:34 +00:00
}
}
if (typeof t.plural_function[app] == 'undefined') {
t.plural_function[app] = function (n) {
var p = (n != 1) ? 1 : 0;
return { 'nplural' : 2, 'plural' : p };
};
/**
* code below has been taken from jsgettext - which is LGPL licensed
* https://developer.berlios.de/projects/jsgettext/
* http://cvs.berlios.de/cgi-bin/viewcvs.cgi/jsgettext/jsgettext/lib/Gettext.js
*/
var pf_re = new RegExp('^(\\s*nplurals\\s*=\\s*[0-9]+\\s*;\\s*plural\\s*=\\s*(?:\\s|[-\\?\\|&=!<>+*/%:;a-zA-Z0-9_\(\)])+)', 'm');
if (pf_re.test(t.plural_form)) {
//ex english: "Plural-Forms: nplurals=2; plural=(n != 1);\n"
//pf = "nplurals=2; plural=(n != 1);";
//ex russian: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10< =4 && (n%100<10 or n%100>=20) ? 1 : 2)
//pf = "nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)";
var pf = t.plural_form;
if (! /;\s*$/.test(pf)) pf = pf.concat(';');
/* We used to use eval, but it seems IE has issues with it.
* We now use "new Function", though it carries a slightly
* bigger performance hit.
var code = 'function (n) { var plural; var nplurals; '+pf+' return { "nplural" : nplurals, "plural" : (plural === true ? 1 : plural ? plural : 0) }; };';
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[app] = new Function("n", code);
} else {
2013-08-18 09:17:28 +00:00
console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]");
}
}
}
/**
* translate a string
* @param app the id of the app for which to translate the string
* @param text the string to translate
* @param vars (optional) FIXME
* @param count (optional) number to replace %n with
* @return string
*/
function t(app, text, vars, count){
initL10N(app);
var _build = function (text, vars, count) {
return text.replace(/%n/g, count).replace(/{([^{}]*)}/g,
2013-02-09 16:20:08 +00:00
function (a, b) {
var r = vars[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
);
};
var translation = text;
if( typeof( t.cache[app][text] ) !== 'undefined' ){
translation = t.cache[app][text];
}
if(typeof vars === 'object' || count !== undefined ) {
return _build(translation, vars, count);
} else {
return translation;
2011-06-19 21:33:34 +00:00
}
}
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 = {};
2011-06-19 21:33:34 +00:00
/**
* translate a string
* @param app the id of the app for which to translate the string
* @param text_singular the string to translate for exactly one object
* @param text_plural the string to translate for n objects
* @param count number to determine whether to use singular or plural
* @param vars (optional) FIXME
* @return string
*/
function n(app, text_singular, text_plural, count, vars) {
initL10N(app);
2013-12-07 10:38:01 +00:00
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[app](count);
return t(app, translation[plural.plural], vars, count);
}
}
if(count === 1) {
return t(app, text_singular, vars, count);
}
2011-06-19 21:33:34 +00:00
else{
return t(app, text_plural, vars, count);
2011-06-19 21:33:34 +00:00
}
}
/**
2012-10-12 12:01:47 +00:00
* Sanitizes a HTML string
* @param s string
2012-10-12 12:01:47 +00:00
* @return Sanitized string
*/
function escapeHTML(s) {
return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');
2012-10-12 12:01:47 +00:00
}
2012-08-27 19:46:05 +00:00
/**
* Get the path to download a file
* @param file The filename
* @param dir The directory the file is in - e.g. $('#dir').val()
* @return string
* @deprecated use Files.getDownloadURL() instead
2012-08-27 19:46:05 +00:00
*/
function fileDownloadPath(dir, file) {
2012-10-27 13:10:21 +00:00
return OC.filePath('files', 'ajax', 'download.php')+'?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
2012-08-27 19:46:05 +00:00
}
2012-09-23 01:16:52 +00:00
var OC={
PERMISSION_CREATE:4,
PERMISSION_READ:1,
PERMISSION_UPDATE:2,
PERMISSION_DELETE:8,
PERMISSION_SHARE:16,
2013-08-13 20:58:27 +00:00
PERMISSION_ALL:31,
webroot:oc_webroot,
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
coreApps:['', 'admin','log','search','settings','core','3rdparty'],
/**
* get an absolute url to a file in an appen
* @param app the id of the app the file belongs to
* @param file the file path relative to the app folder
* @return string
*/
linkTo:function(app,file){
return OC.filePath(app,'',file);
},
/**
* Creates an url for remote use
* @param string $service id
* @return string the url
*
* Returns a url to the given service.
*/
linkToRemoteBase:function(service) {
return OC.webroot + '/remote.php/' + service;
},
2014-03-02 22:15:37 +00:00
/**
* Generates the absolute url for the given relative url, which can contain parameters.
*
* @returns {string}
* @param {string} url
* @param params
*/
generateUrl: function(url, params) {
var _build = function (text, vars) {
return text.replace(/{([^{}]*)}/g,
function (a, b) {
var r = vars[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
}
);
};
if (url.charAt(0) !== '/') {
url = '/' + url;
}
return OC.webroot + '/index.php' + _build(url, params);
},
/**
* @brief Creates an absolute url for remote use
* @param string $service id
* @param bool $add_slash
* @return string the url
*
* Returns a absolute url to the given service.
*/
linkToRemote:function(service) {
return window.location.protocol + '//' + window.location.host + OC.linkToRemoteBase(service);
},
/**
* get the absolute url for a file in an app
* @param app the id of the app
* @param type the type of the file to link to (e.g. css,img,ajax.template)
* @param file the filename
* @return string
*/
filePath:function(app,type,file){
2012-09-23 01:16:52 +00:00
var isCore=OC.coreApps.indexOf(app)!==-1,
link=OC.webroot;
if((file.substring(file.length-3) === 'php' || file.substring(file.length-3) === 'css') && !isCore){
2012-08-15 15:38:55 +00:00
link+='/index.php/apps/' + app;
if (file != 'index.php') {
2012-08-15 15:38:55 +00:00
link+='/';
if(type){
link+=encodeURI(type + '/');
}
link+= file;
2012-04-24 19:54:09 +00:00
}
2012-09-23 01:16:52 +00:00
}else if(file.substring(file.length-3) !== 'php' && !isCore){
2012-06-06 19:54:57 +00:00
link=OC.appswebroots[app];
2012-04-24 19:33:34 +00:00
if(type){
link+= '/'+type+'/';
2012-04-24 19:33:34 +00:00
}
2012-09-23 01:16:52 +00:00
if(link.substring(link.length-1) !== '/'){
link+='/';
2012-09-23 01:16:52 +00:00
}
2012-04-24 19:54:09 +00:00
link+=file;
2012-04-20 20:35:12 +00:00
}else{
2012-10-28 18:28:44 +00:00
if ((app == 'settings' || app == 'core' || app == 'search') && type == 'ajax') {
link+='/index.php/';
}
else {
link+='/';
}
2012-04-20 20:35:12 +00:00
if(!isCore){
link+='apps/';
}
2012-09-23 01:16:52 +00:00
if (app !== '') {
app+='/';
link+=app;
}
2012-04-20 20:35:12 +00:00
if(type){
link+=type+'/';
}
2012-07-31 10:21:06 +00:00
link+=file;
}
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
* @return string
2012-07-31 10:21:06 +00:00
*
* if no extension is given for the image, it will automatically decide between .png and .svg based on what the browser supports
2012-07-31 10:21:06 +00:00
*/
imagePath:function(app,file){
if(file.indexOf('.')==-1){//if no extension is given, use png or svg depending on browser support
file+=(OC.Util.hasSVGSupport())?'.svg':'.png';
}
return OC.filePath(app,'img',file);
},
/**
* load a script for the server and load it
* @param app the app id to which the script belongs
* @param script the filename of the script
* @param ready event handeler to be called when the script is loaded
2012-07-31 10:21:06 +00:00
*
* if the script is already loaded, the event handeler will be called directly
*/
addScript:function(app,script,ready){
2012-09-23 01:16:52 +00:00
var deferred, path=OC.filePath(app,'js',script+'.js');
if(!OC.addScript.loaded[path]){
2011-07-30 16:05:20 +00:00
if(ready){
2012-09-23 01:16:52 +00:00
deferred=$.getScript(path,ready);
2011-07-30 16:05:20 +00:00
}else{
2012-09-23 01:16:52 +00:00
deferred=$.getScript(path);
2011-07-30 16:05:20 +00:00
}
OC.addScript.loaded[path]=deferred;
2011-07-30 19:18:54 +00:00
}else{
if(ready){
ready();
}
}
return OC.addScript.loaded[path];
},
/**
* load a css file and load it
* @param app the app id to which the css style belongs
* @param style the filename of the css file
*/
addStyle:function(app,style){
var path=OC.filePath(app,'css',style+'.css');
2012-09-23 01:16:52 +00:00
if(OC.addStyle.loaded.indexOf(path)===-1){
OC.addStyle.loaded.push(path);
2013-07-02 15:44:10 +00:00
if (document.createStyleSheet) {
document.createStyleSheet(path);
} else {
style=$('<link rel="stylesheet" type="text/css" href="'+path+'"/>');
$('head').append(style);
}
2011-07-30 16:05:20 +00:00
}
},
basename: function(path) {
return path.replace(/\\/g,'/').replace( /.*\//, '' );
},
dirname: function(path) {
2012-09-23 01:16:52 +00:00
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
2012-09-08 22:35:02 +00:00
},
/**
* do a search query and display the results
* @param query the search query
*/
2011-07-30 16:05:20 +00:00
search:function(query){
if(query){
2011-07-31 02:03:48 +00:00
OC.addStyle('search','results');
$.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), function(results){
OC.search.lastResults=results;
OC.search.showResults(results);
2011-07-30 19:18:54 +00:00
});
2011-07-30 16:05:20 +00:00
}
2012-02-28 22:02:02 +00:00
},
2012-04-02 17:39:24 +00:00
dialogs:OCdialogs,
2012-07-31 12:06:44 +00:00
mtime2date:function(mtime) {
2012-09-23 01:16:52 +00:00
mtime = parseInt(mtime,10);
2012-07-31 12:06:44 +00:00
var date = new Date(1000*mtime);
2012-09-23 01:16:52 +00:00
return date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes();
2012-07-31 12:06:44 +00:00
},
/**
* Parses a URL query string into a JS map
* @param queryString query string in the format param1=1234&param2=abcde&param3=xyz
* @return map containing key/values matching the URL parameters
*/
parseQueryString:function(queryString){
var parts,
pos,
components,
result = {},
key,
value;
if (!queryString){
return null;
}
pos = queryString.indexOf('?');
if (pos >= 0){
queryString = queryString.substr(pos + 1);
}
parts = queryString.replace(/\+/g, '%20').split('&');
for (var i = 0; i < parts.length; i++){
// split on first equal sign
var part = parts[i]
pos = part.indexOf('=');
if (pos >= 0) {
components = [
part.substr(0, pos),
part.substr(pos + 1)
]
}
else {
// key only
components = [part];
}
if (!components.length){
continue;
}
key = decodeURIComponent(components[0]);
if (!key){
continue;
}
// if equal sign was there, return string
if (components.length > 1) {
result[key] = decodeURIComponent(components[1]);
}
// no equal sign => null value
else {
result[key] = null;
}
}
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'.
* @param loadJS boolean or String. If true 'js/settings.js' is loaded. If it's a string
* it will attempt to load a script by that name in the 'js' directory.
* @param cache boolean. If true the javascript file won't be forced refreshed. Defaults to true.
* @param scriptName String. The name of the PHP file to load. Defaults to 'settings.php' in
* the root of the app directory hierarchy.
*/
appSettings:function(args) {
if(typeof args === 'undefined' || typeof args.appid === 'undefined') {
throw { name: 'MissingParameter', message: 'The parameter appid is missing' };
}
var props = {scriptName:'settings.php', cache:true};
$.extend(props, args);
2012-07-31 10:21:06 +00:00
var settings = $('#appsettings');
if(settings.length == 0) {
throw { name: 'MissingDOMElement', message: 'There has be be an element with id "appsettings" for the popup to show.' };
}
var popup = $('#appsettings_popup');
if(popup.length == 0) {
$('body').prepend('<div class="popup hidden" id="appsettings_popup"></div>');
2013-02-09 16:20:08 +00:00
popup = $('#appsettings_popup');
popup.addClass(settings.hasClass('topright') ? 'topright' : 'bottomleft');
}
if(popup.is(':visible')) {
popup.hide().remove();
2012-07-31 10:21:06 +00:00
} else {
var arrowclass = settings.hasClass('topright') ? 'up' : 'left';
var jqxhr = $.get(OC.filePath(props.appid, '', props.scriptName), function(data) {
popup.html(data).ready(function() {
popup.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close svg"></a>').show();
popup.find('.close').bind('click', function() {
popup.remove();
2012-09-05 20:17:33 +00:00
});
if(typeof props.loadJS !== 'undefined') {
var scriptname;
if(props.loadJS === true) {
scriptname = 'settings.js';
} else if(typeof props.loadJS === 'string') {
scriptname = props.loadJS;
} else {
throw { name: 'InvalidParameter', message: 'The "loadJS" parameter must be either boolean or a string.' };
}
if(props.cache) {
$.ajaxSetup({cache: true});
}
$.getScript(OC.filePath(props.appid, 'js', scriptname))
.fail(function(jqxhr, settings, e) {
throw e;
});
}
if(!OC.Util.hasSVGSupport()) {
OC.Util.replaceSVG();
}
}).show();
}, 'html');
2012-07-31 10:21:06 +00:00
}
},
// for menu toggling
registerMenu: function($toggle, $menuEl) {
$menuEl.addClass('menu');
$toggle.addClass('menutoggle');
$toggle.on('click.menu', function(event) {
if ($menuEl.is(OC._currentMenu)) {
$menuEl.hide();
OC._currentMenu = null;
OC._currentMenuToggle = null;
return false;
}
// another menu was open?
else if (OC._currentMenu) {
// close it
OC._currentMenu.hide();
}
$menuEl.show();
OC._currentMenu = $menuEl;
OC._currentMenuToggle = $toggle;
return false
});
},
unregisterMenu: function($toggle, $menuEl) {
// close menu if opened
if ($menuEl.is(OC._currentMenu)) {
$menuEl.hide();
OC._currentMenu = null;
OC._currentMenuToggle = null;
}
$toggle.off('click.menu').removeClass('menutoggle');
$menuEl.removeClass('menu');
},
/**
* Wrapper for matchMedia
*
* This is makes it possible for unit tests to
* stub matchMedia (which doesn't work in PhantomJS)
*/
_matchMedia: function(media) {
if (window.matchMedia) {
return window.matchMedia(media);
}
return false;
2012-07-31 10:21:06 +00:00
}
};
OC.search.customResults={};
2011-07-31 02:03:48 +00:00
OC.search.currentResult=-1;
OC.search.lastQuery='';
OC.search.lastResults={};
2011-07-30 16:05:20 +00:00
OC.addStyle.loaded=[];
OC.addScript.loaded=[];
OC.msg={
startSaving:function(selector){
OC.msg.startAction(selector, t('core', 'Saving...'));
},
finishedSaving:function(selector, data){
OC.msg.finishedAction(selector, data);
},
startAction:function(selector, message){
$(selector)
.html( message )
.removeClass('success')
.removeClass('error')
.stop(true, true)
.show();
},
finishedAction:function(selector, data){
if( data.status === "success" ){
$(selector).html( data.data.message )
.addClass('success')
.stop(true, true)
.delay(3000)
.fadeOut(900);
}else{
$(selector).html( data.data.message ).addClass('error');
}
}
};
OC.Notification={
2013-03-02 18:24:37 +00:00
queuedNotifications: [],
2013-02-09 16:20:08 +00:00
getDefaultNotificationFunction: null,
setDefault: function(callback) {
OC.Notification.getDefaultNotificationFunction = callback;
},
hide: function(callback) {
$('#notification').fadeOut('400', function(){
if (OC.Notification.isHidden()) {
if (OC.Notification.getDefaultNotificationFunction) {
OC.Notification.getDefaultNotificationFunction.call();
}
}
if (callback) {
callback.call();
}
$('#notification').empty();
if(OC.Notification.queuedNotifications.length > 0){
OC.Notification.showHtml(OC.Notification.queuedNotifications[0]);
OC.Notification.queuedNotifications.shift();
}
});
},
showHtml: function(html) {
if(($('#notification').filter('span.undo').length == 1) || OC.Notification.isHidden()){
$('#notification').html(html);
$('#notification').fadeIn().css("display","inline");
}else{
OC.Notification.queuedNotifications.push(html);
}
},
show: function(text) {
2013-03-02 16:36:04 +00:00
if(($('#notification').filter('span.undo').length == 1) || OC.Notification.isHidden()){
$('#notification').text(text);
2013-03-02 16:36:04 +00:00
$('#notification').fadeIn().css("display","inline");
2013-02-09 16:20:08 +00:00
}else{
OC.Notification.queuedNotifications.push($('<div/>').text(text).html());
2013-02-09 16:20:08 +00:00
}
},
isHidden: function() {
return ($("#notification").text() === '');
}
};
2012-09-09 00:58:16 +00:00
OC.Breadcrumb={
container:null,
2013-08-02 09:44:53 +00:00
show:function(dir, leafname, leaflink){
if(!this.container){//default
this.container=$('#controls');
}
this._show(this.container, dir, leafname, leaflink);
},
_show:function(container, dir, leafname, leaflink){
var self = this;
this._clear(container);
2013-08-02 09:44:53 +00:00
// show home + path in subdirectories
if (dir) {
2013-08-02 09:44:53 +00:00
//add home
var link = OC.linkTo('files','index.php');
2013-08-02 09:44:53 +00:00
var crumb=$('<div/>');
crumb.addClass('crumb');
2013-08-02 09:44:53 +00:00
var crumbLink=$('<a/>');
crumbLink.attr('href',link);
2013-08-02 09:44:53 +00:00
var crumbImg=$('<img/>');
crumbImg.attr('src',OC.imagePath('core','places/home'));
crumbLink.append(crumbImg);
crumb.append(crumbLink);
container.prepend(crumb);
2013-08-02 09:44:53 +00:00
//add path parts
var segments = dir.split('/');
var pathurl = '';
jQuery.each(segments, function(i,name) {
if (name !== '') {
pathurl = pathurl+'/'+name;
var link = OC.linkTo('files','index.php')+'?dir='+encodeURIComponent(pathurl);
self._push(container, name, link);
2013-08-02 09:44:53 +00:00
}
});
}
2013-08-02 09:44:53 +00:00
//add leafname
if (leafname && leaflink) {
this._push(container, leafname, leaflink);
2013-08-02 09:44:53 +00:00
}
},
2012-09-09 00:58:16 +00:00
push:function(name, link){
if(!this.container){//default
this.container=$('#controls');
2012-09-09 00:58:16 +00:00
}
return this._push(OC.Breadcrumb.container, name, link);
},
_push:function(container, name, link){
2012-09-09 00:58:16 +00:00
var crumb=$('<div/>');
crumb.addClass('crumb').addClass('last');
var crumbLink=$('<a/>');
crumbLink.attr('href',link);
crumbLink.text(name);
crumb.append(crumbLink);
var existing=container.find('div.crumb');
2012-09-09 00:58:16 +00:00
if(existing.length){
existing.removeClass('last');
existing.last().after(crumb);
}else{
container.prepend(crumb);
2012-09-09 00:58:16 +00:00
}
return crumb;
},
pop:function(){
if(!this.container){//default
this.container=$('#controls');
2012-09-09 00:58:16 +00:00
}
this.container.find('div.crumb').last().remove();
this.container.find('div.crumb').last().addClass('last');
2012-09-09 00:58:16 +00:00
},
clear:function(){
if(!this.container){//default
this.container=$('#controls');
2012-09-09 00:58:16 +00:00
}
this._clear(this.container);
},
_clear:function(container) {
container.find('div.crumb').remove();
2012-09-09 00:58:16 +00:00
}
2012-09-23 01:16:52 +00:00
};
2012-09-09 00:58:16 +00:00
2012-09-23 01:16:52 +00:00
if(typeof localStorage !=='undefined' && localStorage !== null){
//user and instance aware localstorage
OC.localStorage={
namespace:'oc_'+OC.currentUser+'_'+OC.webroot+'_',
hasItem:function(name){
2012-09-23 01:16:52 +00:00
return OC.localStorage.getItem(name)!==null;
},
setItem:function(name,item){
return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item));
},
removeItem:function(name,item){
2014-03-10 15:26:07 +00:00
return localStorage.removeItem(OC.localStorage.namespace+name);
},
getItem:function(name){
var item = localStorage.getItem(OC.localStorage.namespace+name);
if(item===null) {
return null;
} else if (typeof JSON === 'undefined') {
//fallback to jquery for IE6/7/8
return $.parseJSON(item);
} else {
return JSON.parse(item);
}
}
};
}else{
//dummy localstorage
OC.localStorage={
2012-09-23 01:16:52 +00:00
hasItem:function(){
return false;
},
2012-09-23 01:16:52 +00:00
setItem:function(){
return false;
},
2012-09-23 01:16:52 +00:00
getItem:function(){
return null;
}
};
}
/**
* check if the browser support svg images
*/
function SVGSupport() {
return SVGSupport.checkMimeType.correct && !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect;
}
SVGSupport.checkMimeType=function(){
$.ajax({
url: OC.imagePath('core','breadcrumb.svg'),
success:function(data,text,xhr){
var headerParts=xhr.getAllResponseHeaders().split("\n");
var headers={};
$.each(headerParts,function(i,text){
if(text){
var parts=text.split(':',2);
2012-09-23 01:16:52 +00:00
if(parts.length===2){
var value=parts[1].trim();
2012-09-23 01:16:52 +00:00
if(value[0]==='"'){
value=value.substr(1,value.length-2);
}
headers[parts[0].toLowerCase()]=value;
}
}
});
if(headers["content-type"]!=='image/svg+xml'){
OC.Util.replaceSVG();
SVGSupport.checkMimeType.correct=false;
}
}
});
};
SVGSupport.checkMimeType.correct=true;
// replace all svg images with png for browser compatibility
// @deprecated use OC.Util.replaceSVG instead
function replaceSVG($el){
return OC.Util.replaceSVG($el);
}
/**
* prototypal inharitence functions
2012-07-31 10:21:06 +00:00
*
* usage:
* MySubObject=object(MyObject)
*/
function object(o) {
function F() {}
2013-02-09 16:20:08 +00:00
F.prototype = o;
return new F();
}
/**
* Fills height of window. (more precise than height: 100%;)
*/
function fillHeight(selector) {
if (selector.length === 0) {
return;
}
var height = parseFloat($(window).height())-selector.offset().top;
selector.css('height', height + 'px');
if(selector.outerHeight() > selector.height()){
selector.css('height', height-(selector.outerHeight()-selector.height()) + 'px');
}
console.warn("This function is deprecated! Use CSS instead");
}
/**
* Fills height and width of window. (more precise than height: 100%; or width: 100%;)
*/
function fillWindow(selector) {
if (selector.length === 0) {
return;
}
fillHeight(selector);
var width = parseFloat($(window).width())-selector.offset().left;
selector.css('width', width + 'px');
if(selector.outerWidth() > selector.width()){
selector.css('width', width-(selector.outerWidth()-selector.width()) + 'px');
}
console.warn("This function is deprecated! Use CSS instead");
}
2011-10-04 16:54:07 +00:00
/**
* Initializes core
*/
function initCore() {
/**
2014-02-04 19:58:06 +00:00
* Calls the server periodically to ensure that session doesn't
* time out
*/
function initSessionHeartBeat(){
// interval in seconds
var interval = 900;
if (oc_config.session_lifetime) {
interval = Math.floor(oc_config.session_lifetime / 2);
}
// minimum one minute
if (interval < 60) {
interval = 60;
}
2014-03-02 22:15:37 +00:00
var url = OC.generateUrl('/heartbeat');
setInterval(function(){
$.post(url);
}, interval * 1000);
}
2014-02-04 19:58:06 +00:00
// session heartbeat (defaults to enabled)
if (typeof(oc_config.session_keepalive) === 'undefined' ||
!!oc_config.session_keepalive) {
initSessionHeartBeat();
}
2011-10-04 16:54:07 +00:00
if(!OC.Util.hasSVGSupport()){ //replace all svg images with png images for browser that dont support svg
OC.Util.replaceSVG();
}else{
SVGSupport.checkMimeType();
}
2011-07-31 02:03:48 +00:00
$('form.searchbox').submit(function(event){
event.preventDefault();
});
2011-07-31 02:03:48 +00:00
$('#searchbox').keyup(function(event){
2012-09-23 01:16:52 +00:00
if(event.keyCode===13){//enter
2011-07-31 02:03:48 +00:00
if(OC.search.currentResult>-1){
var result=$('#searchresults tr.result a')[OC.search.currentResult];
2011-08-27 20:36:15 +00:00
window.location = $(result).attr('href');
2011-07-31 02:03:48 +00:00
}
2012-09-23 01:16:52 +00:00
}else if(event.keyCode===38){//up
2011-07-31 02:03:48 +00:00
if(OC.search.currentResult>0){
OC.search.currentResult--;
OC.search.renderCurrent();
}
2012-09-23 01:16:52 +00:00
}else if(event.keyCode===40){//down
2011-07-31 02:03:48 +00:00
if(OC.search.lastResults.length>OC.search.currentResult+1){
OC.search.currentResult++;
OC.search.renderCurrent();
}
2012-09-23 01:16:52 +00:00
}else if(event.keyCode===27){//esc
2011-07-31 02:03:48 +00:00
OC.search.hide();
if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
FileList.unfilter();
}
2011-07-30 16:05:20 +00:00
}else{
2011-07-31 02:03:48 +00:00
var query=$('#searchbox').val();
2012-09-23 01:16:52 +00:00
if(OC.search.lastQuery!==query){
2011-07-31 02:03:48 +00:00
OC.search.lastQuery=query;
OC.search.currentResult=-1;
if (FileList && typeof FileList.filter === 'function') { //TODO add hook system
FileList.filter(query);
}
2011-07-31 02:03:48 +00:00
if(query.length>2){
OC.search(query);
}else{
if(OC.search.hide){
OC.search.hide();
}
}
2011-07-30 19:18:54 +00:00
}
2011-07-30 16:05:20 +00:00
}
});
var setShowPassword = function(input, label) {
input.showPassword().keyup();
};
setShowPassword($('#adminpass'), $('label[for=show]'));
setShowPassword($('#pass2'), $('label[for=personal-show]'));
setShowPassword($('#dbpass'), $('label[for=dbpassword]'));
//use infield labels
$("label.infield").inFieldLabels({
pollDuration: 100
});
2012-09-23 01:16:52 +00:00
var checkShowCredentials = function() {
var empty = false;
$('input#user, input#password').each(function() {
2012-09-23 01:16:52 +00:00
if ($(this).val() === '') {
empty = true;
}
});
if(empty) {
$('#submit').fadeOut();
$('#remember_login').hide();
$('#remember_login+label').fadeOut();
} else {
$('#submit').fadeIn();
$('#remember_login').show();
$('#remember_login+label').fadeIn();
}
2012-09-23 01:16:52 +00:00
};
// hide log in button etc. when form fields not filled
Merge branch 'master' of git://gitorious.org/owncloud/owncloud into oracle-support Conflicts: 3rdparty/Sabre/CardDAV/Plugin.php 3rdparty/smb4php/smb.php apps/bookmarks/ajax/addBookmark.php apps/bookmarks/ajax/editBookmark.php apps/bookmarks/appinfo/migrate.php apps/calendar/ajax/calendar/edit.form.php apps/calendar/ajax/changeview.php apps/calendar/ajax/import/import.php apps/calendar/ajax/settings/guesstimezone.php apps/calendar/ajax/settings/setfirstday.php apps/calendar/ajax/settings/settimeformat.php apps/calendar/ajax/share/changepermission.php apps/calendar/ajax/share/share.php apps/calendar/ajax/share/unshare.php apps/calendar/appinfo/app.php apps/calendar/appinfo/remote.php apps/calendar/appinfo/update.php apps/calendar/appinfo/version apps/calendar/js/calendar.js apps/calendar/l10n/da.php apps/calendar/l10n/de.php apps/calendar/l10n/fi_FI.php apps/calendar/l10n/gl.php apps/calendar/l10n/he.php apps/calendar/l10n/hr.php apps/calendar/l10n/ja_JP.php apps/calendar/l10n/lb.php apps/calendar/l10n/lt_LT.php apps/calendar/l10n/nb_NO.php apps/calendar/l10n/pl.php apps/calendar/l10n/pt_PT.php apps/calendar/l10n/ro.php apps/calendar/l10n/ru.php apps/calendar/l10n/sv.php apps/calendar/l10n/zh_CN.php apps/calendar/l10n/zh_TW.php apps/calendar/lib/app.php apps/calendar/lib/calendar.php apps/calendar/lib/object.php apps/calendar/lib/share.php apps/calendar/templates/part.choosecalendar.rowfields.php apps/calendar/templates/part.import.php apps/calendar/templates/settings.php apps/contacts/ajax/activation.php apps/contacts/ajax/addressbook/delete.php apps/contacts/ajax/contact/add.php apps/contacts/ajax/contact/addproperty.php apps/contacts/ajax/contact/delete.php apps/contacts/ajax/contact/deleteproperty.php apps/contacts/ajax/contact/saveproperty.php apps/contacts/ajax/createaddressbook.php apps/contacts/ajax/cropphoto.php apps/contacts/ajax/currentphoto.php apps/contacts/ajax/importaddressbook.php apps/contacts/ajax/oc_photo.php apps/contacts/ajax/savecrop.php apps/contacts/ajax/selectaddressbook.php apps/contacts/ajax/updateaddressbook.php apps/contacts/ajax/uploadimport.php apps/contacts/ajax/uploadphoto.php apps/contacts/appinfo/migrate.php apps/contacts/appinfo/remote.php apps/contacts/css/contacts.css apps/contacts/import.php apps/contacts/index.php apps/contacts/js/contacts.js apps/contacts/l10n/ca.php apps/contacts/l10n/cs_CZ.php apps/contacts/l10n/da.php apps/contacts/l10n/de.php apps/contacts/l10n/el.php apps/contacts/l10n/eo.php apps/contacts/l10n/es.php apps/contacts/l10n/et_EE.php apps/contacts/l10n/eu.php apps/contacts/l10n/fa.php apps/contacts/l10n/fi_FI.php apps/contacts/l10n/fr.php apps/contacts/l10n/he.php apps/contacts/l10n/hr.php apps/contacts/l10n/hu_HU.php apps/contacts/l10n/ia.php apps/contacts/l10n/it.php apps/contacts/l10n/ja_JP.php apps/contacts/l10n/ko.php apps/contacts/l10n/lb.php apps/contacts/l10n/mk.php apps/contacts/l10n/nb_NO.php apps/contacts/l10n/nl.php apps/contacts/l10n/pl.php apps/contacts/l10n/pt_BR.php apps/contacts/l10n/pt_PT.php apps/contacts/l10n/ro.php apps/contacts/l10n/ru.php apps/contacts/l10n/sk_SK.php apps/contacts/l10n/sl.php apps/contacts/l10n/sv.php apps/contacts/l10n/th_TH.php apps/contacts/l10n/tr.php apps/contacts/l10n/zh_CN.php apps/contacts/l10n/zh_TW.php apps/contacts/lib/addressbook.php apps/contacts/lib/hooks.php apps/contacts/lib/vcard.php apps/contacts/photo.php apps/contacts/templates/part.contact.php apps/contacts/templates/part.contacts.php apps/contacts/templates/part.cropphoto.php apps/contacts/templates/part.importaddressbook.php apps/contacts/templates/part.selectaddressbook.php apps/contacts/thumbnail.php apps/files/ajax/download.php apps/files/ajax/newfile.php apps/files/ajax/timezone.php apps/files/appinfo/update.php apps/files/appinfo/version apps/files/index.php apps/files/js/fileactions.js apps/files/js/filelist.js apps/files/js/files.js apps/files/l10n/ar.php apps/files/l10n/bg_BG.php apps/files/l10n/ca.php apps/files/l10n/cs_CZ.php apps/files/l10n/da.php apps/files/l10n/de.php apps/files/l10n/el.php apps/files/l10n/eo.php apps/files/l10n/es.php apps/files/l10n/et_EE.php apps/files/l10n/eu.php apps/files/l10n/fa.php apps/files/l10n/fi_FI.php apps/files/l10n/fr.php apps/files/l10n/gl.php apps/files/l10n/he.php apps/files/l10n/hr.php apps/files/l10n/hu_HU.php apps/files/l10n/ia.php apps/files/l10n/id.php apps/files/l10n/it.php apps/files/l10n/ja_JP.php apps/files/l10n/ko.php apps/files/l10n/lb.php apps/files/l10n/lt_LT.php apps/files/l10n/mk.php apps/files/l10n/ms_MY.php apps/files/l10n/nb_NO.php apps/files/l10n/nl.php apps/files/l10n/nn_NO.php apps/files/l10n/pl.php apps/files/l10n/pt_BR.php apps/files/l10n/pt_PT.php apps/files/l10n/ro.php apps/files/l10n/ru.php apps/files/l10n/sk_SK.php apps/files/l10n/sl.php apps/files/l10n/sr.php apps/files/l10n/sr@latin.php apps/files/l10n/sv.php apps/files/l10n/th_TH.php apps/files/l10n/tr.php apps/files/l10n/uk.php apps/files/l10n/zh_CN.php apps/files/l10n/zh_TW.php apps/files_archive/js/archive.js apps/files_encryption/lib/cryptstream.php apps/files_encryption/lib/proxy.php apps/files_encryption/tests/proxy.php apps/files_external/appinfo/app.php apps/files_external/lib/smb.php apps/files_external/lib/streamwrapper.php apps/files_external/tests/config.php apps/files_external/tests/smb.php apps/files_sharing/ajax/email.php apps/files_sharing/ajax/getitem.php apps/files_sharing/ajax/setpermissions.php apps/files_sharing/ajax/share.php apps/files_sharing/ajax/toggleresharing.php apps/files_sharing/ajax/unshare.php apps/files_sharing/ajax/userautocomplete.php apps/files_sharing/js/settings.js apps/files_sharing/js/share.js apps/files_sharing/lib_share.php apps/files_sharing/settings.php apps/files_sharing/sharedstorage.php apps/files_sharing/templates/settings.php apps/files_versions/ajax/rollbackVersion.php apps/files_versions/versions.php apps/gallery/ajax/thumbnail.php apps/gallery/appinfo/app.php apps/gallery/appinfo/update.php apps/gallery/appinfo/version apps/gallery/css/styles.css apps/gallery/index.php apps/gallery/js/pictures.js apps/gallery/l10n/ca.php apps/gallery/l10n/cs_CZ.php apps/gallery/l10n/de.php apps/gallery/l10n/el.php apps/gallery/l10n/es.php apps/gallery/l10n/fi_FI.php apps/gallery/l10n/fr.php apps/gallery/l10n/it.php apps/gallery/l10n/pl.php apps/gallery/l10n/pt_PT.php apps/gallery/l10n/ru.php apps/gallery/l10n/sl.php apps/gallery/l10n/sv.php apps/gallery/l10n/th_TH.php apps/gallery/l10n/tr.php apps/gallery/l10n/zh_CN.php apps/gallery/lib/album.php apps/gallery/lib/hooks_handlers.php apps/gallery/lib/managers.php apps/gallery/lib/photo.php apps/gallery/lib/tiles.php apps/gallery/lib/tiles_test.php apps/gallery/templates/index.php apps/media/lib_ampache.php apps/media/lib_collection.php apps/media/lib_media.php apps/remoteStorage/lib_remoteStorage.php apps/tasks/ajax/addtaskform.php apps/tasks/ajax/edittask.php apps/user_ldap/appinfo/update.php apps/user_ldap/group_ldap.php apps/user_ldap/lib_ldap.php apps/user_ldap/settings.php apps/user_ldap/templates/settings.php apps/user_ldap/user_ldap.php apps/user_migrate/appinfo/app.php apps/user_migrate/templates/settings.php apps/user_webfinger/host-meta.php config/config.sample.php core/js/js.js core/l10n/da.php core/l10n/de.php core/l10n/fi_FI.php core/l10n/gl.php core/l10n/he.php core/l10n/hr.php core/l10n/id.php core/l10n/ja_JP.php core/l10n/lb.php core/l10n/lt_LT.php core/l10n/nb_NO.php core/l10n/pl.php core/l10n/pt_PT.php core/l10n/ro.php core/l10n/ru.php core/l10n/sv.php core/lostpassword/index.php core/templates/layout.user.php core/templates/login.php db_structure.xml index.php l10n/af/calendar.po l10n/af/contacts.po l10n/af/core.po l10n/af/files.po l10n/af/settings.po l10n/ar/calendar.po l10n/ar/contacts.po l10n/ar/core.po l10n/ar/files.po l10n/ar/media.po l10n/ar/settings.po l10n/bg_BG/calendar.po l10n/bg_BG/contacts.po l10n/bg_BG/core.po l10n/bg_BG/files.po l10n/bg_BG/media.po l10n/bg_BG/settings.po l10n/ca/calendar.po l10n/ca/contacts.po l10n/ca/core.po l10n/ca/files.po l10n/ca/gallery.po l10n/ca/settings.po l10n/cs_CZ/calendar.po l10n/cs_CZ/contacts.po l10n/cs_CZ/core.po l10n/cs_CZ/files.po l10n/cs_CZ/gallery.po l10n/cs_CZ/settings.po l10n/da/calendar.po l10n/da/contacts.po l10n/da/core.po l10n/da/files.po l10n/da/settings.po l10n/de/calendar.po l10n/de/contacts.po l10n/de/core.po l10n/de/files.po l10n/de/gallery.po l10n/de/settings.po l10n/el/calendar.po l10n/el/contacts.po l10n/el/core.po l10n/el/files.po l10n/el/gallery.po l10n/el/settings.po l10n/eo/calendar.po l10n/eo/contacts.po l10n/eo/core.po l10n/eo/files.po l10n/eo/media.po l10n/eo/settings.po l10n/es/calendar.po l10n/es/contacts.po l10n/es/core.po l10n/es/files.po l10n/es/gallery.po l10n/es/settings.po l10n/et_EE/calendar.po l10n/et_EE/contacts.po l10n/et_EE/core.po l10n/et_EE/files.po l10n/et_EE/settings.po l10n/eu/calendar.po l10n/eu/contacts.po l10n/eu/core.po l10n/eu/files.po l10n/eu/settings.po l10n/fa/calendar.po l10n/fa/contacts.po l10n/fa/core.po l10n/fa/files.po l10n/fa/settings.po l10n/fi_FI/calendar.po l10n/fi_FI/contacts.po l10n/fi_FI/core.po l10n/fi_FI/files.po l10n/fi_FI/gallery.po l10n/fi_FI/settings.po l10n/fr/calendar.po l10n/fr/contacts.po l10n/fr/core.po l10n/fr/files.po l10n/fr/gallery.po l10n/fr/media.po l10n/fr/settings.po l10n/gl/calendar.po l10n/gl/contacts.po l10n/gl/core.po l10n/gl/files.po l10n/gl/settings.po l10n/he/calendar.po l10n/he/contacts.po l10n/he/core.po l10n/he/files.po l10n/he/settings.po l10n/hr/calendar.po l10n/hr/contacts.po l10n/hr/core.po l10n/hr/files.po l10n/hr/settings.po l10n/hu_HU/calendar.po l10n/hu_HU/contacts.po l10n/hu_HU/core.po l10n/hu_HU/files.po l10n/hu_HU/settings.po l10n/hy/calendar.po l10n/hy/contacts.po l10n/hy/core.po l10n/hy/files.po l10n/hy/settings.po l10n/ia/calendar.po l10n/ia/contacts.po l10n/ia/core.po l10n/ia/files.po l10n/ia/settings.po l10n/id/calendar.po l10n/id/contacts.po l10n/id/core.po l10n/id/files.po l10n/id/settings.po l10n/it/calendar.po l10n/it/contacts.po l10n/it/core.po l10n/it/files.po l10n/it/gallery.po l10n/it/settings.po l10n/ja_JP/calendar.po l10n/ja_JP/contacts.po l10n/ja_JP/core.po l10n/ja_JP/files.po l10n/ja_JP/settings.po l10n/ko/calendar.po l10n/ko/contacts.po l10n/ko/core.po l10n/ko/files.po l10n/ko/settings.po l10n/lb/calendar.po l10n/lb/contacts.po l10n/lb/core.po l10n/lb/files.po l10n/lb/settings.po l10n/lt_LT/calendar.po l10n/lt_LT/contacts.po l10n/lt_LT/core.po l10n/lt_LT/files.po l10n/lt_LT/settings.po l10n/mk/calendar.po l10n/mk/contacts.po l10n/mk/core.po l10n/mk/files.po l10n/mk/settings.po l10n/ms_MY/calendar.po l10n/ms_MY/contacts.po l10n/ms_MY/core.po l10n/ms_MY/files.po l10n/ms_MY/settings.po l10n/nb_NO/calendar.po l10n/nb_NO/contacts.po l10n/nb_NO/core.po l10n/nb_NO/files.po l10n/nb_NO/settings.po l10n/nl/calendar.po l10n/nl/contacts.po l10n/nl/core.po l10n/nl/files.po l10n/nl/settings.po l10n/nn_NO/calendar.po l10n/nn_NO/contacts.po l10n/nn_NO/core.po l10n/nn_NO/files.po l10n/nn_NO/settings.po l10n/pl/calendar.po l10n/pl/contacts.po l10n/pl/core.po l10n/pl/files.po l10n/pl/gallery.po l10n/pl/settings.po l10n/pt_BR/calendar.po l10n/pt_BR/contacts.po l10n/pt_BR/core.po l10n/pt_BR/files.po l10n/pt_BR/settings.po l10n/pt_PT/calendar.po l10n/pt_PT/contacts.po l10n/pt_PT/core.po l10n/pt_PT/files.po l10n/pt_PT/gallery.po l10n/pt_PT/settings.po l10n/ro/calendar.po l10n/ro/contacts.po l10n/ro/core.po l10n/ro/files.po l10n/ro/settings.po l10n/ru/calendar.po l10n/ru/contacts.po l10n/ru/core.po l10n/ru/files.po l10n/ru/gallery.po l10n/ru/settings.po l10n/sk_SK/calendar.po l10n/sk_SK/contacts.po l10n/sk_SK/core.po l10n/sk_SK/files.po l10n/sk_SK/settings.po l10n/sl/calendar.po l10n/sl/contacts.po l10n/sl/core.po l10n/sl/files.po l10n/sl/gallery.po l10n/sl/settings.po l10n/sr/calendar.po l10n/sr/contacts.po l10n/sr/core.po l10n/sr/files.po l10n/sr/settings.po l10n/sr@latin/calendar.po l10n/sr@latin/contacts.po l10n/sr@latin/core.po l10n/sr@latin/files.po l10n/sr@latin/settings.po l10n/sv/calendar.po l10n/sv/contacts.po l10n/sv/core.po l10n/sv/files.po l10n/sv/gallery.po l10n/sv/media.po l10n/sv/settings.po l10n/templates/bookmarks.pot l10n/templates/calendar.pot l10n/templates/contacts.pot l10n/templates/core.pot l10n/templates/files.pot l10n/templates/gallery.pot l10n/templates/media.pot l10n/templates/settings.pot l10n/th_TH/calendar.po l10n/th_TH/contacts.po l10n/th_TH/core.po l10n/th_TH/files.po l10n/th_TH/gallery.po l10n/th_TH/settings.po l10n/tr/calendar.po l10n/tr/contacts.po l10n/tr/core.po l10n/tr/files.po l10n/tr/gallery.po l10n/tr/settings.po l10n/uk/calendar.po l10n/uk/contacts.po l10n/uk/core.po l10n/uk/files.po l10n/uk/media.po l10n/uk/settings.po l10n/zh_CN/calendar.po l10n/zh_CN/contacts.po l10n/zh_CN/core.po l10n/zh_CN/files.po l10n/zh_CN/gallery.po l10n/zh_CN/settings.po l10n/zh_TW/calendar.po l10n/zh_TW/contacts.po l10n/zh_TW/core.po l10n/zh_TW/files.po l10n/zh_TW/settings.po lib/app.php lib/base.php lib/connector/sabre/file.php lib/connector/sabre/locks.php lib/connector/sabre/node.php lib/db.php lib/filecache.php lib/fileproxy/quota.php lib/files.php lib/filestorage/local.php lib/filesystemview.php lib/group/database.php lib/helper.php lib/installer.php lib/json.php lib/l10n.php lib/migrate.php lib/mimetypes.fixlist.php lib/ocs.php lib/preferences.php lib/public/json.php lib/public/util.php lib/template.php lib/user.php lib/user/database.php lib/util.php lib/vcategories.php ocs/providers.php settings/admin.php settings/ajax/lostpassword.php settings/ajax/removeuser.php settings/ajax/setbackgroundjobsmode.php settings/ajax/setlanguage.php settings/ajax/setquota.php settings/ajax/togglegroups.php settings/apps.php settings/css/settings.css settings/js/apps.js settings/js/users.js settings/l10n/bg_BG.php settings/l10n/ca.php settings/l10n/cs_CZ.php settings/l10n/da.php settings/l10n/de.php settings/l10n/el.php settings/l10n/eo.php settings/l10n/es.php settings/l10n/et_EE.php settings/l10n/eu.php settings/l10n/fa.php settings/l10n/fi_FI.php settings/l10n/fr.php settings/l10n/gl.php settings/l10n/he.php settings/l10n/hr.php settings/l10n/hu_HU.php settings/l10n/it.php settings/l10n/ja_JP.php settings/l10n/ko.php settings/l10n/lt_LT.php settings/l10n/mk.php settings/l10n/ms_MY.php settings/l10n/nb_NO.php settings/l10n/nl.php settings/l10n/nn_NO.php settings/l10n/pl.php settings/l10n/pt_BR.php settings/l10n/pt_PT.php settings/l10n/ru.php settings/l10n/sk_SK.php settings/l10n/sl.php settings/l10n/sv.php settings/l10n/th_TH.php settings/l10n/tr.php settings/l10n/zh_CN.php settings/personal.php settings/templates/admin.php settings/templates/users.php
2012-08-24 22:05:07 +00:00
// commented out due to some browsers having issues with it
// checkShowCredentials();
// $('input#user, input#password').keyup(checkShowCredentials);
2011-08-08 21:31:58 +00:00
// user menu
$('#settings #expand').keydown(function(event) {
2012-09-23 01:16:52 +00:00
if (event.which === 13 || event.which === 32) {
$('#expand').click()
}
});
$('#settings #expand').click(function(event) {
2013-02-14 16:13:50 +00:00
$('#settings #expanddiv').slideToggle(200);
event.stopPropagation();
2011-08-08 21:31:58 +00:00
});
$('#settings #expanddiv').click(function(event){
event.stopPropagation();
});
//hide the user menu when clicking outside it
$(document).click(function(){
2013-02-14 16:13:50 +00:00
$('#settings #expanddiv').slideUp(200);
});
2011-08-14 14:12:27 +00:00
// all the tipsy stuff needs to be here (in reverse order) to work
$('.displayName .action').tipsy({gravity:'se', fade:true, live:true});
$('.password .action').tipsy({gravity:'se', fade:true, live:true});
$('#upload').tipsy({gravity:'w', fade:true});
$('.selectedActions a').tipsy({gravity:'s', fade:true, live:true});
$('a.action.delete').tipsy({gravity:'e', fade:true, live:true});
2012-04-13 16:28:17 +00:00
$('a.action').tipsy({gravity:'s', fade:true, live:true});
2011-08-14 14:12:27 +00:00
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
$('input').tipsy({gravity:'w', fade:true});
// toggle for menus
$(document).on('mouseup.closemenus', function(event) {
var $el = $(event.target);
if ($el.closest('.menu').length || $el.closest('.menutoggle').length) {
// don't close when clicking on the menu directly or a menu toggle
return false;
}
if (OC._currentMenu) {
OC._currentMenu.hide();
}
OC._currentMenu = null;
OC._currentMenuToggle = null;
});
/**
* Set up the main menu toggle to react to media query changes.
* If the screen is small enough, the main menu becomes a toggle.
* If the screen is bigger, the main menu is not a toggle any more.
*/
function setupMainMenu() {
// toggle the navigation on mobile
if (!OC._matchMedia) {
return;
}
var mq = OC._matchMedia('(max-width: 768px)');
var lastMatch = mq.matches;
var $toggle = $('#header #owncloud');
var $navigation = $('#navigation');
function updateMainMenu() {
// mobile mode ?
if (lastMatch && !$toggle.hasClass('menutoggle')) {
// init the menu
OC.registerMenu($toggle, $navigation);
$toggle.data('oldhref', $toggle.attr('href'));
$toggle.attr('href', '#');
$navigation.hide();
}
else {
OC.unregisterMenu($toggle, $navigation);
$toggle.attr('href', $toggle.data('oldhref'));
$navigation.show();
}
}
updateMainMenu();
// TODO: debounce this
$(window).resize(function() {
if (lastMatch !== mq.matches) {
lastMatch = mq.matches;
updateMainMenu();
}
});
}
if (window.matchMedia) {
setupMainMenu();
}
}
$(document).ready(initCore);
/**
* Filter Jquery selector by attribute value
*/
2012-07-31 10:21:06 +00:00
$.fn.filterAttr = function(attr_name, attr_value) {
Merge branch 'master' of git://gitorious.org/owncloud/owncloud into oracle-support Conflicts: 3rdparty/Sabre/CardDAV/Plugin.php 3rdparty/smb4php/smb.php apps/bookmarks/ajax/addBookmark.php apps/bookmarks/ajax/editBookmark.php apps/bookmarks/appinfo/migrate.php apps/calendar/ajax/calendar/edit.form.php apps/calendar/ajax/changeview.php apps/calendar/ajax/import/import.php apps/calendar/ajax/settings/guesstimezone.php apps/calendar/ajax/settings/setfirstday.php apps/calendar/ajax/settings/settimeformat.php apps/calendar/ajax/share/changepermission.php apps/calendar/ajax/share/share.php apps/calendar/ajax/share/unshare.php apps/calendar/appinfo/app.php apps/calendar/appinfo/remote.php apps/calendar/appinfo/update.php apps/calendar/appinfo/version apps/calendar/js/calendar.js apps/calendar/l10n/da.php apps/calendar/l10n/de.php apps/calendar/l10n/fi_FI.php apps/calendar/l10n/gl.php apps/calendar/l10n/he.php apps/calendar/l10n/hr.php apps/calendar/l10n/ja_JP.php apps/calendar/l10n/lb.php apps/calendar/l10n/lt_LT.php apps/calendar/l10n/nb_NO.php apps/calendar/l10n/pl.php apps/calendar/l10n/pt_PT.php apps/calendar/l10n/ro.php apps/calendar/l10n/ru.php apps/calendar/l10n/sv.php apps/calendar/l10n/zh_CN.php apps/calendar/l10n/zh_TW.php apps/calendar/lib/app.php apps/calendar/lib/calendar.php apps/calendar/lib/object.php apps/calendar/lib/share.php apps/calendar/templates/part.choosecalendar.rowfields.php apps/calendar/templates/part.import.php apps/calendar/templates/settings.php apps/contacts/ajax/activation.php apps/contacts/ajax/addressbook/delete.php apps/contacts/ajax/contact/add.php apps/contacts/ajax/contact/addproperty.php apps/contacts/ajax/contact/delete.php apps/contacts/ajax/contact/deleteproperty.php apps/contacts/ajax/contact/saveproperty.php apps/contacts/ajax/createaddressbook.php apps/contacts/ajax/cropphoto.php apps/contacts/ajax/currentphoto.php apps/contacts/ajax/importaddressbook.php apps/contacts/ajax/oc_photo.php apps/contacts/ajax/savecrop.php apps/contacts/ajax/selectaddressbook.php apps/contacts/ajax/updateaddressbook.php apps/contacts/ajax/uploadimport.php apps/contacts/ajax/uploadphoto.php apps/contacts/appinfo/migrate.php apps/contacts/appinfo/remote.php apps/contacts/css/contacts.css apps/contacts/import.php apps/contacts/index.php apps/contacts/js/contacts.js apps/contacts/l10n/ca.php apps/contacts/l10n/cs_CZ.php apps/contacts/l10n/da.php apps/contacts/l10n/de.php apps/contacts/l10n/el.php apps/contacts/l10n/eo.php apps/contacts/l10n/es.php apps/contacts/l10n/et_EE.php apps/contacts/l10n/eu.php apps/contacts/l10n/fa.php apps/contacts/l10n/fi_FI.php apps/contacts/l10n/fr.php apps/contacts/l10n/he.php apps/contacts/l10n/hr.php apps/contacts/l10n/hu_HU.php apps/contacts/l10n/ia.php apps/contacts/l10n/it.php apps/contacts/l10n/ja_JP.php apps/contacts/l10n/ko.php apps/contacts/l10n/lb.php apps/contacts/l10n/mk.php apps/contacts/l10n/nb_NO.php apps/contacts/l10n/nl.php apps/contacts/l10n/pl.php apps/contacts/l10n/pt_BR.php apps/contacts/l10n/pt_PT.php apps/contacts/l10n/ro.php apps/contacts/l10n/ru.php apps/contacts/l10n/sk_SK.php apps/contacts/l10n/sl.php apps/contacts/l10n/sv.php apps/contacts/l10n/th_TH.php apps/contacts/l10n/tr.php apps/contacts/l10n/zh_CN.php apps/contacts/l10n/zh_TW.php apps/contacts/lib/addressbook.php apps/contacts/lib/hooks.php apps/contacts/lib/vcard.php apps/contacts/photo.php apps/contacts/templates/part.contact.php apps/contacts/templates/part.contacts.php apps/contacts/templates/part.cropphoto.php apps/contacts/templates/part.importaddressbook.php apps/contacts/templates/part.selectaddressbook.php apps/contacts/thumbnail.php apps/files/ajax/download.php apps/files/ajax/newfile.php apps/files/ajax/timezone.php apps/files/appinfo/update.php apps/files/appinfo/version apps/files/index.php apps/files/js/fileactions.js apps/files/js/filelist.js apps/files/js/files.js apps/files/l10n/ar.php apps/files/l10n/bg_BG.php apps/files/l10n/ca.php apps/files/l10n/cs_CZ.php apps/files/l10n/da.php apps/files/l10n/de.php apps/files/l10n/el.php apps/files/l10n/eo.php apps/files/l10n/es.php apps/files/l10n/et_EE.php apps/files/l10n/eu.php apps/files/l10n/fa.php apps/files/l10n/fi_FI.php apps/files/l10n/fr.php apps/files/l10n/gl.php apps/files/l10n/he.php apps/files/l10n/hr.php apps/files/l10n/hu_HU.php apps/files/l10n/ia.php apps/files/l10n/id.php apps/files/l10n/it.php apps/files/l10n/ja_JP.php apps/files/l10n/ko.php apps/files/l10n/lb.php apps/files/l10n/lt_LT.php apps/files/l10n/mk.php apps/files/l10n/ms_MY.php apps/files/l10n/nb_NO.php apps/files/l10n/nl.php apps/files/l10n/nn_NO.php apps/files/l10n/pl.php apps/files/l10n/pt_BR.php apps/files/l10n/pt_PT.php apps/files/l10n/ro.php apps/files/l10n/ru.php apps/files/l10n/sk_SK.php apps/files/l10n/sl.php apps/files/l10n/sr.php apps/files/l10n/sr@latin.php apps/files/l10n/sv.php apps/files/l10n/th_TH.php apps/files/l10n/tr.php apps/files/l10n/uk.php apps/files/l10n/zh_CN.php apps/files/l10n/zh_TW.php apps/files_archive/js/archive.js apps/files_encryption/lib/cryptstream.php apps/files_encryption/lib/proxy.php apps/files_encryption/tests/proxy.php apps/files_external/appinfo/app.php apps/files_external/lib/smb.php apps/files_external/lib/streamwrapper.php apps/files_external/tests/config.php apps/files_external/tests/smb.php apps/files_sharing/ajax/email.php apps/files_sharing/ajax/getitem.php apps/files_sharing/ajax/setpermissions.php apps/files_sharing/ajax/share.php apps/files_sharing/ajax/toggleresharing.php apps/files_sharing/ajax/unshare.php apps/files_sharing/ajax/userautocomplete.php apps/files_sharing/js/settings.js apps/files_sharing/js/share.js apps/files_sharing/lib_share.php apps/files_sharing/settings.php apps/files_sharing/sharedstorage.php apps/files_sharing/templates/settings.php apps/files_versions/ajax/rollbackVersion.php apps/files_versions/versions.php apps/gallery/ajax/thumbnail.php apps/gallery/appinfo/app.php apps/gallery/appinfo/update.php apps/gallery/appinfo/version apps/gallery/css/styles.css apps/gallery/index.php apps/gallery/js/pictures.js apps/gallery/l10n/ca.php apps/gallery/l10n/cs_CZ.php apps/gallery/l10n/de.php apps/gallery/l10n/el.php apps/gallery/l10n/es.php apps/gallery/l10n/fi_FI.php apps/gallery/l10n/fr.php apps/gallery/l10n/it.php apps/gallery/l10n/pl.php apps/gallery/l10n/pt_PT.php apps/gallery/l10n/ru.php apps/gallery/l10n/sl.php apps/gallery/l10n/sv.php apps/gallery/l10n/th_TH.php apps/gallery/l10n/tr.php apps/gallery/l10n/zh_CN.php apps/gallery/lib/album.php apps/gallery/lib/hooks_handlers.php apps/gallery/lib/managers.php apps/gallery/lib/photo.php apps/gallery/lib/tiles.php apps/gallery/lib/tiles_test.php apps/gallery/templates/index.php apps/media/lib_ampache.php apps/media/lib_collection.php apps/media/lib_media.php apps/remoteStorage/lib_remoteStorage.php apps/tasks/ajax/addtaskform.php apps/tasks/ajax/edittask.php apps/user_ldap/appinfo/update.php apps/user_ldap/group_ldap.php apps/user_ldap/lib_ldap.php apps/user_ldap/settings.php apps/user_ldap/templates/settings.php apps/user_ldap/user_ldap.php apps/user_migrate/appinfo/app.php apps/user_migrate/templates/settings.php apps/user_webfinger/host-meta.php config/config.sample.php core/js/js.js core/l10n/da.php core/l10n/de.php core/l10n/fi_FI.php core/l10n/gl.php core/l10n/he.php core/l10n/hr.php core/l10n/id.php core/l10n/ja_JP.php core/l10n/lb.php core/l10n/lt_LT.php core/l10n/nb_NO.php core/l10n/pl.php core/l10n/pt_PT.php core/l10n/ro.php core/l10n/ru.php core/l10n/sv.php core/lostpassword/index.php core/templates/layout.user.php core/templates/login.php db_structure.xml index.php l10n/af/calendar.po l10n/af/contacts.po l10n/af/core.po l10n/af/files.po l10n/af/settings.po l10n/ar/calendar.po l10n/ar/contacts.po l10n/ar/core.po l10n/ar/files.po l10n/ar/media.po l10n/ar/settings.po l10n/bg_BG/calendar.po l10n/bg_BG/contacts.po l10n/bg_BG/core.po l10n/bg_BG/files.po l10n/bg_BG/media.po l10n/bg_BG/settings.po l10n/ca/calendar.po l10n/ca/contacts.po l10n/ca/core.po l10n/ca/files.po l10n/ca/gallery.po l10n/ca/settings.po l10n/cs_CZ/calendar.po l10n/cs_CZ/contacts.po l10n/cs_CZ/core.po l10n/cs_CZ/files.po l10n/cs_CZ/gallery.po l10n/cs_CZ/settings.po l10n/da/calendar.po l10n/da/contacts.po l10n/da/core.po l10n/da/files.po l10n/da/settings.po l10n/de/calendar.po l10n/de/contacts.po l10n/de/core.po l10n/de/files.po l10n/de/gallery.po l10n/de/settings.po l10n/el/calendar.po l10n/el/contacts.po l10n/el/core.po l10n/el/files.po l10n/el/gallery.po l10n/el/settings.po l10n/eo/calendar.po l10n/eo/contacts.po l10n/eo/core.po l10n/eo/files.po l10n/eo/media.po l10n/eo/settings.po l10n/es/calendar.po l10n/es/contacts.po l10n/es/core.po l10n/es/files.po l10n/es/gallery.po l10n/es/settings.po l10n/et_EE/calendar.po l10n/et_EE/contacts.po l10n/et_EE/core.po l10n/et_EE/files.po l10n/et_EE/settings.po l10n/eu/calendar.po l10n/eu/contacts.po l10n/eu/core.po l10n/eu/files.po l10n/eu/settings.po l10n/fa/calendar.po l10n/fa/contacts.po l10n/fa/core.po l10n/fa/files.po l10n/fa/settings.po l10n/fi_FI/calendar.po l10n/fi_FI/contacts.po l10n/fi_FI/core.po l10n/fi_FI/files.po l10n/fi_FI/gallery.po l10n/fi_FI/settings.po l10n/fr/calendar.po l10n/fr/contacts.po l10n/fr/core.po l10n/fr/files.po l10n/fr/gallery.po l10n/fr/media.po l10n/fr/settings.po l10n/gl/calendar.po l10n/gl/contacts.po l10n/gl/core.po l10n/gl/files.po l10n/gl/settings.po l10n/he/calendar.po l10n/he/contacts.po l10n/he/core.po l10n/he/files.po l10n/he/settings.po l10n/hr/calendar.po l10n/hr/contacts.po l10n/hr/core.po l10n/hr/files.po l10n/hr/settings.po l10n/hu_HU/calendar.po l10n/hu_HU/contacts.po l10n/hu_HU/core.po l10n/hu_HU/files.po l10n/hu_HU/settings.po l10n/hy/calendar.po l10n/hy/contacts.po l10n/hy/core.po l10n/hy/files.po l10n/hy/settings.po l10n/ia/calendar.po l10n/ia/contacts.po l10n/ia/core.po l10n/ia/files.po l10n/ia/settings.po l10n/id/calendar.po l10n/id/contacts.po l10n/id/core.po l10n/id/files.po l10n/id/settings.po l10n/it/calendar.po l10n/it/contacts.po l10n/it/core.po l10n/it/files.po l10n/it/gallery.po l10n/it/settings.po l10n/ja_JP/calendar.po l10n/ja_JP/contacts.po l10n/ja_JP/core.po l10n/ja_JP/files.po l10n/ja_JP/settings.po l10n/ko/calendar.po l10n/ko/contacts.po l10n/ko/core.po l10n/ko/files.po l10n/ko/settings.po l10n/lb/calendar.po l10n/lb/contacts.po l10n/lb/core.po l10n/lb/files.po l10n/lb/settings.po l10n/lt_LT/calendar.po l10n/lt_LT/contacts.po l10n/lt_LT/core.po l10n/lt_LT/files.po l10n/lt_LT/settings.po l10n/mk/calendar.po l10n/mk/contacts.po l10n/mk/core.po l10n/mk/files.po l10n/mk/settings.po l10n/ms_MY/calendar.po l10n/ms_MY/contacts.po l10n/ms_MY/core.po l10n/ms_MY/files.po l10n/ms_MY/settings.po l10n/nb_NO/calendar.po l10n/nb_NO/contacts.po l10n/nb_NO/core.po l10n/nb_NO/files.po l10n/nb_NO/settings.po l10n/nl/calendar.po l10n/nl/contacts.po l10n/nl/core.po l10n/nl/files.po l10n/nl/settings.po l10n/nn_NO/calendar.po l10n/nn_NO/contacts.po l10n/nn_NO/core.po l10n/nn_NO/files.po l10n/nn_NO/settings.po l10n/pl/calendar.po l10n/pl/contacts.po l10n/pl/core.po l10n/pl/files.po l10n/pl/gallery.po l10n/pl/settings.po l10n/pt_BR/calendar.po l10n/pt_BR/contacts.po l10n/pt_BR/core.po l10n/pt_BR/files.po l10n/pt_BR/settings.po l10n/pt_PT/calendar.po l10n/pt_PT/contacts.po l10n/pt_PT/core.po l10n/pt_PT/files.po l10n/pt_PT/gallery.po l10n/pt_PT/settings.po l10n/ro/calendar.po l10n/ro/contacts.po l10n/ro/core.po l10n/ro/files.po l10n/ro/settings.po l10n/ru/calendar.po l10n/ru/contacts.po l10n/ru/core.po l10n/ru/files.po l10n/ru/gallery.po l10n/ru/settings.po l10n/sk_SK/calendar.po l10n/sk_SK/contacts.po l10n/sk_SK/core.po l10n/sk_SK/files.po l10n/sk_SK/settings.po l10n/sl/calendar.po l10n/sl/contacts.po l10n/sl/core.po l10n/sl/files.po l10n/sl/gallery.po l10n/sl/settings.po l10n/sr/calendar.po l10n/sr/contacts.po l10n/sr/core.po l10n/sr/files.po l10n/sr/settings.po l10n/sr@latin/calendar.po l10n/sr@latin/contacts.po l10n/sr@latin/core.po l10n/sr@latin/files.po l10n/sr@latin/settings.po l10n/sv/calendar.po l10n/sv/contacts.po l10n/sv/core.po l10n/sv/files.po l10n/sv/gallery.po l10n/sv/media.po l10n/sv/settings.po l10n/templates/bookmarks.pot l10n/templates/calendar.pot l10n/templates/contacts.pot l10n/templates/core.pot l10n/templates/files.pot l10n/templates/gallery.pot l10n/templates/media.pot l10n/templates/settings.pot l10n/th_TH/calendar.po l10n/th_TH/contacts.po l10n/th_TH/core.po l10n/th_TH/files.po l10n/th_TH/gallery.po l10n/th_TH/settings.po l10n/tr/calendar.po l10n/tr/contacts.po l10n/tr/core.po l10n/tr/files.po l10n/tr/gallery.po l10n/tr/settings.po l10n/uk/calendar.po l10n/uk/contacts.po l10n/uk/core.po l10n/uk/files.po l10n/uk/media.po l10n/uk/settings.po l10n/zh_CN/calendar.po l10n/zh_CN/contacts.po l10n/zh_CN/core.po l10n/zh_CN/files.po l10n/zh_CN/gallery.po l10n/zh_CN/settings.po l10n/zh_TW/calendar.po l10n/zh_TW/contacts.po l10n/zh_TW/core.po l10n/zh_TW/files.po l10n/zh_TW/settings.po lib/app.php lib/base.php lib/connector/sabre/file.php lib/connector/sabre/locks.php lib/connector/sabre/node.php lib/db.php lib/filecache.php lib/fileproxy/quota.php lib/files.php lib/filestorage/local.php lib/filesystemview.php lib/group/database.php lib/helper.php lib/installer.php lib/json.php lib/l10n.php lib/migrate.php lib/mimetypes.fixlist.php lib/ocs.php lib/preferences.php lib/public/json.php lib/public/util.php lib/template.php lib/user.php lib/user/database.php lib/util.php lib/vcategories.php ocs/providers.php settings/admin.php settings/ajax/lostpassword.php settings/ajax/removeuser.php settings/ajax/setbackgroundjobsmode.php settings/ajax/setlanguage.php settings/ajax/setquota.php settings/ajax/togglegroups.php settings/apps.php settings/css/settings.css settings/js/apps.js settings/js/users.js settings/l10n/bg_BG.php settings/l10n/ca.php settings/l10n/cs_CZ.php settings/l10n/da.php settings/l10n/de.php settings/l10n/el.php settings/l10n/eo.php settings/l10n/es.php settings/l10n/et_EE.php settings/l10n/eu.php settings/l10n/fa.php settings/l10n/fi_FI.php settings/l10n/fr.php settings/l10n/gl.php settings/l10n/he.php settings/l10n/hr.php settings/l10n/hu_HU.php settings/l10n/it.php settings/l10n/ja_JP.php settings/l10n/ko.php settings/l10n/lt_LT.php settings/l10n/mk.php settings/l10n/ms_MY.php settings/l10n/nb_NO.php settings/l10n/nl.php settings/l10n/nn_NO.php settings/l10n/pl.php settings/l10n/pt_BR.php settings/l10n/pt_PT.php settings/l10n/ru.php settings/l10n/sk_SK.php settings/l10n/sl.php settings/l10n/sv.php settings/l10n/th_TH.php settings/l10n/tr.php settings/l10n/zh_CN.php settings/personal.php settings/templates/admin.php settings/templates/users.php
2012-08-24 22:05:07 +00:00
return this.filter(function() { return $(this).attr(attr_name) === attr_value; });
};
2012-02-26 13:03:53 +00:00
function humanFileSize(size) {
2012-09-23 01:16:52 +00:00
var humanList = ['B', 'kB', 'MB', 'GB', 'TB'];
2012-02-26 13:03:53 +00:00
// Calculate Log with base 1024: size = 1024 ** order
2012-11-06 10:01:02 +00:00
var order = size?Math.floor(Math.log(size) / Math.log(1024)):0;
2012-02-26 13:03:53 +00:00
// Stay in range of the byte sizes that are defined
order = Math.min(humanList.length - 1, order);
2012-09-23 01:16:52 +00:00
var readableFormat = humanList[order];
var relativeSize = (size / Math.pow(1024, order)).toFixed(1);
if(order < 2){
relativeSize = parseFloat(relativeSize).toFixed(0);
2013-12-18 14:43:45 +00:00
}
else if(relativeSize.substr(relativeSize.length-2,2)==='.0'){
2012-02-26 13:03:53 +00:00
relativeSize=relativeSize.substr(0,relativeSize.length-2);
2012-02-25 20:19:32 +00:00
}
2012-02-26 13:03:53 +00:00
return relativeSize + ' ' + readableFormat;
2012-02-25 20:19:32 +00:00
}
2012-02-25 20:19:32 +00:00
function formatDate(date){
if(typeof date=='number'){
date=new Date(date);
}
return $.datepicker.formatDate(datepickerFormatDate, date)+' '+date.getHours()+':'+((date.getMinutes()<10)?'0':'')+date.getMinutes();
2012-02-25 20:19:32 +00:00
}
// taken from http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
function getURLParameter(name) {
return decodeURI(
(RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1]
);
}
/**
* takes an absolute timestamp and return a string with a human-friendly relative date
* @param int a Unix timestamp
*/
function relative_modified_date(timestamp) {
var timediff = Math.round((new Date()).getTime() / 1000) - timestamp;
var diffminutes = Math.round(timediff/60);
var diffhours = Math.round(diffminutes/60);
var diffdays = Math.round(diffhours/24);
var diffmonths = Math.round(diffdays/31);
if(timediff < 60) { return t('core','seconds ago'); }
2013-08-09 18:37:18 +00:00
else if(timediff < 3600) { return n('core','%n minute ago', '%n minutes ago', diffminutes); }
else if(timediff < 86400) { return n('core', '%n hour ago', '%n hours ago', diffhours); }
else if(timediff < 86400) { return t('core','today'); }
else if(timediff < 172800) { return t('core','yesterday'); }
2013-08-09 18:37:18 +00:00
else if(timediff < 2678400) { return n('core', '%n day ago', '%n days ago', diffdays); }
else if(timediff < 5184000) { return t('core','last month'); }
2013-08-09 18:37:18 +00:00
else if(timediff < 31556926) { return n('core', '%n month ago', '%n months ago', diffmonths); }
//else if(timediff < 31556926) { return t('core','months ago'); }
else if(timediff < 63113852) { return t('core','last year'); }
else { return t('core','years ago'); }
}
OC.Util = {
/**
* Returns whether the browser supports SVG
*
* @return true if the browser supports SVG, false otherwise
*/
// TODO: replace with original function
hasSVGSupport: SVGSupport,
/**
* If SVG is not supported, replaces the given icon's extension
* from ".svg" to ".png".
* If SVG is supported, return the image path as is.
*
* @param file image path with svg extension
* @return fixed image path with png extension if SVG is not
* supported
*/
replaceSVGIcon: function(file) {
if (!OC.Util.hasSVGSupport()) {
var i = file.lastIndexOf('.svg');
if (i >= 0) {
file = file.substr(0, i) + '.png' + file.substr(i+4);
}
}
return file;
},
/**
* Replace SVG images in all elements that have the "svg" class set
* with PNG images.
*
* @param $el root element from which to search, defaults to $('body')
*/
replaceSVG: function($el) {
if (!$el) {
$el = $('body');
}
$el.find('img.svg').each(function(index,element){
element=$(element);
var src=element.attr('src');
element.attr('src',src.substr(0, src.length-3) + 'png');
});
$el.find('.svg').each(function(index,element){
element = $(element);
var background = element.css('background-image');
if (background){
var i = background.lastIndexOf('.svg');
if (i >= 0){
background = background.substr(0,i) + '.png' + background.substr(i + 4);
element.css('background-image', background);
}
}
element.find('*').each(function(index, element) {
element = $(element);
var background = element.css('background-image');
if (background) {
var i = background.lastIndexOf('.svg');
if(i >= 0){
background = background.substr(0,i) + '.png' + background.substr(i + 4);
element.css('background-image', background);
}
}
});
});
}
};
/**
* get a variable by name
* @param string name
*/
OC.get=function(name) {
var namespaces = name.split(".");
var tail = namespaces.pop();
var context=window;
for(var i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]];
if(!context){
return false;
}
}
return context[tail];
2012-09-23 01:16:52 +00:00
};
/**
* set a variable by name
* @param string name
* @param mixed value
*/
OC.set=function(name, value) {
var namespaces = name.split(".");
var tail = namespaces.pop();
var context=window;
for(var i = 0; i < namespaces.length; i++) {
if(!context[namespaces[i]]){
context[namespaces[i]]={};
}
context = context[namespaces[i]];
}
context[tail]=value;
2012-09-23 01:16:52 +00:00
};
2014-02-20 17:42:59 +00:00
// fix device width on windows phone
(function() {
if ("-ms-user-select" in document.documentElement.style && navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode("@-ms-viewport{width:auto!important}")
);
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
})();
/**
* select a range in an input field
* @link http://stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area
* @param {type} start
* @param {type} end
*/
2013-09-16 11:47:37 +00:00
jQuery.fn.selectRange = function(start, end) {
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();
}
});
};
2013-09-16 11:47:37 +00:00
/**
* check if an element exists.
* allows you to write if ($('#myid').exists()) to increase readability
* @link http://stackoverflow.com/questions/31044/is-there-an-exists-function-for-jquery
*/
jQuery.fn.exists = function(){
return this.length > 0;
};
2013-09-16 11:47:37 +00:00