diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-03-03 15:06:51 +0100 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-03-03 15:06:51 +0100 |
commit | f2dcab50b5ebeaa7f1248bd9ecf49cd0f047caf7 (patch) | |
tree | df91aa5178e434609ed14988bb693dce0685d863 /core | |
parent | bfb67286c85806fdd4293b60936d5cdedee2e702 (diff) | |
parent | 4c45483ad3acd5b675e54893686f912a32f10a12 (diff) | |
download | nextcloud-server-f2dcab50b5ebeaa7f1248bd9ecf49cd0f047caf7.tar.gz nextcloud-server-f2dcab50b5ebeaa7f1248bd9ecf49cd0f047caf7.zip |
fix merge conflicts
Diffstat (limited to 'core')
-rw-r--r-- | core/ajax/appconfig.php | 35 | ||||
-rw-r--r-- | core/css/styles.css | 4 | ||||
-rw-r--r-- | core/js/config.js | 55 | ||||
-rw-r--r-- | core/js/js.js | 50 | ||||
-rw-r--r-- | core/js/multiselect.js | 19 | ||||
-rw-r--r-- | core/js/oc-dialogs.js | 145 |
6 files changed, 295 insertions, 13 deletions
diff --git a/core/ajax/appconfig.php b/core/ajax/appconfig.php new file mode 100644 index 00000000000..50984ac32b9 --- /dev/null +++ b/core/ajax/appconfig.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com> + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +require_once ("../../lib/base.php"); +OC_JSON::checkLoggedIn(); +$action=isset($_POST['action'])?$_POST['action']:$_GET['action']; +$result=false; +switch($action){ + case 'getValue': + $result=OC_Appconfig::getValue($_GET['app'],$_GET['key'],$_GET['default']); + break; + case 'setValue': + $result=OC_Appconfig::setValue($_POST['app'],$_POST['key'],$_POST['value']); + break; + case 'getApps': + $result=OC_Appconfig::getApps(); + break; + case 'getKeys': + $result=OC_Appconfig::getKeys($_GET['app']); + break; + case 'hasKey': + $result=OC_Appconfig::hasKey($_GET['app'],$_GET['key']); + break; + case 'deleteKey': + $result=OC_Appconfig::deleteKey($_POST['app'],$_POST['key']); + break; + case 'deleteApp': + $result=OC_Appconfig::deleteApp($_POST['app']); + break; +} +OC_JSON::success(array('data'=>$result)); diff --git a/core/css/styles.css b/core/css/styles.css index 58c5765a9d3..96c1d5d40f0 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -128,4 +128,6 @@ div.jp-play-bar, div.jp-seek-bar { padding:0; } li.error { width:640px; margin:4em auto; padding:1em 1em 1em 4em; background:#ffe .8em .8em no-repeat; color: #FF3B3B; border:1px solid #ccc; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; } .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { overflow: hidden; text-overflow: ellipsis; } .hint { background-image: url('/core/img/actions/info.png'); background-repeat:no-repeat; color: #777777; padding-left: 25px; background-position: 0 0.3em;} -.separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; }
\ No newline at end of file +.separator { display: inline; border-left: 1px solid #d3d3d3; border-right: 1px solid #fff; height: 10px; width:0px; margin: 4px; } + +a.bookmarklet { background-color: #ddd; border:1px solid #ccc; padding: 5px;padding-top: 0px;padding-bottom: 2px; text-decoration: none; margin-top: 5px } diff --git a/core/js/config.js b/core/js/config.js new file mode 100644 index 00000000000..500fe072a64 --- /dev/null +++ b/core/js/config.js @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com> + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +OC.AppConfig={ + url:OC.filePath('core','ajax','appconfig.php'), + getCall:function(action,data,callback){ + data.action=action; + $.getJSON(OC.AppConfig.url,data,function(result){ + if(result.status='success'){ + if(callback){ + callback(result.data); + } + } + }); + }, + postCall:function(action,data,callback){ + data.action=action; + $.post(OC.AppConfig.url,data,function(result){ + if(result.status='success'){ + if(callback){ + callback(result.data); + } + } + },'json'); + }, + getValue:function(app,key,defaultValue,callback){ + if(typeof defaultValue=='function'){ + callback=defaultValue; + defaultValue=null; + } + OC.AppConfig.getCall('getValue',{app:app,key:key,default:defaultValue},callback); + }, + setValue:function(app,key,value){ + OC.AppConfig.postCall('setValue',{app:app,key:key,value:value}); + }, + getApps:function(callback){ + OC.AppConfig.getCall('getApps',{},callback); + }, + getKeys:function(app,callback){ + OC.AppConfig.getCall('getKeys',{app:app},callback); + }, + hasKey:function(app,key,callback){ + OC.AppConfig.getCall('hasKey',{app:app,key:key},callback); + }, + deleteKey:function(app,key){ + OC.AppConfig.postCall('deleteKey',{app:app,key:key}); + }, + deleteApp:function(app){ + OC.AppConfig.postCall('deleteApp',{app:app}); + }, +} +//TODO OC.Preferences diff --git a/core/js/js.js b/core/js/js.js index 6da9c29e693..df1b5c6ce76 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -125,7 +125,8 @@ OC={ OC.search.showResults(results); }); } - } + }, + dialogs:OCdialogs }; OC.search.customResults={}; OC.search.currentResult=-1; @@ -252,16 +253,22 @@ function replaceSVG(){ $('.svg').each(function(index,element){ element=$(element); var background=element.css('background-image'); - if(background && background!='none'){ - background=background.substr(0,background.length-4)+'png)'; - element.css('background-image',background); + if(background){ + var i=background.lastIndexOf('.svg'); + if(i>=0){ + background=background.substr(0,i)+'.png'+background.substr(i+4); + element.css('background-image',background); + } } element.find('*').each(function(index,element) { element=$(element); var background=element.css('background-image'); - if(background && background!='none'){ - background=background.substr(0,background.length-4)+'png)'; - element.css('background-image',background); + if(background){ + var i=background.lastIndexOf('.svg'); + if(i>=0){ + background=background.substr(0,i)+'.png'+background.substr(i+4); + element.css('background-image',background); + } } }); }); @@ -444,4 +451,33 @@ $.fn.filterAttr = function(attr_name, attr_value) { return this.filter(function() { return $(this).attr(attr_name) === attr_value; }); }; +function humanFileSize(size) { + humanList = ['B', 'kB', 'MB', 'GB', 'TB']; + // Calculate Log with base 1024: size = 1024 ** order + order = Math.floor(Math.log(size) / Math.log(1024)); + // Stay in range of the byte sizes that are defined + order = Math.min(humanList.length - 1, order); + readableFormat = humanList[order]; + relativeSize = (size / Math.pow(1024, order)).toFixed(1); + if(relativeSize.substr(relativeSize.length-2,2)=='.0'){ + relativeSize=relativeSize.substr(0,relativeSize.length-2); + } + return relativeSize + ' ' + readableFormat; +} + +function simpleFileSize(bytes) { + mbytes = Math.round(bytes/(1024*1024/10))/10; + if(bytes == 0) { return '0'; } + else if(mbytes < 0.1) { return '< 0.1'; } + else if(mbytes > 1000) { return '> 1000'; } + else { return mbytes.toFixed(1); } +} +function formatDate(date){ + if(typeof date=='number'){ + date=new Date(date); + } + var monthNames = [ t('files','January'), t('files','February'), t('files','March'), t('files','April'), t('files','May'), t('files','June'), + t('files','July'), t('files','August'), t('files','September'), t('files','October'), t('files','November'), t('files','December') ]; + return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+date.getMinutes(); +} diff --git a/core/js/multiselect.js b/core/js/multiselect.js index 96fc09a0759..541dddf0f70 100644 --- a/core/js/multiselect.js +++ b/core/js/multiselect.js @@ -12,6 +12,11 @@ 'minWidth': 'default;', }; $.extend(settings,options); + $.each(this.children(),function(i,option){ + if($(option).attr('selected') && settings.checked.indexOf($(option).val())==-1){ + settings.checked.push($(option).val()); + } + }); var button=$('<div class="multiselect button"><span>'+settings.title+'</span><span>▾</span></div>'); var span=$('<span/>'); span.append(button); @@ -46,9 +51,11 @@ }); button.addClass('active'); event.stopPropagation(); - var options=$(this).parent().next().children().map(function(){return $(this).val();}); + var options=$(this).parent().next().children(); var list=$('<ul class="multiselectoptions"/>').hide().appendTo($(this).parent()); - function createItem(item,checked){ + function createItem(element,checked){ + element=$(element); + var item=element.val(); var id='ms'+multiSelectId+'-option-'+item; var input=$('<input id="'+id+'" type="checkbox"/>'); var label=$('<label for="'+id+'">'+item+'</label>'); @@ -61,6 +68,7 @@ input.change(function(){ var groupname=$(this).next().text(); if($(this).is(':checked')){ + element.attr('selected','selected'); if(settings.oncheck){ if(settings.oncheck(groupname)===false){ $(this).attr('checked', false); @@ -70,6 +78,7 @@ settings.checked.push(groupname); }else{ var index=settings.checked.indexOf(groupname); + element.attr('selected',null); if(settings.onuncheck){ if(settings.onuncheck(groupname)===false){ $(this).attr('checked',true); @@ -119,11 +128,11 @@ var li=$(this).parent(); $(this).remove(); li.text('+ '+settings.createText); - li.before(createItem($(this).val())); + li.before(createItem(this)); + var select=button.parent().next(); + select.append($('<option selected="selected" value="'+$(this).val()+'">'+$(this).val()+'</option>')); li.prev().children('input').trigger('click'); button.parent().data('preventHide',false); - var select=button.parent().next(); - select.append($('<option value="'+$(this).val()+'">'+$(this).val()+'</option>')); if(settings.createCallback){ settings.createCallback(); } diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js new file mode 100644 index 00000000000..de67c342a71 --- /dev/null +++ b/core/js/oc-dialogs.js @@ -0,0 +1,145 @@ +/** + * ownCloud + * + * @author Bartek Przybylski + * @copyright 2012 Bartek Przybylski bart.p.pl@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/>. + * + * todo(bartek): add select option in form + */ + +/** + * this class ease usage of jquery dialogs + */ +OCdialogs = { + /** + * displays alert dialog + * @param text content of dialog + * @param title dialog title + * @param callback which will be triggered when user press OK + */ + alert:function(text, title, callback) { + var content = '<p><span class="ui-icon ui-icon-alert"></span>'+text+'</p>'; + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback); + }, + /** + * displays info dialog + * @param text content of dialog + * @param title dialog title + * @param callback which will be triggered when user press OK + */ + info:function(text, title, callback) { + var content = '<p><span class="ui-icon ui-icon-info"></span>'+text+'</p>'; + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.OK_BUTTON, callback); + }, + /** + * displays confirmation dialog + * @param text content of dialog + * @param title dialog title + * @param callback which will be triggered when user press YES or NO (true or false would be passed to callback respectively) + */ + confirm:function(text, title, callback) { + var content = '<p><span class="ui-icon ui-icon-notice"></span>'+text+'</p>'; + OCdialogs.message(content, title, OCdialogs.ALERT_DIALOG, OCdialogs.YES_NO_BUTTON, callback); + }, + /** + * prompt for user input + * @param text content of dialog + * @param title dialog title + * @param callback which will be triggered when user press OK (input text will be passed to callback) + */ + prompt:function(text, title, callback) { + var content = '<p><span class="ui-icon ui-icon-pencil"></span>'+text+':<br/><input type="text" id="oc-dialog-prompt-input" style="width:90%"></p>'; + OCdialogs.message(content, title, OCdialogs.PROMPT_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback); + }, + /** + * prompt user for input with custom form + * fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type'},...] + * @param fields to display + * @param title dialog title + * @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...]) + */ + form:function(fields, title, callback) { + var content = '<table>'; + for (var a in fields) { + content += '<tr><td>'+fields[a].text+'</td><td>'; + var type=fields[a].type; + if (type == 'text' || type == 'checkbox' || type == 'password') + content += '<input type="'+type+'" name="'+fields[a].name+'">'; + content += "</td></tr>" + } + content += "</table>"; + OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback); + }, + message:function(content, title, dialog_type, buttons, callback) { + var c_name = 'oc-dialog-'+OCdialogs.dialogs_counter+'-content'; + var c_id = '#'+c_name; + var d = '<div id="'+c_name+'" title="'+title+'">'+content+'</div>'; + $('body').append(d); + var b = []; + switch (buttons) { + case OCdialogs.YES_NO_BUTTONS: + b[1] = {text: t('dialogs', 'No'), click: function(){ if (callback != undefined) callback(false); $(c_id).dialog('close'); }}; + b[0] = {text: t('dialogs', 'Yes'), click: function(){ if (callback != undefined) callback(true); $(c_id).dialog('close');}}; + break; + case OCdialogs.OK_CANCEL_BUTTONS: + b[1] = {text: t('dialogs', 'Cancel'), click: function(){$(c_id).dialog('close'); }}; + case OCdialogs.OK_BUTTON: // fallthrough + var f; + switch(dialog_type) { + case OCdialogs.ALERT_DIALOG: + f = function(){$(c_id).dialog('close'); }; + break; + case OCdialogs.PROMPT_DIALOG: + f = function(){OCdialogs.prompt_ok_handler(callback, c_id)}; + break; + case OCdialogs.FORM_DIALOG: + f = function(){OCdialogs.form_ok_handler(callback, c_id)}; + break; + } + b[0] = {text: t('dialogs', 'Ok'), click: f}; + break; + } + $(c_id).dialog({width: 4*$(document).width()/9, height: $(d).height() + 150, modal: false, buttons: b}); + OCdialogs.dialogs_counter++; + }, + // dialogs buttons types + YES_NO_BUTTONS: 70, + OK_BUTTONS: 71, + OK_CANCEL_BUTTONS: 72, + // dialogs types + ALERT_DIALOG: 80, + INFO_DIALOG: 81, + PROMPT_DIALOG: 82, + FORM_DIALOG: 83, + dialogs_counter: 0, + determineValue: function(element) { + switch ($(element).attr('type')) { + case 'checkbox': return $(element).attr('checked') != undefined; + } + return $(element).val(); + }, + prompt_ok_handler: function(callback, c_id){callback(true, $(c_id + " input#oc-dialog-prompt-input").val()); $(c_id).dialog('close');}, + form_ok_handler: function(callback, c_id) { + var r = []; + var c = 0; + $(c_id + ' input').each(function(i, elem) { + r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)}; + c++; + }); + $(c_id).dialog('close'); + callback(r); + } +}; |