@@ -1,15 +1,24 @@ | |||
name: Semgrep | |||
name: Linters | |||
on: | |||
pull_request: { } | |||
jobs: | |||
semgrep: | |||
linters: | |||
name: Frappe Linter | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- name: Set up Python 3.8 | |||
uses: actions/setup-python@v2 | |||
with: | |||
python-version: 3.8 | |||
- name: Install and Run Pre-commit | |||
uses: pre-commit/action@v2.0.3 | |||
- name: Download Semgrep rules | |||
run: git clone --depth 1 https://github.com/frappe/semgrep-rules.git frappe-semgrep-rules | |||
@@ -0,0 +1,23 @@ | |||
exclude: 'node_modules|.git' | |||
default_stages: [commit] | |||
fail_fast: false | |||
repos: | |||
- repo: https://github.com/pre-commit/pre-commit-hooks | |||
rev: v4.0.1 | |||
hooks: | |||
- id: trailing-whitespace | |||
files: "frappe.*" | |||
exclude: ".*json$|.*txt$|.*csv|.*md|.*svg" | |||
- id: check-yaml | |||
- id: no-commit-to-branch | |||
args: ['--branch', 'develop'] | |||
- id: check-merge-conflict | |||
- id: check-ast | |||
ci: | |||
autoupdate_schedule: weekly | |||
skip: [] | |||
submodules: false |
@@ -3,7 +3,6 @@ codecov: | |||
coverage: | |||
status: | |||
patch: off | |||
project: | |||
default: false | |||
server: | |||
@@ -166,7 +166,7 @@ class Importer: | |||
if not self.data_import.status == "Partial Success": | |||
self.data_import.db_set("status", "Partial Success") | |||
# commit after every successful import | |||
frappe.db.commit() | |||
@@ -314,19 +314,19 @@ result = [ | |||
{ | |||
"parent_column": "Parent 1", | |||
"column_1": 200, | |||
"column_2": 150.50 | |||
"column_2": 150.50 | |||
}, | |||
{ | |||
"parent_column": "Child 1", | |||
"column_1": 100, | |||
"column_2": 75.25, | |||
"parent_value": "Parent 1" | |||
"parent_value": "Parent 1" | |||
}, | |||
{ | |||
"parent_column": "Child 2", | |||
"column_1": 100, | |||
"column_2": 75.25, | |||
"parent_value": "Parent 1" | |||
"parent_value": "Parent 1" | |||
} | |||
] | |||
@@ -495,7 +495,7 @@ frappe.ui.form.on('Dashboard Chart', { | |||
set_parent_document_type: async function(frm) { | |||
let document_type = frm.doc.document_type; | |||
let doc_is_table = document_type && | |||
let doc_is_table = document_type && | |||
(await frappe.db.get_value('DocType', document_type, 'istable')).message.istable; | |||
frm.set_df_property('parent_document_type', 'hidden', !doc_is_table); | |||
@@ -16,7 +16,7 @@ frappe.ui.form.on('Form Tour', { | |||
frm.add_custom_button(__('Show Tour'), async () => { | |||
const issingle = await check_if_single(frm.doc.reference_doctype); | |||
let route_changed = null; | |||
if (issingle) { | |||
route_changed = frappe.set_route('Form', frm.doc.reference_doctype); | |||
} else if (frm.doc.first_document) { | |||
@@ -24,7 +24,7 @@ frappe.views.calendar["ToDo"] = { | |||
"options": "reference_type", | |||
"label": __("Task") | |||
} | |||
], | |||
get_events_method: "frappe.desk.calendar.get_events" | |||
}; | |||
@@ -9,7 +9,7 @@ frappe.ui.form.on('Workspace', { | |||
refresh: function(frm) { | |||
frm.enable_save(); | |||
if (frm.doc.for_user || (frm.doc.public && !frm.has_perm('write') && | |||
if (frm.doc.for_user || (frm.doc.public && !frm.has_perm('write') && | |||
!frappe.user.has_role('Workspace Manager'))) { | |||
frm.trigger('disable_form'); | |||
} | |||
@@ -176,9 +176,9 @@ def update_page(name, title, icon, parent, public): | |||
doc = frappe.get_doc("Workspace", name) | |||
filters = { | |||
filters = { | |||
'parent_page': doc.title, | |||
'public': doc.public | |||
'public': doc.public | |||
} | |||
child_docs = frappe.get_list("Workspace", filters=filters) | |||
@@ -255,7 +255,7 @@ def delete_page(page): | |||
def sort_pages(sb_public_items, sb_private_items): | |||
if not loads(sb_public_items) and not loads(sb_private_items): | |||
return | |||
sb_public_items = loads(sb_public_items) | |||
sb_private_items = loads(sb_private_items) | |||
@@ -292,7 +292,7 @@ def last_sequence_id(doc): | |||
if not doc_exists: | |||
return 0 | |||
return frappe.db.get_list('Workspace', | |||
return frappe.db.get_list('Workspace', | |||
fields=['sequence_id'], | |||
filters={ | |||
'public': doc.public, | |||
@@ -630,7 +630,7 @@ class InboundMail(Email): | |||
if self.reference_document(): | |||
data['reference_doctype'] = self.reference_document().doctype | |||
data['reference_name'] = self.reference_document().name | |||
else: | |||
else: | |||
if append_to and append_to != 'Communication': | |||
reference_doc = self._create_reference_document(append_to) | |||
if reference_doc: | |||
@@ -3,6 +3,6 @@ | |||
frappe.ui.form.on('Razorpay Settings', { | |||
refresh: function(frm) { | |||
} | |||
}); |
@@ -15,7 +15,7 @@ def execute(): | |||
for file in files: | |||
file_path = file.file_url | |||
file_name = file_path.split('/')[-1] | |||
if not file_path.startswith(('/private/', '/files/')): | |||
continue | |||
@@ -160,7 +160,7 @@ frappe.ui.form.ControlDate = class ControlDate extends frappe.ui.form.ControlDat | |||
get_df_options() { | |||
let df_options = this.df.options; | |||
if (!df_options) return {}; | |||
let options = {}; | |||
if (typeof df_options === 'string') { | |||
try { | |||
@@ -92,7 +92,7 @@ frappe.ui.form.ControlTable = class ControlTable extends frappe.ui.form.Control | |||
if (frappe.model.no_value_type.includes(field.fieldtype)) { | |||
return false; | |||
} | |||
const is_field_matching = () => { | |||
return ( | |||
field.fieldname.toLowerCase() === field_name || | |||
@@ -66,7 +66,7 @@ export default class GridPagination { | |||
} | |||
// only allow numbers from 0-9 and up, down, left, right arrow keys | |||
if (charCode > 31 && (charCode < 48 || charCode > 57) && | |||
if (charCode > 31 && (charCode < 48 || charCode > 57) && | |||
![37, 38, 39, 40].includes(charCode)) { | |||
return false; | |||
} | |||
@@ -150,7 +150,7 @@ frappe.views.ListViewSelect = class ListViewSelect { | |||
const views_wrapper = this.sidebar.sidebar.find(".views-section"); | |||
views_wrapper.find(".sidebar-label").html(`${__(view)}`); | |||
const $dropdown = views_wrapper.find(".views-dropdown"); | |||
let placeholder = `${__("Select {0}", [__(view)])}`; | |||
let html = ``; | |||
@@ -112,9 +112,9 @@ frappe.ui.FieldSelect = class FieldSelect { | |||
// main table | |||
var main_table_fields = std_filters.concat(frappe.meta.docfield_list[me.doctype]); | |||
$.each(frappe.utils.sort(main_table_fields, "label", "string"), function(i, df) { | |||
let doctype = frappe.get_meta(me.doctype).istable && me.parent_doctype ? | |||
let doctype = frappe.get_meta(me.doctype).istable && me.parent_doctype ? | |||
me.parent_doctype : me.doctype; | |||
// show fields where user has read access and if report hide flag is not set | |||
if (frappe.perm.has_perm(doctype, df.permlevel, "read")) | |||
me.add_field_option(df); | |||
@@ -132,9 +132,9 @@ frappe.ui.FieldSelect = class FieldSelect { | |||
} | |||
$.each(frappe.utils.sort(child_table_fields, "label", "string"), function(i, df) { | |||
let doctype = frappe.get_meta(me.doctype).istable && me.parent_doctype ? | |||
let doctype = frappe.get_meta(me.doctype).istable && me.parent_doctype ? | |||
me.parent_doctype : me.doctype; | |||
// show fields where user has read access and if report hide flag is not set | |||
if (frappe.perm.has_perm(doctype, df.permlevel, "read")) | |||
me.add_field_option(df); | |||
@@ -244,7 +244,7 @@ Object.assign(frappe.utils, { | |||
}; | |||
return String(txt).replace( | |||
/[&<>"'`=/]/g, | |||
/[&<>"'`=/]/g, | |||
char => escape_html_mapping[char] || char | |||
); | |||
}, | |||
@@ -262,7 +262,7 @@ Object.assign(frappe.utils, { | |||
}; | |||
return String(txt).replace( | |||
/&|<|>|"|'|/|`|=/g, | |||
/&|<|>|"|'|/|`|=/g, | |||
char => unescape_html_mapping[char] || char | |||
); | |||
}, | |||
@@ -1435,7 +1435,7 @@ Object.assign(frappe.utils, { | |||
// for link titles | |||
frappe._link_titles = {}; | |||
} | |||
frappe._link_titles[doctype + "::" + name] = value; | |||
}, | |||
@@ -10,14 +10,14 @@ | |||
<link href="{{ base_url }}/assets/frappe/css/bootstrap.css" rel="stylesheet"> | |||
<link type="text/css" rel="stylesheet" | |||
href="{{ base_url }}/assets/frappe/css/font-awesome.css"> | |||
<link rel="stylesheet" type="text/css" href="{{ base_url }}/assets/frappe/css/tree.css"> | |||
<link rel="stylesheet" type="text/css" href="{{ base_url }}/assets/frappe/css/tree.css"> | |||
<style> | |||
{{ print_css }} | |||
</style> | |||
<style> | |||
.tree.opened::before, | |||
.tree-node.opened::before, | |||
.tree:last-child::after, | |||
.tree.opened::before, | |||
.tree-node.opened::before, | |||
.tree:last-child::after, | |||
.tree-node:last-child::after { | |||
z-index: 1; | |||
border-left: 1px solid #d1d8dd; | |||
@@ -28,7 +28,7 @@ | |||
text-decoration: none; | |||
cursor: default; | |||
} | |||
.tree.opened > .tree-children > .tree-node > .tree-link::before, | |||
.tree.opened > .tree-children > .tree-node > .tree-link::before, | |||
.tree-node.opened > .tree-children > .tree-node > .tree-link::before { | |||
border-top: 1px solid #d1d8dd; | |||
z-index: 1; | |||
@@ -50,7 +50,7 @@ export default class Block { | |||
document.documentElement.addEventListener('mousemove', do_drag, false); | |||
document.documentElement.addEventListener('mouseup', stop_drag, false); | |||
} | |||
function do_drag(e) { | |||
$(this).css("cursor", "col-resize"); | |||
$('.widget').css("pointer-events", "none"); | |||
@@ -72,7 +72,7 @@ export default class Block { | |||
} else { | |||
window.getSelection().removeAllRanges(); | |||
} | |||
} | |||
} | |||
function stop_drag() { | |||
$(this).css("cursor", "default"); | |||
@@ -221,7 +221,7 @@ export default class Block { | |||
$widget_control.prepend($button); | |||
this.dropdown_list.forEach((item) => { | |||
if ((item.label == 'Expand' || item.label == 'Shrink') && | |||
if ((item.label == 'Expand' || item.label == 'Shrink') && | |||
me.options && !me.options.allow_resize) { | |||
return; | |||
} | |||
@@ -107,7 +107,7 @@ export default class Header extends Block { | |||
if (data.text !== undefined) { | |||
let text = this._data.text || ''; | |||
const contains_html_tag = /<[a-z][\s\S]*>/i.test(text); | |||
this._element.innerHTML = contains_html_tag ? | |||
this._element.innerHTML = contains_html_tag ? | |||
text : `<span class="h${this._settings.default_size}">${text}</span>`; | |||
} | |||
@@ -36,7 +36,7 @@ export default class HeaderSize { | |||
checkState(selection) { | |||
let termWrapper = this.api.selection.findParentTag('SPAN'); | |||
for (const h of ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']) { | |||
if (termWrapper && termWrapper.classList.contains(h)) { | |||
let num = h.match(/\d+/)[0]; | |||
@@ -57,7 +57,7 @@ export default class HeaderSize { | |||
span.innerText = range.toString(); | |||
this.remove_parent_tag(range, range.commonAncestorContainer, span); | |||
range.extractContents(); | |||
range.insertNode(span); | |||
this.api.inlineToolbar.close(); | |||
@@ -90,7 +90,7 @@ export default class HeaderSize { | |||
renderActions() { | |||
this.actions = document.createElement('div'); | |||
this.actions.classList = 'header-level-select'; | |||
this.headerLevels = new Array(6).fill().map((_, idx) => { | |||
const $header_level = document.createElement('div'); | |||
$header_level.classList.add(`h${idx+1}`, 'header-level'); | |||
@@ -116,7 +116,7 @@ export default class Paragraph extends Block { | |||
this.wrapper.appendChild(this._element); | |||
this._element.classList.remove('widget'); | |||
$para_control.appendTo(this.wrapper); | |||
this.wrapper.classList.add('widget', 'paragraph', 'edit-mode'); | |||
this.open_block_list(); | |||
@@ -219,7 +219,7 @@ frappe.views.Workspace = class Workspace { | |||
$sidebar[0].firstElementChild.classList.add("selected"); | |||
if (sidebar_page) sidebar_page.selected = true; | |||
// open child sidebar section if closed | |||
// open child sidebar section if closed | |||
$sidebar.parent().hasClass('hidden') && | |||
$sidebar.parent().removeClass('hidden'); | |||
@@ -244,7 +244,7 @@ frappe.views.Workspace = class Workspace { | |||
this.pages[page.name] = data.message; | |||
if (!this.page_data || Object.keys(this.page_data).length === 0) return; | |||
if (this.page_data.charts && this.page_data.charts.items.length === 0) return; | |||
if (this.page_data.charts && this.page_data.charts.items.length === 0) return; | |||
return frappe.dashboard_utils.get_dashboard_settings().then(settings => { | |||
if (settings) { | |||
@@ -596,9 +596,9 @@ frappe.views.Workspace = class Workspace { | |||
} | |||
update_cached_values(old_item, new_item, duplicate, new_page) { | |||
let [from_pages, to_pages] = old_item.public ? | |||
let [from_pages, to_pages] = old_item.public ? | |||
[this.public_pages, this.private_pages] : [this.private_pages, this.public_pages]; | |||
let old_item_index = from_pages.findIndex(page => page.title == old_item.title); | |||
duplicate && old_item_index++; | |||
@@ -859,7 +859,7 @@ frappe.views.Workspace = class Workspace { | |||
public: page.attributes['item-public'].value | |||
}); | |||
let $drop_icon = $(page).find('.sidebar-item-control .drop-icon').first(); | |||
let $drop_icon = $(page).find('.sidebar-item-control .drop-icon').first(); | |||
if ($(page).find('.sidebar-child-item > *').length != 0) { | |||
$drop_icon.removeClass('hidden'); | |||
} else { | |||
@@ -993,13 +993,13 @@ frappe.views.Workspace = class Workspace { | |||
} | |||
} | |||
}); | |||
this.update_cached_values(new_page, new_page, true, true); | |||
let pre_url = new_page.public ? '' : 'private/'; | |||
let route = pre_url + frappe.router.slug(new_page.title); | |||
frappe.set_route(route); | |||
this.make_sidebar(); | |||
this.show_sidebar_actions(); | |||
}); | |||
@@ -1010,15 +1010,15 @@ frappe.views.Workspace = class Workspace { | |||
validate_page(new_page, old_page) { | |||
let message = ""; | |||
let [from_pages, to_pages] = new_page.is_public ? | |||
let [from_pages, to_pages] = new_page.is_public ? | |||
[this.private_pages, this.public_pages] : [this.public_pages, this.private_pages]; | |||
let section = this.sidebar_categories[new_page.is_public]; | |||
if (to_pages && to_pages.filter(p => p.title == new_page.title)[0]) { | |||
message = `Page with title ${new_page.title} already exist.`; | |||
} | |||
} | |||
if (frappe.router.doctype_route_exist(frappe.router.slug(new_page.title))) { | |||
message = "Doctype with same route already exist. Please choose different title."; | |||
} | |||
@@ -698,12 +698,12 @@ export default class ChartWidget extends Widget { | |||
.get_filters_for_chart_type(this.chart_doc).then(filters => { | |||
chart_saved_filters = this.update_default_date_filters(filters, chart_saved_filters); | |||
this.filters = | |||
frappe.utils.parse_array(user_saved_filters) || frappe.utils.parse_array(this.filters) | |||
frappe.utils.parse_array(user_saved_filters) || frappe.utils.parse_array(this.filters) | |||
|| frappe.utils.parse_array(chart_saved_filters); | |||
}); | |||
} else { | |||
this.filters = | |||
frappe.utils.parse_array(user_saved_filters) || frappe.utils.parse_array(this.filters) | |||
frappe.utils.parse_array(user_saved_filters) || frappe.utils.parse_array(this.filters) | |||
|| frappe.utils.parse_array(chart_saved_filters); | |||
return Promise.resolve(); | |||
} | |||
@@ -993,7 +993,7 @@ jSignatureClass.prototype.resetCanvas = function(data, dontClear){ | |||
ctx.shadowBlur = 0; | |||
} | |||
} | |||
ctx.strokeStyle = settings.color; | |||
// setting up new dataEngine | |||
@@ -12,7 +12,7 @@ | |||
*/ | |||
/* | |||
1. Buttons | |||
*/ | |||
@@ -257,7 +257,7 @@ a.pswp__share--download:hover { | |||
padding: 0 10px; } | |||
/* | |||
4. Caption | |||
*/ | |||
@@ -338,8 +338,8 @@ a.pswp__share--download:hover { | |||
margin: 0; } | |||
.pswp--css_animation .pswp__preloader__cut { | |||
/* | |||
The idea of animating inner circle is based on Polymer ("material") loading indicator | |||
/* | |||
The idea of animating inner circle is based on Polymer ("material") loading indicator | |||
by Keanu Lee https://blog.keanulee.com/2014/10/20/the-tale-of-three-spinners.html | |||
*/ | |||
position: relative; | |||
@@ -409,7 +409,7 @@ a.pswp__share--download:hover { | |||
transform: rotate(0); } } | |||
/* | |||
6. Additional styles | |||
*/ | |||
@@ -5,9 +5,9 @@ | |||
* | |||
* UI on top of main sliding area (caption, arrows, close button, etc.). | |||
* Built just using public methods/properties of PhotoSwipe. | |||
* | |||
* | |||
*/ | |||
(function (root, factory) { | |||
(function (root, factory) { | |||
if (typeof define === 'function' && define.amd) { | |||
define(factory); | |||
} else if (typeof exports === 'object') { | |||
@@ -48,11 +48,11 @@ var PhotoSwipeUI_Default = | |||
_options, | |||
_defaultUIOptions = { | |||
barsSize: {top:44, bottom:'auto'}, | |||
closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'], | |||
timeToIdle: 4000, | |||
closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'], | |||
timeToIdle: 4000, | |||
timeToIdleOutside: 1000, | |||
loadingIndicatorDelay: 1000, // 2s | |||
addCaptionHTMLFn: function(item, captionEl /*, isFake */) { | |||
if(!item.title) { | |||
captionEl.children[0].innerHTML = ''; | |||
@@ -92,7 +92,7 @@ var PhotoSwipeUI_Default = | |||
getTextForShare: function( /* shareButtonData */ ) { | |||
return pswp.currItem.title || ''; | |||
}, | |||
indexIndicatorSep: ' / ', | |||
fitControlsWidth: 1200 | |||
@@ -136,12 +136,12 @@ var PhotoSwipeUI_Default = | |||
} | |||
_blockControlsTap = true; | |||
// Some versions of Android don't prevent ghost click event | |||
// Some versions of Android don't prevent ghost click event | |||
// when preventDefault() was called on touchstart and/or touchend. | |||
// | |||
// This happens on v4.3, 4.2, 4.1, | |||
// older versions strangely work correctly, | |||
// but just in case we add delay on all of them) | |||
// | |||
// This happens on v4.3, 4.2, 4.1, | |||
// older versions strangely work correctly, | |||
// but just in case we add delay on all of them) | |||
var tapDelay = framework.features.isOldAndroid ? 600 : 30; | |||
_blockControlsTapTimeout = setTimeout(function() { | |||
_blockControlsTap = false; | |||
@@ -172,8 +172,8 @@ var PhotoSwipeUI_Default = | |||
_toggleShareModal = function() { | |||
_shareModalHidden = !_shareModalHidden; | |||
if(!_shareModalHidden) { | |||
_toggleShareModalClass(); | |||
setTimeout(function() { | |||
@@ -189,7 +189,7 @@ var PhotoSwipeUI_Default = | |||
} | |||
}, 300); | |||
} | |||
if(!_shareModalHidden) { | |||
_updateShareURLs(); | |||
} | |||
@@ -211,13 +211,13 @@ var PhotoSwipeUI_Default = | |||
} | |||
window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+ | |||
'location=yes,width=550,height=420,top=100,left=' + | |||
'location=yes,width=550,height=420,top=100,left=' + | |||
(window.screen ? Math.round(screen.width / 2 - 275) : 100) ); | |||
if(!_shareModalHidden) { | |||
_toggleShareModal(); | |||
} | |||
return false; | |||
}, | |||
_updateShareURLs = function() { | |||
@@ -242,7 +242,7 @@ var PhotoSwipeUI_Default = | |||
shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+ | |||
'class="pswp__share--' + shareButtonData.id + '"' + | |||
(shareButtonData.download ? 'download' : '') + '>' + | |||
(shareButtonData.download ? 'download' : '') + '>' + | |||
shareButtonData.label + '</a>'; | |||
if(_options.parseShareButtonOut) { | |||
@@ -297,7 +297,7 @@ var PhotoSwipeUI_Default = | |||
_setupLoadingIndicator = function() { | |||
// Setup loading indicator | |||
if(_options.preloaderEl) { | |||
_toggleLoadingIndicator(true); | |||
_listen('beforeChange', function() { | |||
@@ -310,18 +310,18 @@ var PhotoSwipeUI_Default = | |||
if(pswp.currItem && pswp.currItem.loading) { | |||
if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) { | |||
// show preloader if progressive loading is not enabled, | |||
// show preloader if progressive loading is not enabled, | |||
// or image width is not defined yet (because of slow connection) | |||
_toggleLoadingIndicator(false); | |||
_toggleLoadingIndicator(false); | |||
// items-controller.js function allowProgressiveImg | |||
} | |||
} else { | |||
_toggleLoadingIndicator(true); // hide preloader | |||
} | |||
}, _options.loadingIndicatorDelay); | |||
}); | |||
_listen('imageLoadComplete', function(index, item) { | |||
if(pswp.currItem === item) { | |||
@@ -341,8 +341,8 @@ var PhotoSwipeUI_Default = | |||
var gap = item.vGap; | |||
if( _fitControlsInViewport() ) { | |||
var bars = _options.barsSize; | |||
var bars = _options.barsSize; | |||
if(_options.captionEl && bars.bottom === 'auto') { | |||
if(!_fakeCaptionContainer) { | |||
_fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake'); | |||
@@ -360,7 +360,7 @@ var PhotoSwipeUI_Default = | |||
} else { | |||
gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom; | |||
} | |||
// height of top bar is static, no need to calculate it | |||
gap.top = bars.top; | |||
} else { | |||
@@ -371,7 +371,7 @@ var PhotoSwipeUI_Default = | |||
// Hide controls when mouse is used | |||
if(_options.timeToIdle) { | |||
_listen('mouseUsed', function() { | |||
framework.bind(document, 'mousemove', _onIdleMouseMove); | |||
framework.bind(document, 'mouseout', _onMouseLeaveWindow); | |||
@@ -418,77 +418,77 @@ var PhotoSwipeUI_Default = | |||
var _uiElements = [ | |||
{ | |||
name: 'caption', | |||
{ | |||
name: 'caption', | |||
option: 'captionEl', | |||
onInit: function(el) { | |||
_captionContainer = el; | |||
} | |||
onInit: function(el) { | |||
_captionContainer = el; | |||
} | |||
}, | |||
{ | |||
name: 'share-modal', | |||
{ | |||
name: 'share-modal', | |||
option: 'shareEl', | |||
onInit: function(el) { | |||
onInit: function(el) { | |||
_shareModal = el; | |||
}, | |||
onTap: function() { | |||
_toggleShareModal(); | |||
} | |||
} | |||
}, | |||
{ | |||
name: 'button--share', | |||
{ | |||
name: 'button--share', | |||
option: 'shareEl', | |||
onInit: function(el) { | |||
onInit: function(el) { | |||
_shareButton = el; | |||
}, | |||
onTap: function() { | |||
_toggleShareModal(); | |||
} | |||
} | |||
}, | |||
{ | |||
name: 'button--zoom', | |||
{ | |||
name: 'button--zoom', | |||
option: 'zoomEl', | |||
onTap: pswp.toggleDesktopZoom | |||
}, | |||
{ | |||
name: 'counter', | |||
{ | |||
name: 'counter', | |||
option: 'counterEl', | |||
onInit: function(el) { | |||
onInit: function(el) { | |||
_indexIndicator = el; | |||
} | |||
} | |||
}, | |||
{ | |||
name: 'button--close', | |||
{ | |||
name: 'button--close', | |||
option: 'closeEl', | |||
onTap: pswp.close | |||
}, | |||
{ | |||
name: 'button--arrow--left', | |||
{ | |||
name: 'button--arrow--left', | |||
option: 'arrowEl', | |||
onTap: pswp.prev | |||
}, | |||
{ | |||
name: 'button--arrow--right', | |||
{ | |||
name: 'button--arrow--right', | |||
option: 'arrowEl', | |||
onTap: pswp.next | |||
}, | |||
{ | |||
name: 'button--fs', | |||
{ | |||
name: 'button--fs', | |||
option: 'fullscreenEl', | |||
onTap: function() { | |||
onTap: function() { | |||
if(_fullscrenAPI.isFullscreen()) { | |||
_fullscrenAPI.exit(); | |||
} else { | |||
_fullscrenAPI.enter(); | |||
} | |||
} | |||
} | |||
}, | |||
{ | |||
name: 'preloader', | |||
{ | |||
name: 'preloader', | |||
option: 'preloaderEl', | |||
onInit: function(el) { | |||
onInit: function(el) { | |||
_loadingIndicator = el; | |||
} | |||
} | |||
} | |||
]; | |||
@@ -514,12 +514,12 @@ var PhotoSwipeUI_Default = | |||
if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) { | |||
if( _options[uiElement.option] ) { // if element is not disabled from options | |||
framework.removeClass(item, 'pswp__element--disabled'); | |||
if(uiElement.onInit) { | |||
uiElement.onInit(item); | |||
} | |||
//item.style.display = 'block'; | |||
} else { | |||
framework.addClass(item, 'pswp__element--disabled'); | |||
@@ -538,7 +538,7 @@ var PhotoSwipeUI_Default = | |||
}; | |||
ui.init = function() { | |||
@@ -574,9 +574,9 @@ var PhotoSwipeUI_Default = | |||
_listen('preventDragEvent', function(e, isDown, preventObj) { | |||
var t = e.target || e.srcElement; | |||
if( | |||
t && | |||
t.getAttribute('class') && e.type.indexOf('mouse') > -1 && | |||
( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) ) | |||
t && | |||
t.getAttribute('class') && e.type.indexOf('mouse') > -1 && | |||
( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) ) | |||
) { | |||
preventObj.prevent = false; | |||
} | |||
@@ -634,7 +634,7 @@ var PhotoSwipeUI_Default = | |||
framework.addClass( _controls, 'pswp__ui--hidden'); | |||
ui.setIdle(false); | |||
}); | |||
if(!_options.showAnimationDuration) { | |||
framework.removeClass( _controls, 'pswp__ui--hidden'); | |||
@@ -649,7 +649,7 @@ var PhotoSwipeUI_Default = | |||
}); | |||
_listen('parseVerticalMargin', _applyNavBarGaps); | |||
_setupUIElements(); | |||
if(_options.shareEl && _shareButton && _shareModal) { | |||
@@ -673,7 +673,7 @@ var PhotoSwipeUI_Default = | |||
ui.update = function() { | |||
// Don't update UI if it's hidden | |||
if(_controlsVisible && pswp.currItem) { | |||
ui.updateIndexIndicator(); | |||
if(_options.captionEl) { | |||
@@ -704,19 +704,19 @@ var PhotoSwipeUI_Default = | |||
pswp.setScrollOffset( 0, framework.getScrollY() ); | |||
}, 50); | |||
} | |||
// toogle pswp--fs class on root element | |||
framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs'); | |||
}; | |||
ui.updateIndexIndicator = function() { | |||
if(_options.counterEl) { | |||
_indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) + | |||
_options.indexIndicatorSep + | |||
_indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) + | |||
_options.indexIndicatorSep + | |||
_options.getNumItemsFn(); | |||
} | |||
}; | |||
ui.onGlobalTap = function(e) { | |||
e = e || window.event; | |||
var target = e.target || e.srcElement; | |||
@@ -742,7 +742,7 @@ var PhotoSwipeUI_Default = | |||
pswp.toggleDesktopZoom(e.detail.releasePoint); | |||
} | |||
} | |||
} else { | |||
// tap anywhere (except buttons) to toggle visibility of controls | |||
@@ -759,7 +759,7 @@ var PhotoSwipeUI_Default = | |||
pswp.close(); | |||
return; | |||
} | |||
} | |||
}; | |||
ui.onMouseOver = function(e) { | |||
@@ -809,7 +809,7 @@ var PhotoSwipeUI_Default = | |||
eventK: 'moz' + tF | |||
}; | |||
} else if(dE.webkitRequestFullscreen) { | |||
api = { | |||
@@ -829,21 +829,21 @@ var PhotoSwipeUI_Default = | |||
} | |||
if(api) { | |||
api.enter = function() { | |||
api.enter = function() { | |||
// disable close-on-scroll in fullscreen | |||
_initalCloseOnScrollValue = _options.closeOnScroll; | |||
_options.closeOnScroll = false; | |||
_initalCloseOnScrollValue = _options.closeOnScroll; | |||
_options.closeOnScroll = false; | |||
if(this.enterK === 'webkitRequestFullscreen') { | |||
pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT ); | |||
} else { | |||
return pswp.template[this.enterK](); | |||
return pswp.template[this.enterK](); | |||
} | |||
}; | |||
api.exit = function() { | |||
api.exit = function() { | |||
_options.closeOnScroll = _initalCloseOnScrollValue; | |||
return document[this.exitK](); | |||
return document[this.exitK](); | |||
}; | |||
api.isFullscreen = function() { return document[this.elementK]; }; | |||
@@ -11,10 +11,10 @@ function prettyDate(time){ | |||
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/, "")), | |||
diff = (((new Date()).getTime() - date.getTime()) / 1000), | |||
day_diff = Math.floor(diff / 86400); | |||
if ( isNaN(day_diff) || day_diff < 0 ) | |||
return ''; | |||
return day_diff == 0 && ( | |||
diff < 60 && "just now" || | |||
diff < 120 && "1 minute ago" || | |||
@@ -1070,11 +1070,11 @@ body { | |||
} | |||
.resizer { | |||
width: 10px; | |||
width: 10px; | |||
height: 100%; | |||
position:absolute; | |||
right: 0; | |||
bottom: 0; | |||
position:absolute; | |||
right: 0; | |||
bottom: 0; | |||
cursor: col-resize; | |||
border-color: transparent; | |||
transition: border-color 0.3s ease-in-out; | |||
@@ -1089,8 +1089,8 @@ body { | |||
margin-bottom: 0 !important; | |||
flex: 1; | |||
&:focus { | |||
outline: none; | |||
&:focus { | |||
outline: none; | |||
} | |||
} | |||
@@ -1124,11 +1124,11 @@ body { | |||
color: var(--text-muted); | |||
border: 1px dashed var(--gray-400); | |||
cursor: pointer; | |||
.widget-control > * { | |||
width: auto; | |||
} | |||
.spacer-left { | |||
min-width: 74px; | |||
} | |||
@@ -1158,7 +1158,7 @@ body { | |||
gap: 5px; | |||
background-color: var(--card-bg); | |||
padding-left: 5px; | |||
.drag-handle { | |||
cursor: all-scroll; | |||
cursor: grabbing; | |||
@@ -1325,7 +1325,7 @@ body { | |||
padding: 6px 10px; | |||
font-size: small; | |||
border-radius: var(--border-radius-sm); | |||
margin: 1px 0px; | |||
margin: 1px 0px; | |||
} | |||
.dropdown-item-icon { | |||
@@ -202,7 +202,7 @@ $level-margin-right: 8px; | |||
box-shadow: none; | |||
margin-left: 0px !important; | |||
border: 1px solid var(--dark-border-color); | |||
&.btn-info { | |||
background-color: var(--gray-400); | |||
border-color: var(--gray-400); | |||
@@ -150,7 +150,7 @@ body { | |||
min-width: 50%; | |||
padding: 0 4px; | |||
margin-bottom: var(--margin-md); | |||
&:last-child { | |||
margin-bottom: 0; | |||
} | |||
@@ -163,18 +163,18 @@ | |||
padding: var(--padding-lg); | |||
box-shadow: var(--card-shadow); | |||
border-radius: var(--border-radius-md); | |||
.new-comment-fields { | |||
flex: 1; | |||
.form-label { | |||
font-weight: var(--text-bold); | |||
} | |||
.comment-text-area textarea { | |||
resize: none; | |||
} | |||
@media (min-width: 576px) { | |||
.comment-by { | |||
padding-right: 0px !important; | |||
@@ -184,7 +184,7 @@ | |||
} | |||
} | |||
} | |||
#comment-list { | |||
position: relative; | |||
@@ -206,7 +206,7 @@ | |||
top: 10px; | |||
left: -17px; | |||
} | |||
.comment-content { | |||
box-shadow: var(--card-shadow); | |||
border-radius: var(--border-radius-md); | |||
@@ -9,7 +9,7 @@ | |||
width: 80% | |||
} | |||
} | |||
.back-to-home { | |||
font-size: var(--text-base); | |||
} | |||
@@ -46,7 +46,7 @@ | |||
.navbar-toggler { | |||
border-color: rgba(255,255,255, 0.1); | |||
.icon { | |||
stroke: none; | |||
} | |||
@@ -1,6 +1,6 @@ | |||
.portal-row { | |||
padding: 1rem 0; | |||
a { | |||
color: $body-color; | |||
} |
@@ -3,7 +3,7 @@ | |||
[data-doctype="Web Form"] { | |||
.page-content-wrapper { | |||
.breadcrumb-container.container { | |||
@include media-breakpoint-up(sm) { | |||
padding-left: 0; | |||
@@ -38,6 +38,6 @@ | |||
like | |||
} | |||
}); | |||
} | |||
} | |||
}); | |||
</script> |
@@ -11,7 +11,7 @@ | |||
<p>{{ payment_message or _("Your payment was successfully accepted") }}</p> | |||
{% if not payment_message %} | |||
<div> | |||
<a | |||
<a | |||
href='{{ frappe.form_dict.redirect_to or "/" }}' | |||
class='btn btn-primary btn-sm'> | |||
{{ _("Continue") }} | |||
@@ -35,7 +35,7 @@ def get_random(doctype, filters=None, doc=False): | |||
condition = " where " + " and ".join(condition) | |||
else: | |||
condition = "" | |||
out = frappe.db.multisql({ | |||
'mariadb': """select name from `tab%s` %s | |||
order by RAND() limit 1 offset 0""" % (doctype, condition), | |||
@@ -22,7 +22,7 @@ | |||
add_top_padding=1, | |||
add_bottom_padding=1, | |||
) }} | |||
{% if doc.get({"doctype":"Company History"}) %} | |||
<section class="section section-padding-bottom"> | |||
@@ -87,7 +87,7 @@ | |||
{% if item.target %}target="{{ item.target }}"{% endif %}> | |||
{{ _(item.title or item.label) }} | |||
</a> | |||
{%- endfor %} | |||
{%- endfor %} | |||
</ul> | |||
</div> | |||
</div> |
@@ -10,6 +10,6 @@ no_cache = 1 | |||
def get_context(context): | |||
if frappe.session.user=='Guest': | |||
frappe.throw(_("You need to be logged in to access this page"), frappe.PermissionError) | |||
context.current_user = frappe.get_doc("User", frappe.session.user) | |||
context.show_sidebar=True |
@@ -53,8 +53,8 @@ | |||
{% endfor %} | |||
{% else %} | |||
<div class="empty-apps-state"> | |||
<img src="/assets/frappe/images/ui-states/empty-app-state.svg"/> | |||
<div class="font-weight-bold mt-4"> | |||
<img src="/assets/frappe/images/ui-states/empty-app-state.svg"/> | |||
<div class="font-weight-bold mt-4"> | |||
{{ _("No Active Sessions")}} | |||
</div> | |||
<div class="text-muted mt-2"> | |||