summaryrefslogtreecommitdiffstats
path: root/core/js
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-10-30 06:53:49 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-10-30 06:53:49 +0100
commit5550cde03b34e86671652258e7f3bbc2a92b6111 (patch)
treeec6dd9ac1465a3ae4b9e4bbffdc1c87b78621b4b /core/js
parentd9d8da0a5cee5fac1e5f24a321dd612f312af508 (diff)
parent3fdf239b478273155a68ec4ede8d4e4dd54b504d (diff)
downloadnextcloud-server-5550cde03b34e86671652258e7f3bbc2a92b6111.tar.gz
nextcloud-server-5550cde03b34e86671652258e7f3bbc2a92b6111.zip
Merge branch 'master' of github.com:owncloud/core into vcategories_db
Fix conflicts: core/ajax/vcategories/add.php core/ajax/vcategories/delete.php
Diffstat (limited to 'core/js')
-rw-r--r--core/js/jquery.infieldlabel.js140
-rw-r--r--core/js/jquery.infieldlabel.min.js22
-rw-r--r--core/js/js.js13
-rw-r--r--core/js/router.js73
-rw-r--r--core/js/share.js54
5 files changed, 130 insertions, 172 deletions
diff --git a/core/js/jquery.infieldlabel.js b/core/js/jquery.infieldlabel.js
deleted file mode 100644
index f6a67b66ce1..00000000000
--- a/core/js/jquery.infieldlabel.js
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * In-Field Label jQuery Plugin
- * http://fuelyourcoding.com/scripts/infield.html
- *
- * Copyright (c) 2009 Doug Neiner
- * Dual licensed under the MIT and GPL licenses.
- * Uses the same license as jQuery, see:
- * http://docs.jquery.com/License
- *
- * @version 0.1
- */
-(function($){
-
- $.InFieldLabels = function(label,field, options){
- // To avoid scope issues, use 'base' instead of 'this'
- // to reference this class from internal events and functions.
- var base = this;
-
- // Access to jQuery and DOM versions of each element
- base.$label = $(label);
- base.label = label;
-
- base.$field = $(field);
- base.field = field;
-
- base.$label.data("InFieldLabels", base);
- base.showing = true;
-
- base.init = function(){
- // Merge supplied options with default options
- base.options = $.extend({},$.InFieldLabels.defaultOptions, options);
-
- // Check if the field is already filled in
- if(base.$field.val() != ""){
- base.$label.hide();
- base.showing = false;
- };
-
- base.$field.focus(function(){
- base.fadeOnFocus();
- }).blur(function(){
- base.checkForEmpty(true);
- }).bind('keydown.infieldlabel',function(e){
- // Use of a namespace (.infieldlabel) allows us to
- // unbind just this method later
- base.hideOnChange(e);
- }).change(function(e){
- base.checkForEmpty();
- }).bind('onPropertyChange', function(){
- base.checkForEmpty();
- });
- };
-
- // If the label is currently showing
- // then fade it down to the amount
- // specified in the settings
- base.fadeOnFocus = function(){
- if(base.showing){
- base.setOpacity(base.options.fadeOpacity);
- };
- };
-
- base.setOpacity = function(opacity){
- base.$label.stop().animate({ opacity: opacity }, base.options.fadeDuration);
- base.showing = (opacity > 0.0);
- };
-
- // Checks for empty as a fail safe
- // set blur to true when passing from
- // the blur event
- base.checkForEmpty = function(blur){
- if(base.$field.val() == ""){
- base.prepForShow();
- base.setOpacity( blur ? 1.0 : base.options.fadeOpacity );
- } else {
- base.setOpacity(0.0);
- };
- };
-
- base.prepForShow = function(e){
- if(!base.showing) {
- // Prepare for a animate in...
- base.$label.css({opacity: 0.0}).show();
-
- // Reattach the keydown event
- base.$field.bind('keydown.infieldlabel',function(e){
- base.hideOnChange(e);
- });
- };
- };
-
- base.hideOnChange = function(e){
- if(
- (e.keyCode == 16) || // Skip Shift
- (e.keyCode == 9) // Skip Tab
- ) return;
-
- if(base.showing){
- base.$label.hide();
- base.showing = false;
- };
-
- // Remove keydown event to save on CPU processing
- base.$field.unbind('keydown.infieldlabel');
- };
-
- // Run the initialization method
- base.init();
- };
-
- $.InFieldLabels.defaultOptions = {
- fadeOpacity: 0.5, // Once a field has focus, how transparent should the label be
- fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity
- };
-
-
- $.fn.inFieldLabels = function(options){
- return this.each(function(){
- // Find input or textarea based on for= attribute
- // The for attribute on the label must contain the ID
- // of the input or textarea element
- var for_attr = $(this).attr('for');
- if( !for_attr ) return; // Nothing to attach, since the for field wasn't used
-
-
- // Find the referenced input or textarea element
- var $field = $(
- "input#" + for_attr + "[type='text']," +
- "input#" + for_attr + "[type='password']," +
- "textarea#" + for_attr
- );
-
- if( $field.length == 0) return; // Again, nothing to attach
-
- // Only create object for input[text], input[password], or textarea
- (new $.InFieldLabels(this, $field[0], options));
- });
- };
-
-})(jQuery); \ No newline at end of file
diff --git a/core/js/jquery.infieldlabel.min.js b/core/js/jquery.infieldlabel.min.js
index 8f0ab9f7c5e..36f6b8f1271 100644
--- a/core/js/jquery.infieldlabel.min.js
+++ b/core/js/jquery.infieldlabel.min.js
@@ -1,12 +1,12 @@
/*
- * In-Field Label jQuery Plugin
- * http://fuelyourcoding.com/scripts/infield.html
- *
- * Copyright (c) 2009 Doug Neiner
- * Dual licensed under the MIT and GPL licenses.
- * Uses the same license as jQuery, see:
- * http://docs.jquery.com/License
- *
- * @version 0.1
- */
-(function($){$.InFieldLabels=function(b,c,d){var f=this;f.$label=$(b);f.label=b;f.$field=$(c);f.field=c;f.$label.data("InFieldLabels",f);f.showing=true;f.init=function(){f.options=$.extend({},$.InFieldLabels.defaultOptions,d);if(f.$field.val()!=""){f.$label.hide();f.showing=false};f.$field.focus(function(){f.fadeOnFocus()}).blur(function(){f.checkForEmpty(true)}).bind('keydown.infieldlabel',function(e){f.hideOnChange(e)}).change(function(e){f.checkForEmpty()}).bind('onPropertyChange',function(){f.checkForEmpty()})};f.fadeOnFocus=function(){if(f.showing){f.setOpacity(f.options.fadeOpacity)}};f.setOpacity=function(a){f.$label.stop().animate({opacity:a},f.options.fadeDuration);f.showing=(a>0.0)};f.checkForEmpty=function(a){if(f.$field.val()==""){f.prepForShow();f.setOpacity(a?1.0:f.options.fadeOpacity)}else{f.setOpacity(0.0)}};f.prepForShow=function(e){if(!f.showing){f.$label.css({opacity:0.0}).show();f.$field.bind('keydown.infieldlabel',function(e){f.hideOnChange(e)})}};f.hideOnChange=function(e){if((e.keyCode==16)||(e.keyCode==9))return;if(f.showing){f.$label.hide();f.showing=false};f.$field.unbind('keydown.infieldlabel')};f.init()};$.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};$.fn.inFieldLabels=function(c){return this.each(function(){var a=$(this).attr('for');if(!a)return;var b=$("input#"+a+"[type='text'],"+"input#"+a+"[type='password'],"+"textarea#"+a);if(b.length==0)return;(new $.InFieldLabels(this,b[0],c))})}})(jQuery); \ No newline at end of file
+ In-Field Label jQuery Plugin
+ http://fuelyourcoding.com/scripts/infield.html
+
+ Copyright (c) 2009-2010 Doug Neiner
+ Dual licensed under the MIT and GPL licenses.
+ Uses the same license as jQuery, see:
+ http://docs.jquery.com/License
+
+ @version 0.1.5
+*/
+(function($){$.InFieldLabels=function(label,field,options){var base=this;base.$label=$(label);base.label=label;base.$field=$(field);base.field=field;base.$label.data("InFieldLabels",base);base.showing=true;base.init=function(){base.options=$.extend({},$.InFieldLabels.defaultOptions,options);setTimeout(function(){if(base.$field.val()!==""){base.$label.hide();base.showing=false}},200);base.$field.focus(function(){base.fadeOnFocus()}).blur(function(){base.checkForEmpty(true)}).bind('keydown.infieldlabel',function(e){base.hideOnChange(e)}).bind('paste',function(e){base.setOpacity(0.0)}).change(function(e){base.checkForEmpty()}).bind('onPropertyChange',function(){base.checkForEmpty()}).bind('keyup.infieldlabel',function(){base.checkForEmpty()})};base.fadeOnFocus=function(){if(base.showing){base.setOpacity(base.options.fadeOpacity)}};base.setOpacity=function(opacity){base.$label.stop().animate({opacity:opacity},base.options.fadeDuration);base.showing=(opacity>0.0)};base.checkForEmpty=function(blur){if(base.$field.val()===""){base.prepForShow();base.setOpacity(blur?1.0:base.options.fadeOpacity)}else{base.setOpacity(0.0)}};base.prepForShow=function(e){if(!base.showing){base.$label.css({opacity:0.0}).show();base.$field.bind('keydown.infieldlabel',function(e){base.hideOnChange(e)})}};base.hideOnChange=function(e){if((e.keyCode===16)||(e.keyCode===9)){return}if(base.showing){base.$label.hide();base.showing=false}base.$field.unbind('keydown.infieldlabel')};base.init()};$.InFieldLabels.defaultOptions={fadeOpacity:0.5,fadeDuration:300};$.fn.inFieldLabels=function(options){return this.each(function(){var for_attr=$(this).attr('for'),$field;if(!for_attr){return}$field=$("input#"+for_attr+"[type='text'],"+"input#"+for_attr+"[type='search'],"+"input#"+for_attr+"[type='tel'],"+"input#"+for_attr+"[type='url'],"+"input#"+for_attr+"[type='email'],"+"input#"+for_attr+"[type='password'],"+"textarea#"+for_attr);if($field.length===0){return}(new $.InFieldLabels(this,$field[0],options))})}}(jQuery));
diff --git a/core/js/js.js b/core/js/js.js
index c5e32f3c278..2073fc4d4b7 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -62,7 +62,7 @@ function escapeHTML(s) {
* @return string
*/
function fileDownloadPath(dir, file) {
- return OC.filePath('files', 'ajax', 'download.php')+'&files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
+ return OC.filePath('files', 'ajax', 'download.php')+'?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir);
}
var OC={
@@ -95,9 +95,9 @@ var OC={
var isCore=OC.coreApps.indexOf(app)!==-1,
link=OC.webroot;
if((file.substring(file.length-3) === 'php' || file.substring(file.length-3) === 'css') && !isCore){
- link+='/?app=' + app;
+ link+='/index.php/apps/' + app;
if (file != 'index.php') {
- link+='&getfile=';
+ link+='/';
if(type){
link+=encodeURI(type + '/');
}
@@ -113,7 +113,12 @@ var OC={
}
link+=file;
}else{
- link+='/';
+ if ((app == 'settings' || app == 'core' || app == 'search') && type == 'ajax') {
+ link+='/index.php/';
+ }
+ else {
+ link+='/';
+ }
if(!isCore){
link+='apps/';
}
diff --git a/core/js/router.js b/core/js/router.js
new file mode 100644
index 00000000000..8b66f5a05c5
--- /dev/null
+++ b/core/js/router.js
@@ -0,0 +1,73 @@
+OC.router_base_url = OC.webroot + '/index.php/',
+OC.Router = {
+ routes_request: $.ajax(OC.router_base_url + 'core/routes.json', {
+ dataType: 'json',
+ success: function(jsondata) {
+ if (jsondata.status == 'success') {
+ OC.Router.routes = jsondata.data;
+ }
+ }
+ }),
+ generate:function(name, opt_params) {
+ if (!('routes' in this)) {
+ if(this.routes_request.state() != 'resolved') {
+ alert('wait');// wait
+ }
+ }
+ if (!(name in this.routes)) {
+ throw new Error('The route "' + name + '" does not exist.');
+ }
+ var route = this.routes[name];
+ var params = opt_params || {};
+ var unusedParams = $.extend(true, {}, params);
+ var url = '';
+ var optional = true;
+ $(route.tokens).each(function(i, token) {
+ if ('text' === token[0]) {
+ url = token[1] + url;
+ optional = false;
+
+ return;
+ }
+
+ if ('variable' === token[0]) {
+ if (false === optional || !(token[3] in route.defaults)
+ || ((token[3] in params) && params[token[3]] != route.defaults[token[3]])) {
+ var value;
+ if (token[3] in params) {
+ value = params[token[3]];
+ delete unusedParams[token[3]];
+ } else if (token[3] in route.defaults) {
+ value = route.defaults[token[3]];
+ } else if (optional) {
+ return;
+ } else {
+ throw new Error('The route "' + name + '" requires the parameter "' + token[3] + '".');
+ }
+
+ var empty = true === value || false === value || '' === value;
+
+ if (!empty || !optional) {
+ url = token[1] + encodeURIComponent(value).replace(/%2F/g, '/') + url;
+ }
+
+ optional = false;
+ }
+
+ return;
+ }
+
+ throw new Error('The token type "' + token[0] + '" is not supported.');
+ });
+ if (url === '') {
+ url = '/';
+ }
+
+ unusedParams = $.param(unusedParams);
+ if (unusedParams.length > 0) {
+ url += '?'+unusedParams;
+ }
+
+ return OC.router_base_url + url;
+ }
+};
diff --git a/core/js/share.js b/core/js/share.js
index 7d8799edf51..73c74a7cb6d 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -10,17 +10,38 @@ OC.Share={
// Load all share icons
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
if (result && result.status === 'success') {
- $.each(result.data, function(item, hasPrivateLink) {
- // Private links override shared in terms of icon display
+ $.each(result.data, function(item, hasLink) {
+ OC.Share.statuses[item] = hasLink;
+ // Links override shared in terms of icon display
+ if (hasLink) {
+ var image = OC.imagePath('core', 'actions/public');
+ } else {
+ var image = OC.imagePath('core', 'actions/shared');
+ }
if (itemType != 'file' && itemType != 'folder') {
- if (hasPrivateLink) {
- var image = OC.imagePath('core', 'actions/public');
- } else {
- var image = OC.imagePath('core', 'actions/shared');
- }
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
+ } else {
+ var file = $('tr').filterAttr('data-file', OC.basename(item));
+ if (file.length > 0) {
+ $(file).find('.fileactions .action').filterAttr('data-action', 'Share').find('img').attr('src', image);
+ }
+ var dir = $('#dir').val();
+ if (dir.length > 1) {
+ var last = '';
+ var path = dir;
+ // Search for possible parent folders that are shared
+ while (path != last) {
+ if (path == item) {
+ var img = $('.fileactions .action').filterAttr('data-action', 'Share').find('img');
+ if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
+ img.attr('src', image);
+ }
+ }
+ last = path;
+ path = OC.Share.dirname(path);
+ }
+ }
}
- OC.Share.statuses[item] = hasPrivateLink;
});
}
});
@@ -483,15 +504,14 @@ $(document).ready(function() {
$('#linkPass').toggle('blind');
});
- $('#linkPassText').live('keyup', function(event) {
- if (event.keyCode == 13) {
- var itemType = $('#dropdown').data('item-type');
- var itemSource = $('#dropdown').data('item-source');
- OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() {
- $('#linkPassText').val('');
- $('#linkPassText').attr('placeholder', t('core', 'Password protected'));
- });
- }
+ $('#linkPassText').live('focusout', function(event) {
+ var itemType = $('#dropdown').data('item-type');
+ var itemSource = $('#dropdown').data('item-source');
+ OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.PERMISSION_READ, function() {
+ $('#linkPassText').val('');
+ $('#linkPassText').attr('placeholder', t('core', 'Password protected'));
+ });
+ $('#linkPassText').attr('placeholder', t('core', 'Password protected'));
});
$('#expirationCheckbox').live('click', function() {