aboutsummaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
Diffstat (limited to 'core/js')
-rw-r--r--core/js/compatibility.js2
-rw-r--r--core/js/config.js4
-rw-r--r--core/js/jquery.infieldlabel.js2
-rw-r--r--core/js/jquery.inview.js2
-rw-r--r--core/js/jquery.ocdialog.js10
-rw-r--r--core/js/js.js139
-rw-r--r--core/js/listview.js4
-rw-r--r--core/js/multiselect.js4
-rw-r--r--core/js/oc-dialogs.js44
-rw-r--r--core/js/oc-requesttoken.js2
-rw-r--r--core/js/oc-vcategories.js2
-rw-r--r--core/js/router.js2
-rw-r--r--core/js/share.js32
-rw-r--r--core/js/visitortimezone.js2
14 files changed, 159 insertions, 92 deletions
diff --git a/core/js/compatibility.js b/core/js/compatibility.js
index b690803ca77..6548f95d42b 100644
--- a/core/js/compatibility.js
+++ b/core/js/compatibility.js
@@ -24,7 +24,7 @@ if (typeof Object.keys !== 'function') {
}
}
return k;
- }
+ };
}
/**
diff --git a/core/js/config.js b/core/js/config.js
index 563df4e6632..52d1c3aee25 100644
--- a/core/js/config.js
+++ b/core/js/config.js
@@ -9,7 +9,7 @@ OC.AppConfig={
getCall:function(action,data,callback){
data.action=action;
$.getJSON(OC.AppConfig.url,data,function(result){
- if(result.status='success'){
+ if(result.status==='success'){
if(callback){
callback(result.data);
}
@@ -19,7 +19,7 @@ OC.AppConfig={
postCall:function(action,data,callback){
data.action=action;
$.post(OC.AppConfig.url,data,function(result){
- if(result.status='success'){
+ if(result.status==='success'){
if(callback){
callback(result.data);
}
diff --git a/core/js/jquery.infieldlabel.js b/core/js/jquery.infieldlabel.js
index 8a76da1b140..fad15102bcb 100644
--- a/core/js/jquery.infieldlabel.js
+++ b/core/js/jquery.infieldlabel.js
@@ -174,4 +174,4 @@
});
};
-}(jQuery)); \ No newline at end of file
+}(jQuery));
diff --git a/core/js/jquery.inview.js b/core/js/jquery.inview.js
index 9687cd83368..511ae95415e 100644
--- a/core/js/jquery.inview.js
+++ b/core/js/jquery.inview.js
@@ -131,4 +131,4 @@
// By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays
// intervals while the user scrolls. Therefore the inview event might fire a bit late there
setInterval(checkInView, 250);
-})(jQuery); \ No newline at end of file
+})(jQuery);
diff --git a/core/js/jquery.ocdialog.js b/core/js/jquery.ocdialog.js
index 7413927e3b2..bafbd0e0e9f 100644
--- a/core/js/jquery.ocdialog.js
+++ b/core/js/jquery.ocdialog.js
@@ -13,7 +13,7 @@
this.originalCss = {
display: this.element[0].style.display,
width: this.element[0].style.width,
- height: this.element[0].style.height,
+ height: this.element[0].style.height
};
this.originalTitle = this.element.attr('title');
@@ -152,7 +152,7 @@
content_height -= this.$buttonrow.outerHeight(true);
}
this.parent = this.$dialog.parent().length > 0 ? this.$dialog.parent() : $('body');
- content_height = Math.min(content_height, this.parent.height()-20)
+ content_height = Math.min(content_height, this.parent.height()-20);
this.element.css({
height: content_height + 'px',
width: this.$dialog.innerWidth()-20 + 'px'
@@ -187,7 +187,7 @@
}
},
widget: function() {
- return this.$dialog
+ return this.$dialog;
},
close: function() {
this._destroyOverlay();
@@ -200,10 +200,10 @@
},
destroy: function() {
if(this.$title) {
- this.$title.remove()
+ this.$title.remove();
}
if(this.$buttonrow) {
- this.$buttonrow.remove()
+ this.$buttonrow.remove();
}
if(this.originalTitle) {
diff --git a/core/js/js.js b/core/js/js.js
index 03f660be62c..d580b6113e6 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -1,6 +1,6 @@
/**
* Disable console output unless DEBUG mode is enabled.
- * Add
+ * Add
* define('DEBUG', true);
* To the end of config/config.php to enable debug mode.
* The undefined checks fix the broken ie8 console
@@ -24,60 +24,121 @@ if (oc_debug !== true || typeof console === "undefined" || typeof console.log ==
}
}
-/**
- * translate a string
- * @param app the id of the app for which to translate the string
- * @param text the string to translate
- * @return string
- */
-function t(app,text, vars){
- if( !( t.cache[app] )){
- $.ajax(OC.filePath('core','ajax','translations.php'),{
- async:false,//todo a proper sollution for this without sync ajax calls
- data:{'app': app},
- type:'POST',
- success:function(jsondata){
+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) {
t.cache[app] = jsondata.data;
+ t.plural_form = jsondata.plural_form;
}
});
// Bad answer ...
- if( !( t.cache[app] )){
+ if (!( t.cache[app] )) {
t.cache[app] = [];
}
}
- var _build = function (text, vars) {
- return text.replace(/{([^{}]*)}/g,
+ if (typeof t.plural_function == 'undefined') {
+ t.plural_function = 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 = new Function("n", code);
+ } else {
+ 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,
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' ){
- if(typeof vars === 'object') {
- return _build(t.cache[app][text], vars);
- } else {
- return t.cache[app][text];
+ translation = t.cache[app][text];
+ }
+
+ if(typeof vars === 'object' || count !== undefined ) {
+ return _build(translation, vars, count);
+ } else {
+ return translation;
+ }
+}
+t.cache = {};
+
+/**
+ * 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);
+ 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);
+ return t(app, translation[plural.plural], vars, count);
}
}
+
+ if(count === 1) {
+ return t(app, text_singular, vars, count);
+ }
else{
- if(typeof vars === 'object') {
- return _build(text, vars);
- } else {
- return text;
- }
+ return t(app, text_plural, vars, count);
}
}
-t.cache={};
-/*
+/**
* Sanitizes a HTML string
-* @param string
+* @param s string
* @return Sanitized string
*/
function escapeHTML(s) {
- return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');
+ return s.toString().split('&').join('&amp;').split('<').join('&lt;').split('"').join('&quot;');
}
/**
@@ -96,6 +157,7 @@ var OC={
PERMISSION_UPDATE:2,
PERMISSION_DELETE:8,
PERMISSION_SHARE:16,
+ PERMISSION_ALL:31,
webroot:oc_webroot,
appswebroots:(typeof oc_appswebroots !== 'undefined') ? oc_appswebroots:false,
currentUser:(typeof oc_current_user!=='undefined')?oc_current_user:false,
@@ -696,13 +758,10 @@ $(document).ready(function(){
});
// all the tipsy stuff needs to be here (in reverse order) to work
- $('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true});
- $('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true});
$('.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.delete').tipsy({gravity: 'e', fade:true, live:true});
$('a.action').tipsy({gravity:'s', fade:true, live:true});
$('td .modified').tipsy({gravity:'s', fade:true, live:true});
@@ -751,15 +810,13 @@ function relative_modified_date(timestamp) {
var diffdays = Math.round(diffhours/24);
var diffmonths = Math.round(diffdays/31);
if(timediff < 60) { return t('core','seconds ago'); }
- else if(timediff < 120) { return t('core','1 minute ago'); }
- else if(timediff < 3600) { return t('core','{minutes} minutes ago',{minutes: diffminutes}); }
- else if(timediff < 7200) { return t('core','1 hour ago'); }
- else if(timediff < 86400) { return t('core','{hours} hours ago',{hours: diffhours}); }
+ 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'); }
- else if(timediff < 2678400) { return t('core','{days} days ago',{days: diffdays}); }
+ else if(timediff < 2678400) { return n('core', '%n day ago', '%n days ago', diffdays); }
else if(timediff < 5184000) { return t('core','last month'); }
- else if(timediff < 31556926) { return t('core','{months} months ago',{months: diffmonths}); }
+ 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'); }
@@ -773,7 +830,7 @@ 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){
@@ -792,7 +849,7 @@ 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]]={};
diff --git a/core/js/listview.js b/core/js/listview.js
index 3a713a6222c..18d0bdeaf7c 100644
--- a/core/js/listview.js
+++ b/core/js/listview.js
@@ -11,11 +11,11 @@ ListView.generateTable=function(collumns){
html+='<thead>';
html+='</head>';
html+='<tbody>';
- html+'<tr class="template">';
+ html+='<tr class="template">';
$.each(collumns,function(index,collumn){
html+='<th class="'+collumn.toLower()+'"</th>';
});
- html+'</tr>';
+ html+='</tr>';
html+='</tbody>';
html='</table>';
return $(html);
diff --git a/core/js/multiselect.js b/core/js/multiselect.js
index 48d521e1856..373fd2d41a2 100644
--- a/core/js/multiselect.js
+++ b/core/js/multiselect.js
@@ -25,7 +25,7 @@
'labels':[],
'oncheck':false,
'onuncheck':false,
- 'minWidth': 'default;',
+ 'minWidth': 'default;'
};
$(this).attr('data-msid', multiSelectId);
$.extend(settings,options);
@@ -200,7 +200,7 @@
return false;
}
var li=$(this).parent();
- var val = $(this).val()
+ var val = $(this).val();
var select=button.parent().next();
if(typeof settings.createCallback === 'function') {
var response = settings.createCallback(select, val);
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index f4bc174b5eb..4092b8d0746 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -79,9 +79,15 @@ var OCdialogs = {
title: title
}).data('path', '');
- if (modal === undefined) { modal = false };
- if (multiselect === undefined) { multiselect = false };
- if (mimetype_filter === undefined) { mimetype_filter = '' };
+ if (modal === undefined) {
+ modal = false;
+ }
+ if (multiselect === undefined) {
+ multiselect = false;
+ }
+ if (mimetype_filter === undefined) {
+ mimetype_filter = '';
+ }
$('body').append(self.$filePicker);
@@ -106,7 +112,7 @@ var OCdialogs = {
datapath.push(self.$filePicker.data('path') + '/' + $(element).text());
});
} else {
- var datapath = self.$filePicker.data('path');
+ datapath = self.$filePicker.data('path');
datapath += '/' + self.$filelist.find('.filepicker_element_selected .filename').text();
}
callback(datapath);
@@ -117,10 +123,6 @@ var OCdialogs = {
text: t('core', 'Choose'),
click: functionToCall,
defaultButton: true
- },
- {
- text: t('core', 'Cancel'),
- click: function(){self.$filePicker.ocdialog('close'); }
}];
self.$filePicker.ocdialog({
@@ -155,7 +157,9 @@ var OCdialogs = {
message: content,
type: dialog_type
});
- if (modal === undefined) { modal = false };
+ if (modal === undefined) {
+ modal = false;
+ }
$('body').append($dlg);
var buttonlist = [];
switch (buttons) {
@@ -163,7 +167,9 @@ var OCdialogs = {
buttonlist = [{
text: t('core', 'Yes'),
click: function(){
- if (callback !== undefined) { callback(true) };
+ if (callback !== undefined) {
+ callback(true);
+ }
$(dialog_id).ocdialog('close');
},
defaultButton: true
@@ -171,7 +177,9 @@ var OCdialogs = {
{
text: t('core', 'No'),
click: function(){
- if (callback !== undefined) { callback(false) };
+ if (callback !== undefined) {
+ callback(false);
+ }
$(dialog_id).ocdialog('close');
}
}];
@@ -179,7 +187,9 @@ var OCdialogs = {
case OCdialogs.OK_BUTTON:
var functionToCall = function() {
$(dialog_id).ocdialog('close');
- if(callback !== undefined) { callback() };
+ if(callback !== undefined) {
+ callback();
+ }
};
buttonlist[0] = {
text: t('core', 'Ok'),
@@ -187,7 +197,7 @@ var OCdialogs = {
defaultButton: true
};
break;
- };
+ }
$(dialog_id).ocdialog({
closeOnEscape: true,
@@ -269,7 +279,7 @@ var OCdialogs = {
var sorted = dirs.concat(others);
$.each(sorted, function(idx, entry) {
- $li = self.$listTmpl.octemplate({
+ var $li = self.$listTmpl.octemplate({
type: entry.type,
dir: dir,
filename: entry.name,
@@ -287,13 +297,13 @@ var OCdialogs = {
*/
_fillSlug: function() {
this.$dirTree.empty();
- var self = this
+ var self = this;
var path = this.$filePicker.data('path');
var $template = $('<span data-dir="{dir}">{name}</span>');
if(path) {
var paths = path.split('/');
$.each(paths, function(index, dir) {
- var dir = paths.pop();
+ dir = paths.pop();
if(dir === '') {
return false;
}
@@ -327,7 +337,7 @@ var OCdialogs = {
$element.toggleClass('filepicker_element_selected');
return;
} else if ( $element.data('type') === 'dir' ) {
- this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'))
+ this._fillFilePicker(this.$filePicker.data('path') + '/' + $element.data('entryname'));
}
}
};
diff --git a/core/js/oc-requesttoken.js b/core/js/oc-requesttoken.js
index f4cf286b8aa..6cc6b5a855b 100644
--- a/core/js/oc-requesttoken.js
+++ b/core/js/oc-requesttoken.js
@@ -1,3 +1,3 @@
$(document).bind('ajaxSend', function(elm, xhr, s) {
xhr.setRequestHeader('requesttoken', oc_requesttoken);
-}); \ No newline at end of file
+});
diff --git a/core/js/oc-vcategories.js b/core/js/oc-vcategories.js
index c745dbc5fbd..c297a24680d 100644
--- a/core/js/oc-vcategories.js
+++ b/core/js/oc-vcategories.js
@@ -23,7 +23,7 @@ var OCCategories= {
d.css('cursor', 'wait').find('input,button:not(#category_addbutton)')
.prop('disabled', true).css('cursor', 'wait');
}
- }
+ };
var dlg = $('#edit_categories_dialog').dialog({
modal: true,
height: 350, minHeight:200, width: 250, minWidth: 200,
diff --git a/core/js/router.js b/core/js/router.js
index b94721673a7..44e7c30602e 100644
--- a/core/js/router.js
+++ b/core/js/router.js
@@ -1,4 +1,4 @@
-OC.router_base_url = OC.webroot + '/index.php',
+OC.router_base_url = OC.webroot + '/index.php';
OC.Router = {
// register your ajax requests to load after the loading of the routes
// has finished. otherwise you face problems with race conditions
diff --git a/core/js/share.js b/core/js/share.js
index b4b5159b0b5..27c16f38b92 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -22,9 +22,9 @@ OC.Share={
if (itemType != 'file' && itemType != 'folder') {
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
} else {
- var file = $('tr').filterAttr('data-id', item);
+ var file = $('tr[data-id="'+item+'"]');
if (file.length > 0) {
- var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
+ var action = $(file).find('.fileactions .action[data-action="Share"]');
var img = action.find('img').attr('src', image);
action.addClass('permanent');
action.html(' '+t('core', 'Shared')).prepend(img);
@@ -36,7 +36,7 @@ OC.Share={
// Search for possible parent folders that are shared
while (path != last) {
if (path == data['path']) {
- var actions = $('.fileactions .action').filterAttr('data-action', 'Share');
+ var actions = $('.fileactions .action[data-action="Share"]');
$.each(actions, function(index, action) {
var img = $(action).find('img');
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
@@ -103,9 +103,9 @@ OC.Share={
var checkReshare = true;
if (typeof OC.Share.statuses[itemSource] === 'undefined') {
// NOTE: Check does not always work and misses some shares, fix later
- checkShares = true;
+ var checkShares = true;
} else {
- checkShares = true;
+ var checkShares = true;
}
$.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, itemSource: itemSource, checkReshare: checkReshare, checkShares: checkShares }, async: false, success: function(result) {
if (result && result.status === 'success') {
@@ -228,23 +228,23 @@ OC.Share={
});
}
$('#shareWith').autocomplete({minLength: 1, source: function(search, response) {
- // if (cache[search.term]) {
- // response(cache[search.term]);
- // } else {
+ // if (cache[search.term]) {
+ // response(cache[search.term]);
+ // } else {
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: OC.Share.itemShares }, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
} else {
// Suggest sharing via email if valid email address
-// var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
-// if (pattern.test(search.term)) {
-// response([{label: t('core', 'Share via email:')+' '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]);
-// } else {
+// var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
+// if (pattern.test(search.term)) {
+// response([{label: t('core', 'Share via email:')+' '+search.term, value: {shareType: OC.Share.SHARE_TYPE_EMAIL, shareWith: search.term}}]);
+// } else {
response([t('core', 'No people found')]);
-// }
+// }
}
});
- // }
+ // }
},
focus: function(event, focused) {
event.preventDefault();
@@ -256,8 +256,8 @@ OC.Share={
var shareType = selected.item.value.shareType;
var shareWith = selected.item.value.shareWith;
$(this).val(shareWith);
- // Default permissions are Read and Share
- var permissions = OC.PERMISSION_READ | OC.PERMISSION_SHARE;
+ // Default permissions are Edit (CRUD) and Share
+ var permissions = OC.PERMISSION_ALL;
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, function() {
OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, possiblePermissions);
$('#shareWith').val('');
diff --git a/core/js/visitortimezone.js b/core/js/visitortimezone.js
index 58a1e9ea355..ee0105c783d 100644
--- a/core/js/visitortimezone.js
+++ b/core/js/visitortimezone.js
@@ -1,4 +1,4 @@
$(document).ready(function () {
var visitortimezone = (-new Date().getTimezoneOffset() / 60);
$('#timezone-offset').val(visitortimezone);
-}); \ No newline at end of file
+});