diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-06 13:49:54 -0400 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-08-06 13:49:54 -0400 |
commit | ea2385432817dcf5ad47396d83932f564aa76e4b (patch) | |
tree | effc5c5489cf385ee79c73a4bea59605f53240f9 /core/js | |
parent | ba0cf9817526e1206a25a5fe6d70255ab3c9e3bc (diff) | |
parent | fe6450002d6059260c743f48b6f40378454fa1dc (diff) | |
download | nextcloud-server-ea2385432817dcf5ad47396d83932f564aa76e4b.tar.gz nextcloud-server-ea2385432817dcf5ad47396d83932f564aa76e4b.zip |
Merge branch 'master' into share_api
Conflicts:
apps/contacts/lib/app.php
apps/contacts/templates/part.chooseaddressbook.rowfields.php
Diffstat (limited to 'core/js')
-rw-r--r-- | core/js/js.js | 107 |
1 files changed, 80 insertions, 27 deletions
diff --git a/core/js/js.js b/core/js/js.js index df834157cdb..7bded8e1414 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -82,7 +82,7 @@ OC={ if(type){ link+=type+'/'; } - link+=file; + link+=file; } return link; }, @@ -91,9 +91,9 @@ OC={ * @param app the app id to which the image belongs * @param file the name of the image file * @return string - * + * * if no extension is given for the image, it will automatically decide between .png and .svg based on what the browser supports - */ + */ imagePath:function(app,file){ if(file.indexOf('.')==-1){//if no extension is given, use png or svg depending on browser support file+=(SVGSupport())?'.svg':'.png'; @@ -105,7 +105,7 @@ OC={ * @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 - * + * * if the script is already loaded, the event handeler will be called directly */ addScript:function(app,script,ready){ @@ -150,12 +150,66 @@ OC={ } }, dialogs:OCdialogs, - mtime2date:function(mtime) { - mtime = parseInt(mtime); - var date = new Date(1000*mtime); - var ret = date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes(); - return ret; - } + mtime2date:function(mtime) { + mtime = parseInt(mtime); + var date = new Date(1000*mtime); + var ret = date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes(); + return ret; + }, + /** + * 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); + 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.' }; + } + if(settings.is(':visible')) { + settings.hide().find('.arrow').hide(); + } else { + if($('#journal.settings').length == 0) { + var arrowclass = settings.hasClass('topright') ? 'up' : 'left'; + var jqxhr = $.get(OC.filePath(props.appid, '', props.scriptName), function(data) { + $('#appsettings').html(data).ready(function() { + settings.prepend('<span class="arrow '+arrowclass+'"></span><h2>'+t('core', 'Settings')+'</h2><a class="close svg"></a>').show(); + settings.find('.close').bind('click', function() { + settings.hide(); + }) + 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; + }); + } + }); + }, 'html'); + } else { + settings.show().find('.arrow').show(); + } + } + } }; OC.search.customResults={}; OC.search.currentResult=-1; @@ -202,7 +256,7 @@ if (!Array.prototype.filter) { var len = this.length >>> 0; if (typeof fun != "function") throw new TypeError(); - + var res = []; var thisp = arguments[1]; for (var i = 0; i < len; i++) { @@ -222,14 +276,14 @@ if (!Array.prototype.indexOf){ Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length; - + var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; - + for (; from < len; from++) { if (from in this && @@ -306,7 +360,7 @@ function replaceSVG(){ /** * prototypal inharitence functions - * + * * usage: * MySubObject=object(MyObject) */ @@ -352,7 +406,7 @@ $(document).ready(function(){ fillWindow($('#rightcontent')); }); $(window).trigger('resize'); - + if(!SVGSupport()){ //replace all svg images with png images for browser that dont support svg replaceSVG(); }else{ @@ -395,17 +449,13 @@ $(document).ready(function(){ } }); - // 'show password' checkbox + // 'show password' checkbox $('#pass2').showPassword(); //use infield labels $("label.infield").inFieldLabels(); - // hide log in button etc. when form fields not filled - $('#submit').hide(); - $('#remember_login').hide(); - $('#remember_login+label').hide(); - $('input#user, input#password').keyup(function() { + checkShowCredentials = function() { var empty = false; $('input#user, input#password').each(function() { if ($(this).val() == '') { @@ -421,7 +471,10 @@ $(document).ready(function(){ $('#remember_login').show(); $('#remember_login+label').fadeIn(); } - }); + } + // hide log in button etc. when form fields not filled + checkShowCredentials(); + $('input#user, input#password').keyup(checkShowCredentials); $('#settings #expand').keydown(function(event) { if (event.which == 13 || event.which == 32) { @@ -462,15 +515,15 @@ $(document).ready(function(){ if (!Array.prototype.map){ Array.prototype.map = function(fun /*, thisp */){ "use strict"; - + if (this === void 0 || this === null) throw new TypeError(); - + var t = Object(this); var len = t.length >>> 0; if (typeof fun !== "function") throw new TypeError(); - + var res = new Array(len); var thisp = arguments[1]; for (var i = 0; i < len; i++){ @@ -478,7 +531,7 @@ if (!Array.prototype.map){ res[i] = fun.call(thisp, t[i], i, t); } } - + return res; }; } @@ -486,7 +539,7 @@ if (!Array.prototype.map){ /** * Filter Jquery selector by attribute value **/ -$.fn.filterAttr = function(attr_name, attr_value) { +$.fn.filterAttr = function(attr_name, attr_value) { return this.filter(function() { return $(this).attr(attr_name) === attr_value; }); }; |