summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-03-30 22:50:57 +0200
committerBartek Przybylski <bart.p.pl@gmail.com>2012-03-30 22:50:57 +0200
commit6b704a780dbe3daa4c13ad49ad4265c1db4a67aa (patch)
tree07f6053555b696aae2dc67ad208b08b71e5b44e0
parent6abb2cb92edc1edaefea7e37cd46a6c866239c27 (diff)
downloadnextcloud-server-6b704a780dbe3daa4c13ad49ad4265c1db4a67aa.tar.gz
nextcloud-server-6b704a780dbe3daa4c13ad49ad4265c1db4a67aa.zip
select field added to oc.dialogs.form, gallery ported to use it
-rw-r--r--apps/gallery/js/album_cover.js46
-rw-r--r--apps/gallery/templates/index.php39
-rw-r--r--core/js/oc-dialogs.js14
3 files changed, 28 insertions, 71 deletions
diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js
index cd260019642..d44e7f83d1f 100644
--- a/apps/gallery/js/album_cover.js
+++ b/apps/gallery/js/album_cover.js
@@ -113,42 +113,28 @@ function scanForAlbums(cleanup) {
}
function settings() {
- $( '#g-dialog-settings' ).dialog({
- height: 180,
- width: 350,
- modal: false,
- buttons: [
- {
- text: t('gallery', 'Apply'),
- click: function() {
- var scanning_root = $('#g-scanning-root').val();
- var disp_order = $('#g-display-order option:selected').val();
+ OC.dialogs.form([{text: t('gallery', 'Scanning root'), name: 'root', type:'text', value:gallery_scanning_root},
+ {text: t('gallery', 'Default order'), name: 'order', type:'select', value:gallery_default_order, options:[
+ {text:t('gallery', 'Ascending'), value:'ASC'}, {text: t('gallery', 'Descending'), value:'DESC'} ]}],
+ t('gallery', 'Settings'),
+ function(values) {
+ var scanning_root = values[0].value;
+ var disp_order = values[1].value;
if (scanning_root == '') {
- alert('Scanning root cannot be empty');
+ OC.dialogs.alert(t('gallery', 'Scanning root cannot be empty'), t('gallery', 'Error'));
return;
}
$.getJSON(OC.filePath('gallery','ajax','galleryOp.php'), {operation: 'store_settings', root: scanning_root, order: disp_order}, function(r) {
if (r.status == 'success') {
- if (r.rescan == 'yes') {
- $('#g-dialog-settings').dialog('close');
- Albums.clear(document.getElementById('gallery_list'));
- scanForAlbums(true);
- return;
- }
+ if (r.rescan == 'yes') {
+ Albums.clear(document.getElementById('gallery_list'));
+ scanForAlbums(true);
+ }
+ gallery_scanning_root = scanning_root;
} else {
- alert('Error: ' + r.cause);
- return;
+ OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Error'));
+ return;
}
- $('#g-dialog-settings').dialog('close');
});
- }
- },
- {
- text: t('gallery', 'Cancel'),
- click: function() {
- $(this).dialog('close');
- }
- }
- ],
- });
+ });
}
diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php
index c6373d3b0a2..9bec5db1b91 100644
--- a/apps/gallery/templates/index.php
+++ b/apps/gallery/templates/index.php
@@ -9,7 +9,7 @@ OC_Util::addScript('files_imageviewer', 'jquery.fancybox-1.3.4.pack');
OC_Util::addStyle( 'files_imageviewer', 'jquery.fancybox-1.3.4' );
$l = new OC_L10N('gallery');
?>
-
+<script type="text/javascript">var gallery_scanning_root='<? echo OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/'); ?>'; var gallery_default_order = '<? echo OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC'); ?>';</script>
<div id="controls">
<div id="scan">
<div id="scanprogressbar"></div>
@@ -29,40 +29,3 @@ $l = new OC_L10N('gallery');
</div>
<div id="gallery_list">
</div>
-
-<div id="dialog-confirm" title="<?php echo $l->t('Remove confirmation');?>" style="display: none">
- <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo $l->t('Do you want to remove album');?> <span id="albumName"></span>?</p>
-</div>
-
-<div id="dialog-form" title="<?php echo $l->t('Change album name');?>" style="display:none">
- <form>
- <fieldset>
- <label for="name"><?php echo $l->t('New album name');?></label>
- <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
- </fieldset>
- </form>
-</div>
-
-<div id="g-dialog-settings" title="<?php echo $l->t('Settings');?>" style="display:none">
- <form>
- <fieldset><?php $root = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'root', '/'); $order = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC');?>
- <label for="name"><?php echo $l->t('Scanning root');?></label>
- <input type="text" name="g-scanning-root" id="g-scanning-root" class="text ui-widget-content ui-corner-all" value="<?php echo $root;?>" /><br/>
-
- <label for="sort"><?php echo $l->t('Default sorting'); ?></label>
- <select id="g-display-order">
- <option value="ASC"<?php echo $order=='ASC'?'selected':'';?>><?php echo $l->t('Ascending'); ?></option>
- <option value="DESC"<?php echo $order=='DESC'?'selected':'';?>><?php echo $l->t('Descending'); ?></option>
- </select><br/>
-<!--
- <label for="sort"><?php echo $l->t('Thumbnails size'); ?></label>
- <select>
- <option value="100">100px</option>
- <option value="150">150px</option>
- <option value="200">200px</option>
- </select>
- -->
- </fieldset>
- </form>
-</div>
-
diff --git a/core/js/oc-dialogs.js b/core/js/oc-dialogs.js
index c11ac13332b..35d0a0c5c42 100644
--- a/core/js/oc-dialogs.js
+++ b/core/js/oc-dialogs.js
@@ -84,10 +84,18 @@ OCdialogs = {
} else content += '>';
} else if (type == 'text' || type == 'password' && fields[a].value)
content += ' value="'+fields[a].value+'">';
+ } else if (type == 'select') {
+ content += '<select name="'+fields[a].name+'"';
+ if (fields[a].value != undefined)
+ content += ' value="'+fields[a].value+'"';
+ content += '>';
+ for (var o in fields[a].options)
+ content += '<option value="'+fields[a].options[o].value+'">'+fields[a].options[o].text+'</option>';
+ content += '</select>';
}
- content += "</td></tr>"
+ content += '</td></tr>';
}
- content += "</table>";
+ content += '</table>';
OCdialogs.message(content, title, OCdialogs.FORM_DIALOG, OCdialogs.OK_CANCEL_BUTTONS, callback);
},
message:function(content, title, dialog_type, buttons, callback) {
@@ -144,7 +152,7 @@ OCdialogs = {
if (callback != undefined) {
var r = [];
var c = 0;
- $(c_id + ' input').each(function(i, elem) {
+ $(c_id + ' input, '+c_id+' select').each(function(i, elem) {
r[c] = {name: $(elem).attr('name'), value: OCdialogs.determineValue(elem)};
c++;
});