diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-04 13:55:49 +0200 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-09-04 14:11:40 +0200 |
commit | 4af5a8c483278eae2e8e38f5ea0a238072848b87 (patch) | |
tree | beca3f5250e1a50eca58fa63eea056b69ab82e44 /core/js | |
parent | 7c9d9992432839f2265b8f6b0f43ed15bfca9ff1 (diff) | |
parent | 09187f3b3b30e6f810c6afff7332615ed472154e (diff) | |
download | nextcloud-server-4af5a8c483278eae2e8e38f5ea0a238072848b87.tar.gz nextcloud-server-4af5a8c483278eae2e8e38f5ea0a238072848b87.zip |
Merge branch 'master' into fix_3728_with_file_exists_dialog
Conflicts:
apps/files/ajax/upload.php
apps/files/js/file-upload.js
apps/files/js/filelist.js
apps/files/js/files.js
apps/files/templates/part.list.php
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/compatibility.js | 2 | ||||
-rw-r--r-- | core/js/config.js | 4 | ||||
-rw-r--r-- | core/js/jquery.infieldlabel.js | 2 | ||||
-rw-r--r-- | core/js/jquery.inview.js | 2 | ||||
-rw-r--r-- | core/js/jquery.ocdialog.js | 4 | ||||
-rw-r--r-- | core/js/js.js | 66 | ||||
-rw-r--r-- | core/js/listview.js | 4 | ||||
-rw-r--r-- | core/js/multiselect.js | 4 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 52 | ||||
-rw-r--r-- | core/js/oc-requesttoken.js | 5 | ||||
-rw-r--r-- | core/js/oc-vcategories.js | 2 | ||||
-rw-r--r-- | core/js/octemplate.js | 9 | ||||
-rw-r--r-- | core/js/placeholder.js | 62 | ||||
-rw-r--r-- | core/js/router.js | 2 | ||||
-rw-r--r-- | core/js/share.js | 28 | ||||
-rw-r--r-- | core/js/visitortimezone.js | 2 |
16 files changed, 166 insertions, 84 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 ce991052271..0266599d21d 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'); @@ -158,7 +158,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' diff --git a/core/js/js.js b/core/js/js.js index 64b5556987d..1999ff73d23 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -69,7 +69,7 @@ function initL10N(app) { 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 ["+plural_forms+"]"); + console.log("Syntax error in language file. Plural-Forms header is invalid ["+t.plural_forms+"]"); } } } @@ -431,9 +431,16 @@ OC.Notification={ OC.Breadcrumb={ container:null, - crumbs:[], show:function(dir, leafname, leaflink){ - OC.Breadcrumb.clear(); + 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); // show home + path in subdirectories if (dir && dir !== '/') { @@ -450,8 +457,7 @@ OC.Breadcrumb={ crumbImg.attr('src',OC.imagePath('core','places/home')); crumbLink.append(crumbImg); crumb.append(crumbLink); - OC.Breadcrumb.container.prepend(crumb); - OC.Breadcrumb.crumbs.push(crumb); + container.prepend(crumb); //add path parts var segments = dir.split('/'); @@ -460,20 +466,23 @@ OC.Breadcrumb={ if (name !== '') { pathurl = pathurl+'/'+name; var link = OC.linkTo('files','index.php')+'?dir='+encodeURIComponent(pathurl); - OC.Breadcrumb.push(name, link); + self._push(container, name, link); } }); } //add leafname if (leafname && leaflink) { - OC.Breadcrumb.push(leafname, leaflink); + this._push(container, leafname, leaflink); } }, push:function(name, link){ - if(!OC.Breadcrumb.container){//default - OC.Breadcrumb.container=$('#controls'); + if(!this.container){//default + this.container=$('#controls'); } + return this._push(OC.Breadcrumb.container, name, link); + }, + _push:function(container, name, link){ var crumb=$('<div/>'); crumb.addClass('crumb').addClass('last'); @@ -482,30 +491,30 @@ OC.Breadcrumb={ crumbLink.text(name); crumb.append(crumbLink); - var existing=OC.Breadcrumb.container.find('div.crumb'); + var existing=container.find('div.crumb'); if(existing.length){ existing.removeClass('last'); existing.last().after(crumb); }else{ - OC.Breadcrumb.container.prepend(crumb); + container.prepend(crumb); } - OC.Breadcrumb.crumbs.push(crumb); return crumb; }, pop:function(){ - if(!OC.Breadcrumb.container){//default - OC.Breadcrumb.container=$('#controls'); + if(!this.container){//default + this.container=$('#controls'); } - OC.Breadcrumb.container.find('div.crumb').last().remove(); - OC.Breadcrumb.container.find('div.crumb').last().addClass('last'); - OC.Breadcrumb.crumbs.pop(); + this.container.find('div.crumb').last().remove(); + this.container.find('div.crumb').last().addClass('last'); }, clear:function(){ - if(!OC.Breadcrumb.container){//default - OC.Breadcrumb.container=$('#controls'); + if(!this.container){//default + this.container=$('#controls'); } - OC.Breadcrumb.container.find('div.crumb').remove(); - OC.Breadcrumb.crumbs=[]; + this._clear(this.container); + }, + _clear:function(container) { + container.find('div.crumb').remove(); } }; @@ -709,7 +718,6 @@ $(document).ready(function(){ }); label.hide(); }; - setShowPassword($('#password'), $('label[for=show]')); setShowPassword($('#adminpass'), $('label[for=show]')); setShowPassword($('#pass2'), $('label[for=personal-show]')); setShowPassword($('#dbpass'), $('label[for=dbpassword]')); @@ -758,13 +766,11 @@ $(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.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}); @@ -813,15 +819,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'); } 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 a101cce9d1f..b949fc74d14 100644 --- a/core/js/oc-dialogs.js +++ b/core/js/oc-dialogs.js @@ -77,11 +77,17 @@ var OCdialogs = { self.$filePicker = $tmpl.octemplate({ dialog_name: dialog_name, title: title - }).data('path', ''); + }).data('path', '').data('multiselect', multiselect).data('mimetype', mimetype_filter); - 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); @@ -94,7 +100,7 @@ var OCdialogs = { self._handlePickerClick(event, $(this)); }); self._fillFilePicker(''); - }).data('multiselect', multiselect).data('mimetype',mimetype_filter); + }); // build buttons var functionToCall = function() { @@ -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, @@ -502,13 +512,17 @@ 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, date: OC.mtime2date(entry.mtime) }); - $li.find('img').attr('src', entry.mimetype_icon); + if (entry.mimetype === "httpd/unix-directory") { + $li.find('img').attr('src', OC.imagePath('core', 'filetypes/folder.png')); + } else { + $li.find('img').attr('src', OC.Router.generate('core_ajax_preview', {x:32, y:32, file:escapeHTML(dir+'/'+entry.name)}) ); + } self.$filelist.append($li); }); @@ -526,7 +540,7 @@ var OCdialogs = { if(path) { var paths = path.split('/'); $.each(paths, function(index, dir) { - var dir = paths.pop(); + dir = paths.pop(); if(dir === '') { return false; } @@ -560,7 +574,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..0d7f40c592a 100644 --- a/core/js/oc-requesttoken.js +++ b/core/js/oc-requesttoken.js @@ -1,3 +1,4 @@ -$(document).bind('ajaxSend', function(elm, xhr, s) { +$(document).on('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/octemplate.js b/core/js/octemplate.js index e69c6cc56e0..46ffa976574 100644 --- a/core/js/octemplate.js +++ b/core/js/octemplate.js @@ -60,9 +60,10 @@ var self = this; if(typeof this.options.escapeFunction === 'function') { - for (var key = 0; key < this.vars.length; key++) { - if(typeof this.vars[key] === 'string') { - this.vars[key] = self.options.escapeFunction(this.vars[key]); + var keys = Object.keys(this.vars); + for (var key = 0; key < keys.length; key++) { + if(typeof this.vars[keys[key]] === 'string') { + this.vars[keys[key]] = self.options.escapeFunction(this.vars[keys[key]]); } } } @@ -85,7 +86,7 @@ } }, options: { - escapeFunction: function(str) {return $('<i></i>').text(str).html();} + escapeFunction: escapeHTML } }; diff --git a/core/js/placeholder.js b/core/js/placeholder.js new file mode 100644 index 00000000000..d63730547d7 --- /dev/null +++ b/core/js/placeholder.js @@ -0,0 +1,62 @@ +/** + * ownCloud + * + * @author Morris Jobke + * @copyright 2013 Morris Jobke <morris.jobke@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/* + * Adds a background color to the element called on and adds the first character + * of the passed in string. This string is also the seed for the generation of + * the background color. + * + * You have following HTML: + * + * <div id="albumart"></div> + * + * And call this from Javascript: + * + * $('#albumart').placeholder('The Album Title'); + * + * Which will result in: + * + * <div id="albumart" style="background-color: hsl(123, 90%, 65%); ... ">T</div> + * + */ + +(function ($) { + $.fn.placeholder = function(seed) { + var hash = md5(seed), + maxRange = parseInt('ffffffffffffffffffffffffffffffff', 16), + hue = parseInt(hash, 16) / maxRange * 256, + height = this.height(); + this.css('background-color', 'hsl(' + hue + ', 90%, 65%)'); + + // CSS rules + this.css('color', '#fff'); + this.css('font-weight', 'bold'); + this.css('text-align', 'center'); + + // calculate the height + this.css('line-height', height + 'px'); + this.css('font-size', (height * 0.55) + 'px'); + + if(seed !== null && seed.length) { + this.html(seed[0].toUpperCase()); + } + }; +}(jQuery)); 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 a0ae39fffed..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(); 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 +}); |