diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 22:54:48 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2013-02-14 22:54:48 +0100 |
commit | 4b80466880b4e2daf25e38d621a0ebac608d335d (patch) | |
tree | dfdcac5eb81cea7853d16c50ea3043c4642f3c15 /core/js | |
parent | 78a3625ddfc67e7e6743a2ff6fd31e1566b174c8 (diff) | |
parent | 9058d398a7b9aac58ab4aa7379e13ca83c72281d (diff) | |
download | nextcloud-server-4b80466880b4e2daf25e38d621a0ebac608d335d.tar.gz nextcloud-server-4b80466880b4e2daf25e38d621a0ebac608d335d.zip |
Merge branch 'master' into master-sqlserver
Conflicts:
lib/db.php
lib/files/cache/cache.php
lib/files/cache/legacy.php
lib/setup.php
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/compatibility.js | 32 | ||||
-rw-r--r-- | core/js/eventsource.js | 10 | ||||
-rw-r--r-- | core/js/js.js | 4 | ||||
-rw-r--r-- | core/js/singleselect.js | 76 |
4 files changed, 117 insertions, 5 deletions
diff --git a/core/js/compatibility.js b/core/js/compatibility.js new file mode 100644 index 00000000000..0cfeefab871 --- /dev/null +++ b/core/js/compatibility.js @@ -0,0 +1,32 @@ + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim +if(!String.prototype.trim) { + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g,''); + }; +}
\ No newline at end of file diff --git a/core/js/eventsource.js b/core/js/eventsource.js index f783ade7ae9..ce8c8387c8e 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -87,8 +87,10 @@ OC.EventSource.prototype={ useFallBack:false, fallBackCallBack:function(type,data){ if(type){ - for(var i=0;i<this.listeners[type].length;i++){ - this.listeners[type][i](data); + if (typeof this.listeners['done'] != 'undefined') { + for(var i=0;i<this.listeners[type].length;i++){ + this.listeners[type][i](data); + } } }else{ for(var i=0;i<this.typelessListeners.length;i++){ @@ -117,6 +119,8 @@ OC.EventSource.prototype={ } }, close:function(){ - this.source.close(); + if (typeof this.source !='undefined') { + this.source.close(); + } } } diff --git a/core/js/js.js b/core/js/js.js index ae23c955c38..6d5d65403fb 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -663,14 +663,14 @@ $(document).ready(function(){ } }); $('#settings #expand').click(function(event) { - $('#settings #expanddiv').slideToggle(); + $('#settings #expanddiv').slideToggle(200); event.stopPropagation(); }); $('#settings #expanddiv').click(function(event){ event.stopPropagation(); }); $(window).click(function(){//hide the settings menu when clicking outside it - $('#settings #expanddiv').slideUp(); + $('#settings #expanddiv').slideUp(200); }); // all the tipsy stuff needs to be here (in reverse order) to work diff --git a/core/js/singleselect.js b/core/js/singleselect.js new file mode 100644 index 00000000000..1a018b74148 --- /dev/null +++ b/core/js/singleselect.js @@ -0,0 +1,76 @@ +(function ($) { + $.fn.singleSelect = function () { + return this.each(function (i, select) { + var input = $('<input/>'); + select = $(select); + input.css('position', 'absolute'); + input.css(select.offset()); + input.css({ + 'box-sizing': 'border-box', + '-moz-box-sizing': 'border-box', + 'margin': 0, + 'width': (select.width() - 5) + 'px', + 'height': (select.outerHeight() - 2) + 'px', + 'border': 'none', + 'box-shadow': 'none', + 'margin-top': '1px', + 'margin-left': '1px', + 'z-index': 1000 + }); + input.hide(); + $('body').append(input); + + select.on('change', function (event) { + var value = $(this).val(), + newAttr = $('option:selected', $(this)).attr('data-new'); + if (!(typeof newAttr !== 'undefined' && newAttr !== false)) { + input.hide(); + select.data('previous', value); + } else { + event.stopImmediatePropagation(); + input.show(); + select.css('background-color', 'white'); + input.focus(); + } + }); + + $(select).data('previous', $(select).val()); + + input.on('change', function () { + var value = $(this).val(); + if (value) { + select.children().attr('selected', null); + var existingOption = select.children().filter(function (i, option) { + return ($(option).val() == value); + }); + if (existingOption.length) { + existingOption.attr('selected', 'selected'); + } else { + var option = $('<option/>'); + option.attr('selected', 'selected').attr('value', value).text(value); + select.children().last().before(option); + } + select.val(value); + select.css('background-color', null); + input.val(null); + input.hide(); + select.change(); + } else { + var previous = select.data('previous'); + select.children().attr('selected', null); + select.children().each(function (i, option) { + if ($(option).val() == previous) { + $(option).attr('selected', 'selected'); + } + }); + select.removeClass('active'); + input.hide(); + } + }); + + input.on('blur', function () { + $(this).change(); + }); + }); + } +})(jQuery); |