1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

add path help messages

This commit is contained in:
Luke Pulverenti 2015-07-27 12:21:18 -04:00
parent 2f69a6f07e
commit aa2e4f3f67
8 changed files with 188 additions and 116 deletions

View file

@ -70,119 +70,152 @@
});
}
var systemInfo;
function getSystemInfo() {
var deferred = DeferredBuilder.Deferred();
if (systemInfo) {
deferred.resolveWith(null, [systemInfo]);
} else {
ApiClient.getSystemInfo().done(function (info) {
systemInfo = info;
deferred.resolveWith(null, [systemInfo]);
});
}
return deferred.promise();
}
function show(directoryBrowser, page, options, systemInfo) {
options = options || {};
var fileOptions = {
includeDirectories: true
};
if (options.includeDirectories != null) {
fileOptions.includeDirectories = options.includeDirectories;
}
if (options.includeFiles != null) {
fileOptions.includeFiles = options.includeFiles;
}
options.header = options.header || Globalize.translate('HeaderSelectPath');
options.instruction = options.instruction || "";
var html = '<div data-role="popup" id="popupDirectoryPicker" class="popup" style="min-width:65%;">';
html += '<div class="ui-bar-a" style="text-align: center; padding: 0 20px;">';
html += '<h3>' + options.header + '</h3>';
html += '</div>';
html += '<div data-role="content" class="ui-content">';
html += '<form>';
var instruction = options.instruction ? options.instruction + '<br/><br/>' : '';
html += '<p class="directoryPickerHeadline">';
html += instruction;
html += Globalize.translate('MessageDirectoryPickerInstruction')
.replace('{0}', '<b>\\\\server</b>')
.replace('{1}', '<b>\\\\192.168.1.101</b>');
if (systemInfo.OperatingSystem.toLowerCase() == 'bsd') {
html += '<br/>';
html += '<br/>';
html += Globalize.translate('MessageDirectoryPickerBSDInstruction');
html += '<br/>';
html += '<a href="http://doc.freenas.org/9.3/freenas_jails.html#add-storage" target="_blank">' + Globalize.translate('ButtonMoreInformation') + '</a>';
}
html += '</p>';
html += '<div style="margin:20px 0 0;">';
html += '<label for="txtDirectoryPickerPath" class="lblDirectoryPickerPath">' + Globalize.translate('LabelCurrentPath') + '</label>';
html += '<div style="width:82%;display:inline-block;"><input id="txtDirectoryPickerPath" name="txtDirectoryPickerPath" type="text" required="required" style="font-weight:bold;" /></div>';
html += '<button class="btnRefreshDirectories" type="button" data-icon="refresh" data-inline="true" data-mini="true" data-iconpos="notext">' + Globalize.translate('ButtonRefresh') + '</button>';
html += '</div>';
html += '<div style="height: 180px; overflow-y: auto;">';
html += '<ul id="ulDirectoryPickerList" data-role="listview" data-inset="true" data-auto-enhanced="false"></ul>';
html += '</div>';
html += '<p>';
html += '<button type="submit" data-theme="b" data-icon="check" data-mini="true">' + Globalize.translate('ButtonOk') + '</button>';
html += '<button type="button" data-icon="delete" onclick="$(this).parents(\'.popup\').popup(\'close\');" data-mini="true">' + Globalize.translate('ButtonCancel') + '</button>';
html += '</p>';
html += '</form>';
html += '</div>';
html += '</div>';
$(page).append(html);
var popup = $('#popupDirectoryPicker').popup().trigger('create').on("popupafteropen", function () {
$('#popupDirectoryPicker input:first', this).focus();
}).popup("open").on("popupafterclose", function () {
$('form', this).off("submit");
$(this).off("click").off("change").off("popupafterclose").remove();
}).on("click", ".lnkPath", function () {
var path = this.getAttribute('data-path');
if ($(this).hasClass('lnkFile')) {
$('#txtDirectoryPickerPath', page).val(path);
} else {
refreshDirectoryBrowser(page, path, fileOptions);
}
}).on("click", ".btnRefreshDirectories", function () {
var path = $('#txtDirectoryPickerPath', page).val();
refreshDirectoryBrowser(page, path, fileOptions);
}).on("change", "#txtDirectoryPickerPath", function () {
refreshDirectoryBrowser(page, this.value, fileOptions);
});
var txtCurrentPath = $('#txtDirectoryPickerPath', popup);
if (options.path) {
txtCurrentPath.val(options.path);
}
$('form', popup).on('submit', function () {
if (options.callback) {
options.callback($('#txtDirectoryPickerPath', this).val());
}
return false;
});
refreshDirectoryBrowser(page, txtCurrentPath.val());
}
window.DirectoryBrowser = function (page) {
var self = this;
self.show = function (options) {
options = options || {};
var fileOptions = {
includeDirectories: true
};
if (options.includeDirectories != null) {
fileOptions.includeDirectories = options.includeDirectories;
}
if (options.includeFiles != null) {
fileOptions.includeFiles = options.includeFiles;
}
options.header = options.header || Globalize.translate('HeaderSelectPath');
options.instruction = options.instruction || "";
var html = '<div data-role="popup" id="popupDirectoryPicker" class="popup" style="min-width:65%;">';
html += '<div class="ui-bar-a" style="text-align: center; padding: 0 20px;">';
html += '<h3>' + options.header + '</h3>';
html += '</div>';
html += '<div data-role="content" class="ui-content">';
html += '<form>';
var instruction = options.instruction ? options.instruction + '<br/><br/>' : '';
html += '<p class="directoryPickerHeadline">';
html += instruction;
html += Globalize.translate('MessageDirectoryPickerInstruction')
.replace('{0}', '<b>\\\\server</b>')
.replace('{1}', '<b>\\\\192.168.1.101</b>');
html += '</p>';
html += '<div style="margin:20px 0 0;">';
html += '<label for="txtDirectoryPickerPath" class="lblDirectoryPickerPath">' + Globalize.translate('LabelCurrentPath') + '</label>';
html += '<div style="width:82%;display:inline-block;"><input id="txtDirectoryPickerPath" name="txtDirectoryPickerPath" type="text" required="required" style="font-weight:bold;" /></div>';
html += '<button class="btnRefreshDirectories" type="button" data-icon="refresh" data-inline="true" data-mini="true" data-iconpos="notext">' + Globalize.translate('ButtonRefresh') + '</button>';
html += '</div>';
html += '<div style="height: 180px; overflow-y: auto;">';
html += '<ul id="ulDirectoryPickerList" data-role="listview" data-inset="true" data-auto-enhanced="false"></ul>';
html += '</div>';
html += '<p>';
html += '<button type="submit" data-theme="b" data-icon="check" data-mini="true">' + Globalize.translate('ButtonOk') + '</button>';
html += '<button type="button" data-icon="delete" onclick="$(this).parents(\'.popup\').popup(\'close\');" data-mini="true">' + Globalize.translate('ButtonCancel') + '</button>';
html += '</p>';
html += '</form>';
html += '</div>';
html += '</div>';
$(page).append(html);
var popup = $('#popupDirectoryPicker').popup().trigger('create').on("popupafteropen", function () {
$('#popupDirectoryPicker input:first', this).focus();
}).popup("open").on("popupafterclose", function () {
$('form', this).off("submit");
$(this).off("click").off("change").off("popupafterclose").remove();
}).on("click", ".lnkPath", function () {
var path = this.getAttribute('data-path');
if ($(this).hasClass('lnkFile')) {
$('#txtDirectoryPickerPath', page).val(path);
} else {
refreshDirectoryBrowser(page, path, fileOptions);
}
}).on("click", ".btnRefreshDirectories", function () {
var path = $('#txtDirectoryPickerPath', page).val();
refreshDirectoryBrowser(page, path, fileOptions);
}).on("change", "#txtDirectoryPickerPath", function () {
refreshDirectoryBrowser(page, this.value, fileOptions);
getSystemInfo().done(function (systemInfo) {
show(self, page, options, systemInfo);
});
var txtCurrentPath = $('#txtDirectoryPickerPath', popup);
if (options.path) {
txtCurrentPath.val(options.path);
}
$('form', popup).on('submit', function () {
if (options.callback) {
options.callback($('#txtDirectoryPickerPath', this).val());
}
return false;
});
refreshDirectoryBrowser(page, txtCurrentPath.val());
};
self.close = function () {