mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 03:57:08 -04:00
Add JSCS rules and clean code.
This commit is contained in:
parent
1623d0f60a
commit
f0912f9e9d
26 changed files with 290 additions and 103 deletions
155
.jscsrc
Normal file
155
.jscsrc
Normal file
|
@ -0,0 +1,155 @@
|
|||
{
|
||||
// "disallowCommaBeforeLineBreak": true,
|
||||
"disallowDanglingUnderscores": {
|
||||
"allExcept": ["_exception"]
|
||||
},
|
||||
"disallowEmptyBlocks": true,
|
||||
"disallowImplicitTypeConversion": [
|
||||
"binary",
|
||||
"boolean",
|
||||
"numeric",
|
||||
"string"
|
||||
],
|
||||
"disallowKeywords": [
|
||||
"with"
|
||||
],
|
||||
"disallowKeywordsOnNewLine": [
|
||||
"else"
|
||||
],
|
||||
"disallowMixedSpacesAndTabs": true,
|
||||
"disallowMultipleLineStrings": true,
|
||||
"disallowMultipleSpaces": true,
|
||||
"disallowMultipleVarDecl": true,
|
||||
"disallowNewlineBeforeBlockStatements": true,
|
||||
// "disallowPaddingNewlinesInBlock": true,
|
||||
"disallowQuotedKeysInObjects": true,
|
||||
"disallowSpaceAfterObjectKeys": true,
|
||||
"disallowSpaceAfterPrefixUnaryOperators": [
|
||||
"++",
|
||||
"--",
|
||||
"+",
|
||||
"-",
|
||||
"~",
|
||||
"!"
|
||||
],
|
||||
"disallowSpaceBeforePostfixUnaryOperators": [
|
||||
"++",
|
||||
"--"
|
||||
],
|
||||
"disallowSpacesInCallExpression": true,
|
||||
"disallowSpacesInsideArrayBrackets": "all",
|
||||
"disallowSpacesInsideObjectBrackets": true,
|
||||
"disallowSpacesInsideParentheses": true,
|
||||
"disallowTrailingComma": true,
|
||||
"disallowTrailingWhitespace": true,
|
||||
"disallowYodaConditions": true,
|
||||
// "maximumLineLength": 80,
|
||||
// "requireBlocksOnNewline": true,
|
||||
// "requireCamelCaseOrUpperCaseIdentifiers": true,
|
||||
"requireCapitalizedConstructors": true,
|
||||
"requireCommaBeforeLineBreak": true,
|
||||
"requireCurlyBraces": [
|
||||
"if",
|
||||
"else",
|
||||
"for",
|
||||
"while",
|
||||
"do",
|
||||
"try",
|
||||
"catch",
|
||||
"case",
|
||||
"default"
|
||||
],
|
||||
"requireDollarBeforejQueryAssignment": true,
|
||||
"requireDotNotation": true,
|
||||
// "requireKeywordsOnNewLine": [
|
||||
// "else"
|
||||
// ],
|
||||
"requireLineBreakAfterVariableAssignment": true,
|
||||
"requireLineFeedAtFileEnd": true,
|
||||
"requireOperatorBeforeLineBreak": [
|
||||
"?",
|
||||
"=",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!==",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<="
|
||||
],
|
||||
"requireParenthesesAroundIIFE": true,
|
||||
"requireSemicolons": true,
|
||||
"requireSpaceAfterBinaryOperators": [
|
||||
"=",
|
||||
",",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!=="
|
||||
],
|
||||
"requireSpaceAfterKeywords": [
|
||||
"do",
|
||||
"for",
|
||||
"if",
|
||||
"else",
|
||||
"switch",
|
||||
"case",
|
||||
"try",
|
||||
"catch",
|
||||
"void",
|
||||
"while",
|
||||
"with",
|
||||
"return",
|
||||
"typeof",
|
||||
"function"
|
||||
],
|
||||
"requireSpaceAfterLineComment": true,
|
||||
"requireSpaceBeforeBinaryOperators": [
|
||||
"=",
|
||||
"+",
|
||||
"-",
|
||||
"/",
|
||||
"*",
|
||||
"==",
|
||||
"===",
|
||||
"!=",
|
||||
"!=="
|
||||
],
|
||||
"requireSpaceBeforeBlockStatements": true,
|
||||
"requireSpaceBeforeKeywords": [
|
||||
"else",
|
||||
"while",
|
||||
"catch"
|
||||
],
|
||||
"requireSpaceBeforeObjectValues": true,
|
||||
"requireSpaceBetweenArguments": true,
|
||||
"requireSpacesInAnonymousFunctionExpression": {
|
||||
"beforeOpeningRoundBrace": true,
|
||||
"beforeOpeningCurlyBrace": true
|
||||
},
|
||||
"requireSpacesInConditionalExpression": {
|
||||
"afterTest": true,
|
||||
"beforeConsequent": true,
|
||||
"afterConsequent": true,
|
||||
"beforeAlternate": true
|
||||
},
|
||||
"requireSpacesInForStatement": true,
|
||||
"validateIndentation": 4,
|
||||
"validateJSDoc": {
|
||||
"checkParamNames": true,
|
||||
"checkRedundantParams": true,
|
||||
"requireParamTypes": true
|
||||
},
|
||||
"validateLineBreaks": "LF",
|
||||
"validateParameterSeparator": ", ",
|
||||
"validateQuoteMarks": "'"
|
||||
}
|
|
@ -59,10 +59,11 @@ modulejs.define('core/format', ['_'], function (_) {
|
|||
|
||||
function formatNumber(number, padding) {
|
||||
|
||||
var str = String(number);
|
||||
if (padding) {
|
||||
number = ('000' + number).substr(-padding);
|
||||
str = ('000' + str).substr(-padding);
|
||||
}
|
||||
return '' + number;
|
||||
return str;
|
||||
}
|
||||
|
||||
function formatDate(millis, format) {
|
||||
|
|
|
@ -43,12 +43,12 @@ modulejs.define('core/location', ['_', 'modernizr', 'core/settings', 'core/event
|
|||
|
||||
var hrefsAreDecoded = (function () {
|
||||
|
||||
var testpathname = '/a b';
|
||||
var a = doc.createElement('a');
|
||||
var testpathname = '/a b';
|
||||
var a = doc.createElement('a');
|
||||
|
||||
a.href = testpathname;
|
||||
return uriToPathname(a.href) === testpathname;
|
||||
}());
|
||||
a.href = testpathname;
|
||||
return uriToPathname(a.href) === testpathname;
|
||||
}());
|
||||
|
||||
function encodedHref(href) {
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ modulejs.define('core/types', ['config', '_'], function (config, _) {
|
|||
|
||||
function escapeRegExp(sequence) {
|
||||
|
||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, "\\$&");
|
||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
return sequence.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$]/g, '\\$&');
|
||||
// return sequence.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function parse(types) {
|
||||
|
|
|
@ -24,15 +24,16 @@ modulejs.define('core/util', [], function () {
|
|||
var hre = /^0x[0-9a-f]+$/i;
|
||||
var ore = /^0/;
|
||||
// convert all to strings strip whitespace
|
||||
var x = ('' + val1).replace(sre, '');
|
||||
var y = ('' + val2).replace(sre, '');
|
||||
var x = String(val1).replace(sre, '');
|
||||
var y = String(val2).replace(sre, '');
|
||||
// chunk/tokenize
|
||||
var xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
||||
var yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0');
|
||||
var xN = x.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0');
|
||||
var yN = y.replace(re, '\0$1\0').replace(/\0$/, '').replace(/^\0/, '').split('\0');
|
||||
// numeric, hex or date detection
|
||||
var xD = parseInt(x.match(hre), 10) || (xN.length !== 1 && x.match(dre) && Date.parse(x));
|
||||
var yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
|
||||
var oFxNcL, oFyNcL;
|
||||
var oFxNcL;
|
||||
var oFyNcL;
|
||||
// first try and sort Hex codes or Dates
|
||||
if (yD) {
|
||||
if (xD < yD) {
|
||||
|
@ -42,14 +43,15 @@ modulejs.define('core/util', [], function () {
|
|||
}
|
||||
}
|
||||
// natural sorting through split numeric strings and default strings
|
||||
for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc += 1) {
|
||||
for (var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc += 1) {
|
||||
// find floats not starting with '0', string or 0 if not defined (Clint Priest)
|
||||
oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
|
||||
oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
|
||||
// handle numeric vs string comparison - number < string - (Kyle Adams)
|
||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { return (isNaN(oFxNcL)) ? 1 : -1; }
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
if (isNaN(oFxNcL) !== isNaN(oFyNcL)) {
|
||||
return (isNaN(oFxNcL)) ? 1 : -1;
|
||||
} else if (typeof oFxNcL !== typeof oFyNcL) {
|
||||
// rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
|
||||
oFxNcL += '';
|
||||
oFyNcL += '';
|
||||
}
|
||||
|
|
|
@ -41,15 +41,13 @@ modulejs.define('ext/contextmenu', ['_', '$', 'core/settings', 'core/resource'],
|
|||
|
||||
if (entry.type === '-') {
|
||||
$(templateSep).appendTo($ul);
|
||||
}
|
||||
|
||||
else if (entry.type === 'l') {
|
||||
} else if (entry.type === 'l') {
|
||||
$(templateLabel)
|
||||
.find('.cm-text').text(entry.text).end()
|
||||
.appendTo($ul);
|
||||
}
|
||||
|
||||
else if (entry.type === 'e') {
|
||||
} else if (entry.type === 'e') {
|
||||
$li = $(templateEntry)
|
||||
.data('cm-id', entry.id)
|
||||
.find('.cm-text').text(entry.text).end()
|
||||
|
|
|
@ -3,7 +3,8 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server
|
|||
var settings = _.extend({
|
||||
enabled: false
|
||||
}, allsettings.custom);
|
||||
var $header, $footer;
|
||||
var $header;
|
||||
var $footer;
|
||||
var duration = 200;
|
||||
|
||||
|
||||
|
@ -11,7 +12,10 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server
|
|||
|
||||
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
||||
|
||||
var has_header, has_footer, data, content;
|
||||
var hasHeader;
|
||||
var hasFooter;
|
||||
var data;
|
||||
var content;
|
||||
|
||||
if (response) {
|
||||
data = response.custom;
|
||||
|
@ -19,26 +23,26 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/settings', 'core/server
|
|||
if (data.header) {
|
||||
content = data.header;
|
||||
if (data.header_type === 'md') {
|
||||
content = marked(content);
|
||||
content = marked(content);
|
||||
}
|
||||
$header.html(content).stop().slideDown(duration);
|
||||
has_header = true;
|
||||
hasHeader = true;
|
||||
}
|
||||
|
||||
if (data.footer) {
|
||||
content = data.footer;
|
||||
if (data.footer_type === 'md') {
|
||||
content = marked(content);
|
||||
content = marked(content);
|
||||
}
|
||||
$footer.html(content).stop().slideDown(duration);
|
||||
has_footer = true;
|
||||
hasFooter = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_header) {
|
||||
if (!hasHeader) {
|
||||
$header.stop().slideUp(duration);
|
||||
}
|
||||
if (!has_footer) {
|
||||
if (!hasFooter) {
|
||||
$footer.stop().slideUp(duration);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -10,7 +10,9 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
'</div>';
|
||||
var noMatchTemplate = '<div class="no-match l10n-noMatch"/>';
|
||||
var inputIsVisible = false;
|
||||
var $filter, $input, $noMatch;
|
||||
var $filter;
|
||||
var $input;
|
||||
var $noMatch;
|
||||
|
||||
|
||||
function filter(re) {
|
||||
|
|
|
@ -16,7 +16,8 @@ modulejs.define('ext/google-analytics-ua', ['_', 'core/settings', 'core/event'],
|
|||
return;
|
||||
}
|
||||
|
||||
var el, firstScriptElement;
|
||||
var el;
|
||||
var firstScriptElement;
|
||||
|
||||
win.GoogleAnalyticsObject = id;
|
||||
win[id] = win[id] || function () {
|
||||
|
|
|
@ -4,7 +4,7 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
|
|||
enabled: false,
|
||||
show: false,
|
||||
qrcode: true,
|
||||
qrColor: "#999"
|
||||
qrColor: '#999'
|
||||
}, allsettings.info);
|
||||
var template =
|
||||
'<div id="info">' +
|
||||
|
@ -29,7 +29,14 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
|
|||
'</div>';
|
||||
var sepTemplate = '<span class="sep"/>';
|
||||
var storekey = 'ext/info';
|
||||
var $img, $label, $time, $size, $content, $folders, $files, $qrcode;
|
||||
var $img;
|
||||
var $label;
|
||||
var $time;
|
||||
var $size;
|
||||
var $content;
|
||||
var $folders;
|
||||
var $files;
|
||||
var $qrcode;
|
||||
var currentFolder;
|
||||
|
||||
// <span class="l10n-folders"/>
|
||||
|
@ -49,7 +56,7 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
|
|||
function update(item) {
|
||||
|
||||
var src = item.thumbRational || item.icon;
|
||||
var isThumb = !!item.thumbRational;
|
||||
var isThumb = Boolean(item.thumbRational);
|
||||
|
||||
if (item.isCurrentFolder() || !src) {
|
||||
src = resource.icon('folder');
|
||||
|
@ -143,7 +150,7 @@ modulejs.define('ext/info', ['_', '$', 'modernizr', 'core/settings', 'core/resou
|
|||
});
|
||||
|
||||
// ensure stored value is boolean, otherwise set default
|
||||
if (typeof(store.get(storekey)) !== 'boolean') {
|
||||
if (typeof (store.get(storekey)) !== 'boolean') {
|
||||
store.put(storekey, settings.show);
|
||||
}
|
||||
updateSettings();
|
||||
|
|
|
@ -18,11 +18,11 @@ modulejs.define('ext/peer5', ['_', '$', 'core/settings'], function (_, $, allset
|
|||
$.ajax({
|
||||
url: peer5js,
|
||||
dataType: 'script',
|
||||
cache:true
|
||||
cache: true
|
||||
});
|
||||
|
||||
// attach to file items, once the DOM is ready
|
||||
$(function() {
|
||||
$(function () {
|
||||
|
||||
$('body').on('click', '.item.file > a', function (e) {
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_,
|
|||
|
||||
// reference: http://piwik.org/docs/javascript-tracking/
|
||||
|
||||
var pkBaseURL = (("https:" === document.location.protocol) ? "https://" : "http://") + settings.baseURL + '/';
|
||||
var pkBaseURL = ((document.location.protocol === 'https:') ? 'https://' : 'http://') + settings.baseURL + '/';
|
||||
|
||||
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||
$(window).load(function () {
|
||||
|
|
|
@ -33,8 +33,8 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/settings', 'core/event', '
|
|||
if ($audio.length) {
|
||||
|
||||
$audio.css({
|
||||
'left': '' + (($content.width()-$audio.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$audio.height())*0.5) + 'px'
|
||||
left: String(($content.width() - $audio.width()) * 0.5) + 'px',
|
||||
top: String(($content.height() - $audio.height()) * 0.5) + 'px'
|
||||
});
|
||||
|
||||
preview.setLabels([
|
||||
|
@ -54,16 +54,16 @@ modulejs.define('ext/preview-audio', ['_', '$', 'core/settings', 'core/event', '
|
|||
if ($('#pv-aud-audio').length) {
|
||||
$('#pv-aud-audio')[0].pause();
|
||||
}
|
||||
preloadAudio(currentItem.absHref, function ($preloaded_audio) {
|
||||
preloadAudio(currentItem.absHref, function ($preloadedAudio) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_audio.attr('id', 'pv-aud-audio')).fadeIn(200);
|
||||
$('#pv-content').empty().append($preloadedAudio.attr('id', 'pv-aud-audio')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_audio is visible and therefore $preloaded_audio.width is available
|
||||
// small timeout, so $preloadedAudio is visible and therefore $preloadedAudio.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
|
|||
var templateLoading = '<img id="pv-img-image" class="loading"/>';
|
||||
var spinnerThreshold = 200;
|
||||
var spinnerTimeoutId;
|
||||
var currentItems, currentIdx, currentItem;
|
||||
var currentItems;
|
||||
var currentIdx;
|
||||
var currentItem;
|
||||
|
||||
|
||||
function requestSample(href, callback) {
|
||||
|
@ -30,7 +32,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
|
|||
});
|
||||
}
|
||||
|
||||
function preloadImg(item, callback) {
|
||||
function preloadImage(item, callback) {
|
||||
|
||||
requestSample(item.absHref, function (src) {
|
||||
|
||||
|
@ -62,8 +64,8 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
|
|||
|
||||
var labels = [currentItem.label];
|
||||
if (!settings.size) {
|
||||
labels.push('' + $img[0].naturalWidth + 'x' + $img[0].naturalHeight);
|
||||
labels.push('' + (100 * $img.width() / $img[0].naturalWidth).toFixed(0) + '%');
|
||||
labels.push(String($img[0].naturalWidth) + 'x' + String($img[0].naturalHeight));
|
||||
labels.push(String((100 * $img.width() / $img[0].naturalWidth).toFixed(0)) + '%');
|
||||
}
|
||||
preview.setLabels(labels);
|
||||
}
|
||||
|
@ -88,7 +90,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
|
|||
}, spinnerThreshold);
|
||||
}
|
||||
|
||||
preloadImg(currentItem, function (item, preloaded_img) {
|
||||
preloadImage(currentItem, function (item, preloadedImage) {
|
||||
|
||||
if (item !== currentItem) {
|
||||
return;
|
||||
|
@ -98,7 +100,7 @@ modulejs.define('ext/preview-img', ['_', '$', 'core/settings', 'core/event', 'co
|
|||
preview.showSpinner(false);
|
||||
$('#pv-content')
|
||||
.empty()
|
||||
.append($(preloaded_img).attr('id', 'pv-img-image'))
|
||||
.append($(preloadedImage).attr('id', 'pv-img-image'))
|
||||
.show();
|
||||
onAdjustSize();
|
||||
});
|
||||
|
|
|
@ -57,7 +57,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
|||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
var type = settings.types[currentItem.type];
|
||||
var $text, $code;
|
||||
var $text;
|
||||
var $code;
|
||||
|
||||
if (type === 'none') {
|
||||
$text = $(templateMarkdown).text(textContent);
|
||||
|
@ -82,7 +83,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/settings'
|
|||
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + currentItem.size + ' bytes'
|
||||
String(currentItem.size) + ' bytes'
|
||||
]);
|
||||
preview.setRawLink(currentItem.absHref);
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
|||
}, allsettings['preview-vid']);
|
||||
|
||||
|
||||
function preloadVid(src, callback) {
|
||||
function preloadVideo(src, callback) {
|
||||
|
||||
var $video = $('<video/>')
|
||||
.one('loadedmetadata', function () {
|
||||
|
@ -27,20 +27,20 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
|||
|
||||
function onAdjustSize() {
|
||||
|
||||
var $content = $('#pv-content'),
|
||||
$vid = $('#pv-vid-video');
|
||||
var $content = $('#pv-content');
|
||||
var $vid = $('#pv-vid-video');
|
||||
|
||||
if ($vid.length) {
|
||||
|
||||
$vid.css({
|
||||
'left': '' + (($content.width()-$vid.width())*0.5) + 'px',
|
||||
'top': '' + (($content.height()-$vid.height())*0.5) + 'px'
|
||||
left: String(($content.width() - $vid.width()) * 0.5) + 'px',
|
||||
top: String(($content.height() - $vid.height()) * 0.5) + 'px'
|
||||
});
|
||||
|
||||
preview.setLabels([
|
||||
currentItem.label,
|
||||
'' + $vid[0].videoWidth + 'x' + $vid[0].videoHeight,
|
||||
'' + (100 * $vid.width() / $vid[0].videoWidth).toFixed(0) + '%'
|
||||
String($vid[0].videoWidth) + 'x' + String($vid[0].videoHeight),
|
||||
String((100 * $vid.width() / $vid[0].videoWidth).toFixed(0)) + '%'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -55,16 +55,16 @@ modulejs.define('ext/preview-vid', ['_', '$', 'core/settings', 'core/event', 'ex
|
|||
if ($('#pv-vid-video').length) {
|
||||
$('#pv-vid-video')[0].pause();
|
||||
}
|
||||
preloadVid(currentItem.absHref, function ($preloaded_vid) {
|
||||
preloadVideo(currentItem.absHref, function ($preloadedVideo) {
|
||||
|
||||
clearTimeout(spinnerTimeout);
|
||||
preview.showSpinner(false);
|
||||
|
||||
$('#pv-content').fadeOut(100, function () {
|
||||
|
||||
$('#pv-content').empty().append($preloaded_vid.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
$('#pv-content').empty().append($preloadedVideo.attr('id', 'pv-vid-video')).fadeIn(200);
|
||||
|
||||
// small timeout, so $preloaded_vid is visible and therefore $preloaded_vid.width is available
|
||||
// small timeout, so $preloadedVideo is visible and therefore $preloadedVideo.width is available
|
||||
setTimeout(function () {
|
||||
onAdjustSize();
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
|||
function setIndex(idx, total) {
|
||||
|
||||
if (_.isNumber(idx)) {
|
||||
$('#pv-bar-idx').text('' + idx + (_.isNumber(total) ? '/' + total : '')).show();
|
||||
$('#pv-bar-idx').text(String(idx) + (_.isNumber(total) ? '/' + String(total) : '')).show();
|
||||
} else {
|
||||
$('#pv-bar-idx').text('').hide();
|
||||
}
|
||||
|
|
|
@ -6,10 +6,15 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
checkboxes: false
|
||||
}, allsettings.select);
|
||||
var template = '<span class="selector"><img src="' + resource.image('selected') + '" alt="selected"/></span>';
|
||||
var x = 0, y = 0;
|
||||
var l = 0, t = 0, w = 0, h = 0;
|
||||
var isDragSelect, isCtrlPressed;
|
||||
var shrink = 1/3;
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var l = 0;
|
||||
var t = 0;
|
||||
var w = 0;
|
||||
var h = 0;
|
||||
var isDragSelect;
|
||||
var isCtrlPressed;
|
||||
var shrink = 1 / 3;
|
||||
var $document = $(document);
|
||||
var $html = $('html');
|
||||
var $selectionRect = $('<div id="selection-rect"/>');
|
||||
|
@ -19,9 +24,8 @@ modulejs.define('ext/select', ['_', '$', 'core/settings', 'core/resource', 'core
|
|||
|
||||
var items = _.map($('#items .item.selected'), function (itemElement) {
|
||||
|
||||
return $(itemElement).data('item');
|
||||
});
|
||||
|
||||
return $(itemElement).data('item');
|
||||
});
|
||||
event.pub('selection', items);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,9 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
|||
|
||||
return function (item1, item2) {
|
||||
|
||||
var res, val1, val2;
|
||||
var res;
|
||||
var val1;
|
||||
var val2;
|
||||
|
||||
res = getType(item1) - getType(item2);
|
||||
if (res !== 0) {
|
||||
|
@ -73,8 +75,8 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
|||
val2 = getValue(item2);
|
||||
|
||||
if (isNaN(val1) || isNaN(val2)) {
|
||||
val1 = '' + val1;
|
||||
val2 = '' + val2;
|
||||
val1 = String(val1);
|
||||
val2 = String(val2);
|
||||
|
||||
if (ignorecase) {
|
||||
val1 = val1.toLowerCase();
|
||||
|
@ -89,20 +91,20 @@ modulejs.define('ext/sort', ['_', '$', 'core/settings', 'core/resource', 'core/e
|
|||
|
||||
function sortItems(column, reverse) {
|
||||
|
||||
var headers = $('#items li.header a');
|
||||
var header = $('#items li.header a.' + columnClasses[column]);
|
||||
var $headers = $('#items li.header a');
|
||||
var $header = $('#items li.header a.' + columnClasses[column]);
|
||||
var fn = cmpFn(columnGetters[column], reverse, settings.ignorecase, column === 0 && settings.natural);
|
||||
var current = $('#items .item');
|
||||
var sorted = $('#items .item').sort(fn);
|
||||
var $current = $('#items .item');
|
||||
var $sorted = $('#items .item').sort(fn);
|
||||
|
||||
store.put(storekey, {column: column, reverse: reverse});
|
||||
|
||||
headers.removeClass('ascending descending');
|
||||
header.addClass(reverse ? 'descending' : 'ascending');
|
||||
$headers.removeClass('ascending descending');
|
||||
$header.addClass(reverse ? 'descending' : 'ascending');
|
||||
|
||||
for (var i = 0, l = current.length; i < l; i += 1) {
|
||||
if (current[i] !== sorted[i]) {
|
||||
sorted.detach().sort(fn).appendTo('#items');
|
||||
for (var i = 0, l = $current.length; i < l; i += 1) {
|
||||
if ($current[i] !== $sorted[i]) {
|
||||
$sorted.detach().sort(fn).appendTo('#items');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ modulejs.define('ext/thumbnails', ['_', 'core/settings', 'core/event', 'core/ser
|
|||
if (item.thumbRational) {
|
||||
item.$view.find('.icon.landscape img').addClass('thumb').attr('src', item.thumbRational);
|
||||
} else {
|
||||
requestThumb(type, item.absHref, 4/3, function (src) {
|
||||
requestThumb(type, item.absHref, 4 / 3, function (src) {
|
||||
|
||||
if (src && item.$view) {
|
||||
item.thumbRational = src;
|
||||
|
|
|
@ -6,8 +6,8 @@ modulejs.define('ext/title', ['_', 'core/settings', 'core/event'], function (_,
|
|||
|
||||
function onLocationChanged(item) {
|
||||
|
||||
var labels = _.pluck(item.getCrumb(), 'label'),
|
||||
title = labels.join(' > ');
|
||||
var labels = _.pluck(item.getCrumb(), 'label');
|
||||
var title = labels.join(' > ');
|
||||
|
||||
if (labels.length > 1) {
|
||||
title = labels[labels.length - 1] + ' - ' + title;
|
||||
|
|
|
@ -144,7 +144,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/s
|
|||
|
||||
slide(item, $indicator, $content, false);
|
||||
|
||||
} else if ($indicator.hasClass('close')) {
|
||||
} else if ($indicator.hasClass('close')) {
|
||||
|
||||
slide(item, $indicator, $content, true);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ modulejs.define('ext/tree', ['_', '$', 'core/settings', 'core/resource', 'core/s
|
|||
});
|
||||
|
||||
// ensure stored value is boolean, otherwise set default
|
||||
if (typeof(store.get(storekey)) !== 'boolean') {
|
||||
if (typeof (store.get(storekey)) !== 'boolean') {
|
||||
store.put(storekey, settings.show);
|
||||
}
|
||||
updateSettings();
|
||||
|
|
|
@ -129,15 +129,15 @@ modulejs.define('info', ['$', 'config'], function ($, config) {
|
|||
function onLogin() {
|
||||
|
||||
request({
|
||||
'action': 'login',
|
||||
'pass': $('#pass').val()
|
||||
action: 'login',
|
||||
pass: $('#pass').val()
|
||||
});
|
||||
}
|
||||
|
||||
function onLogout() {
|
||||
|
||||
request({
|
||||
'action': 'logout'
|
||||
action: 'logout'
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -13,19 +13,27 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
function createLabel(sequence) {
|
||||
|
||||
sequence = sequence.replace(reEndsWithSlash, '');
|
||||
try { sequence = decodeURIComponent(sequence); } catch (e) {}
|
||||
try {
|
||||
sequence = decodeURIComponent(sequence);
|
||||
} catch (e) {}
|
||||
return sequence;
|
||||
}
|
||||
|
||||
function splitPath(sequence) {
|
||||
|
||||
if (sequence === '/') {
|
||||
return { parent: null, name: '/' };
|
||||
return {
|
||||
parent: null,
|
||||
name: '/'
|
||||
};
|
||||
}
|
||||
|
||||
var match = reSplitPath.exec(sequence);
|
||||
if (match) {
|
||||
var split = { parent: match[1], name: match[2] };
|
||||
var split = {
|
||||
parent: match[1],
|
||||
name: match[2]
|
||||
};
|
||||
|
||||
if (split.parent && !startsWith(split.parent, settings.rootHref)) {
|
||||
split.parent = null;
|
||||
|
@ -147,7 +155,7 @@ modulejs.define('model/item', ['_', 'core/types', 'core/event', 'core/settings',
|
|||
|
||||
isInCurrentFolder: function () {
|
||||
|
||||
return !!this.parent && this.parent.isCurrentFolder();
|
||||
return Boolean(this.parent) && this.parent.isCurrentFolder();
|
||||
},
|
||||
|
||||
isCurrentParentFolder: function () {
|
||||
|
|
|
@ -3,7 +3,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
|||
var modes = ['details', 'grid', 'icons'];
|
||||
var settings = _.extend({}, {
|
||||
modes: modes,
|
||||
sizes: [20, 40, 60, 80, 100, 150, 200],
|
||||
sizes: [20, 40, 60, 80, 100, 150, 200]
|
||||
}, allsettings.view);
|
||||
var storekey = 'viewmode';
|
||||
var modeTemplate =
|
||||
|
@ -12,7 +12,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
|||
'</div>';
|
||||
var sizeTemplate =
|
||||
'<input id="view-size" type="range" min="0" max="0" value="0">';
|
||||
var sortedSizes = settings.sizes.sort(function (a, b) { return a-b; });
|
||||
var sortedSizes = settings.sizes.sort(function (a, b) { return a - b; });
|
||||
var dynamicStyleTag = null;
|
||||
|
||||
|
||||
|
@ -45,14 +45,14 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
|||
var dsize = cropSize(size, 20, 80);
|
||||
var gsize = cropSize(size, 40, 150);
|
||||
var isize = cropSize(size, 80, 2000);
|
||||
var ilsize = Math.round(isize*4/3);
|
||||
var ilsize = Math.round(isize * 4 / 3);
|
||||
var rules = [
|
||||
'#view.view-details .item .label { line-height: ' + (dsize+14) + 'px !important; }',
|
||||
'#view.view-details .item .date { line-height: ' + (dsize+14) + 'px !important; }',
|
||||
'#view.view-details .item .size { line-height: ' + (dsize+14) + 'px !important; }',
|
||||
'#view.view-details .item .label { line-height: ' + (dsize + 14) + 'px !important; }',
|
||||
'#view.view-details .item .date { line-height: ' + (dsize + 14) + 'px !important; }',
|
||||
'#view.view-details .item .size { line-height: ' + (dsize + 14) + 'px !important; }',
|
||||
'#view.view-details .square { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
|
||||
'#view.view-details .square img { width: ' + dsize + 'px !important; height: ' + dsize + 'px !important; }',
|
||||
'#view.view-details .label { margin: 0 246px 0 ' + (dsize+32) + 'px !important; }',
|
||||
'#view.view-details .label { margin: 0 246px 0 ' + (dsize + 32) + 'px !important; }',
|
||||
|
||||
'#view.view-grid .item .label { line-height: ' + gsize + 'px !important; }',
|
||||
'#view.view-grid .square { width: ' + gsize + 'px !important; height: ' + gsize + 'px !important; }',
|
||||
|
@ -120,7 +120,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
|
|||
}
|
||||
|
||||
if (settings.sizes.length > 1) {
|
||||
max = settings.sizes.length-1;
|
||||
max = settings.sizes.length - 1;
|
||||
$(sizeTemplate)
|
||||
.prop('max', max).attr('max', max)
|
||||
.on('input change', function (ev) {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// @include "lib/prism-*.js"
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
/*global jQuery, marked, Modernizr, Prism, _ */
|
||||
modulejs.define('$', function () { return jQuery; });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue