diff --git a/frappe/desk/page/chat/chat.js b/frappe/desk/page/chat/chat.js index c2ada4cfc9..435d54916b 100644 --- a/frappe/desk/page/chat/chat.js +++ b/frappe/desk/page/chat/chat.js @@ -61,7 +61,7 @@ frappe.Chat = Class.extend({ var $row = $('
'); frappe.pages.chat.chat.list.data.unshift(comment); frappe.pages.chat.chat.list.render_row($row, comment); - frappe.pages.chat.chat.list.$w.prepend($row); + frappe.pages.chat.chat.list.wrapper.prepend($row); }, make_sidebar: function() { diff --git a/frappe/public/build.json b/frappe/public/build.json index 6f800e8677..70f550dcd6 100755 --- a/frappe/public/build.json +++ b/frappe/public/build.json @@ -193,8 +193,7 @@ "css/list.min.css": [ "public/css/list.css", "public/css/tag-it.css", - "public/css/calendar.css", - "public/css/gantt.css" + "public/css/calendar.css" ], "js/list.min.js": [ "public/js/frappe/ui/listing.html", @@ -219,13 +218,13 @@ "public/js/frappe/list/listview.js", "public/js/frappe/views/calendar_base.js", "public/js/frappe/views/calendar.js", - "public/js/frappe/views/ganttview.js", "public/js/frappe/list/blueimp-gallery.html", "public/js/frappe/list/image_view_item_row.html", "public/js/frappe/list/image_view_item_main_head.html", "public/js/frappe/list/header_select_all_like_filter.html", "public/js/frappe/list/item_assigned_to_comment_count.html", - "public/js/frappe/views/treeview.js" + "public/js/frappe/views/treeview.js", + "public/js/frappe/views/gantt.js" ], "css/report.min.css": [ "public/css/report.css", diff --git a/frappe/public/css/gantt.css b/frappe/public/css/gantt.css index 4118a25366..e81cef2a83 100644 --- a/frappe/public/css/gantt.css +++ b/frappe/public/css/gantt.css @@ -1,38 +1,78 @@ -.gantt, -.gantt2 { - border: none !important; - border-radius: none !important; - margin: 0px auto !important; -} -.gantt *, -.gantt2 * { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; -} -.fn-gantt .leftPanel, -.fn-gantt .leftPanel .row0, -.fn-gantt .leftPanel .name, -.fn-gantt .leftPanel .desc, -.fn-gantt .dataPanel, -.fn-gantt .day, -.fn-gantt .date, -.fn-gantt .rightPanel .month, -.fn-gantt .rightPanel .year { - border-color: #d1d8dd !important; -} -.fn-gantt .navigate { - border: none !important; -} -.fn-gantt .leftPanel .name, -.fn-gantt .leftPanel .desc, -.fn-gantt .spacer, -.fn-gantt .wd, -.fn-gantt .rightPanel .month, -.fn-gantt .rightPanel .year, -.fn-gantt .bottom { - background-color: #F7FAFC !important; -} -.fn-gantt .today { - background-color: #D9F6FF !important; +.gantt #grid .grid-background { + fill: none; +} +.gantt #grid .grid-header { + fill: #fff; + stroke: #e0e0e0; + stroke-width: 1.4; +} +.gantt #grid .row-odd { + fill: #ffffff; +} +.gantt #grid .row-even { + fill: #f5f5f5; +} +.gantt #grid .row-line { + stroke: #EBEFF2; +} +.gantt #grid .tick { + stroke: #aaa; + stroke-width: 0.2; +} +.gantt #grid .tick.thick { + stroke-width: 0.4; +} +.gantt #arrow { + fill: none; + stroke: #333; + stroke-width: 1.4; +} +.gantt .bar { + fill: #b8c2cc; + stroke: #8D99A6; + stroke-width: 0; + transition: stroke-width 0.3s ease; +} +.gantt .bar-label { + fill: #fff; + dominant-baseline: central; + text-anchor: middle; + font-size: 12px; + font-weight: lighter; + letter-spacing: 0.8px; +} +.gantt .bar-label.big { + fill: #555; + text-anchor: start; +} +.gantt .handle { + fill: #ddd; + cursor: ew-resize; + opacity: 0; + visibility: hidden; + transition: opacity .3s ease; +} +.gantt .bar-wrapper { + cursor: pointer; +} +.gantt .bar-wrapper:hover .bar { + stroke-width: 2; +} +.gantt .bar-wrapper:hover .handle { + visibility: visible; + opacity: 1; +} +.gantt .bar-wrapper.active .bar { + stroke-width: 2; +} +.gantt .primary-text, +.gantt .secondary-text { + font-size: 12px; + text-anchor: middle; +} +.gantt .primary-text { + fill: #999; +} +.gantt .secondary-text { + fill: #555; } diff --git a/frappe/public/js/frappe/list/doclistview.js b/frappe/public/js/frappe/list/doclistview.js index c056a2c9d8..b5846d6914 100644 --- a/frappe/public/js/frappe/list/doclistview.js +++ b/frappe/public/js/frappe/list/doclistview.js @@ -130,14 +130,13 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ this.init_listview(); this.setup_filterable(); this.init_filters(); - this.init_headers(); this.init_sort_selector(); - this.init_like(); - this.init_select_all(); }, init_headers: function() { - this.header = this.meta.image_view == 0? "list_item_main_head": "image_view_item_main_head"; + this.page.main.find(".list-headers").empty(); + + this.header = this.current_view === 'List' ? "list_item_main_head": "image_view_item_main_head"; var main = frappe.render_template(this.header, { columns: this.listview.columns, right_column: this.listview.settings.right_column, @@ -147,6 +146,9 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ this.list_header = $(frappe.render_template("list_item_row_head", { main:main, list:this.listview })) .appendTo(this.page.main.find(".list-headers")); + + this.init_like(); + this.init_select_all(); }, init_listview: function() { @@ -303,7 +305,14 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ refresh: function(dirty) { if(dirty!==undefined) this.dirty = dirty; - this.init_stats(); + this.refresh_sidebar(); + + // if view has changed, re-render header + if(this.current_view != this.list_sidebar.current_view) { + this.current_view = this.list_sidebar.current_view; + this.init_headers(); + this.dirty = true; + } if(this.listview.settings.refresh) { this.listview.settings.refresh(this); @@ -354,8 +363,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ if(!this.listview.settings.use_route) { var route = frappe.get_route(); - var me = this; - if(route[2]) { + if(route[2] && !in_list(['Image', 'Gantt'], route[2])) { $.each(frappe.utils.get_args_dict_from_url(route[2]), function(key, val) { me.set_filter(key, val, true); }); @@ -401,16 +409,131 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ return no_result_message; }, + + render_rows: function(values) { + this['render_rows_' + this.current_view](values); + }, + + render_rows_Image: function(values) { + var cols = values.slice(); + while (cols.length) { + row = this.add_row(cols[0]); + $("
").appendTo(row); + $(row).addClass('no-hover'); + this.render_image_view_row(row, cols.splice(0, 4)); + } + + this.render_image_gallery(); + }, + + render_rows_List: function(values) { + var m = Math.min(values.length, this.page_length); + for(var i=0; i < m; i++) { + this.render_row(this.add_row(values[i]), values[i], this, i); + } + }, + + render_rows_Gantt: function(values) { + var gantt_area = $('') + .appendTo(this.wrapper.find('.result-list').css("overflow", "scroll")); + var id = frappe.dom.set_unique_id(gantt_area); + var me = this; + var field_map = frappe.views.calendar[this.doctype].field_map; + + var view_modes; + frappe.require(["assets/frappe/js/lib/snap.svg-min.js", "assets/frappe/css/gantt.css"], function() { + me.gantt = new Gantt({ + parent_selector: '#' + id, + bar: { + height: 20, + color: "#b8c2cc", + progress_color: "#a3a3ff", + hover_color: "#8D99A6", + hover_progress_color: "#7575ff" + }, + events: { + bar_on_click: function (task) { + frappe.set_route('Form', task.doctype, task.id); + }, + bar_on_datechange: function(task, start, end) { + update_date(task.id, field_map.start, start.format("YYYY-MM-DD"), function() { + update_date(task.id, field_map.end, end.format("YYYY-MM-DD"), function() { + show_alert("Saved", 1); + }); + }); + }, + on_viewmode_change: function(mode) { + me.list_settings.view_mode = mode; + } + } + }); + + view_modes = me.gantt.opts.valid_view_modes || []; + values.forEach(function(item) { + me.gantt.add_task({ + start: item[field_map.start], + end: item[field_map.end], + name: item[field_map.title], + id: item[field_map.id], + doctype: me.doctype, + progress: item.progress + }); + }) + me.gantt.render(); + + var dropdown = ""; + + var dropdown_list = ""; + view_modes.forEach(function(view_mode) { + dropdown_list += "
  • " + + "" + + view_mode + "
  • "; + }) + var $dropdown = $(dropdown) + $dropdown.find(".dropdown-menu") + .append(dropdown_list); + + me.$page.find(".list-row-right").css("margin-top", 0).html($dropdown) + + $dropdown.on("click", ".option", function() { + var mode = $(this).data('value'); + me.gantt.set_view_mode(mode) + $dropdown.find(".dropdown-text").text(mode); + }) + }); + + function update_date(id, fieldname, value, callback) { + frappe.call({ + method: "frappe.client.set_value", + args: { + doctype: me.doctype, + name: id, + fieldname: fieldname, + value: value + }, + callback: function(r) { + callback(); + } + }); + } + }, + render_row: function(row, data) { data.doctype = this.doctype; this.listview.render(row, data, this); }, + render_image_view_row: function(row, data) { for (var i = 0; i < data.length; i++) { data[i].doctype = this.doctype; this.listview.render(row, data[i], this) } }, + get_args: function() { var args = { doctype: this.doctype, @@ -644,7 +767,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ }); // after delete, hide delete button - this.$w.on("render-complete", function() { + this.wrapper.on("render-complete", function() { me.toggle_delete(); }); } @@ -675,7 +798,7 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ get_checked_items: function() { var me = this; return $.map(this.$page.find('.list-delete:checked'), function(e) { - if(me.meta.image_view == 0){ + if(me.current_view==='List'){ return $(e).parents(".list-row:first").data('data'); } else{ @@ -711,9 +834,9 @@ frappe.views.DocListView = frappe.ui.Listing.extend({ } ); }, - init_stats: function() { + refresh_sidebar: function() { var me = this; - this.sidebar_stats = new frappe.views.ListSidebar({ + this.list_sidebar = new frappe.views.ListSidebar({ doctype: this.doctype, stats: this.listview.stats, parent: this.$page.find('.layout-side-section'), diff --git a/frappe/public/js/frappe/list/list_sidebar.html b/frappe/public/js/frappe/list/list_sidebar.html index 4038d91ad7..981bfe5c2b 100644 --- a/frappe/public/js/frappe/list/list_sidebar.html +++ b/frappe/public/js/frappe/list/list_sidebar.html @@ -14,15 +14,17 @@
  • + + + -
  • {%= __("Assigned To Me") %}
  • -
  • - {%= __("Show Images") %} -
  • {% if(frappe.help.has_help(doctype)) { %}
  • {{ __("Help") }}
  • {% } %} diff --git a/frappe/public/js/frappe/list/list_sidebar.js b/frappe/public/js/frappe/list/list_sidebar.js index 8961fed4b4..19b8fd6737 100644 --- a/frappe/public/js/frappe/list/list_sidebar.js +++ b/frappe/public/js/frappe/list/list_sidebar.js @@ -24,15 +24,41 @@ frappe.views.ListSidebar = Class.extend({ this.setup_reports(); this.setup_assigned_to_me(); - this.setup_list_view_switching(); + this.setup_views(); + + }, + setup_views: function() { + var show_list_link = false; if(frappe.views.calendar[this.doctype]) { - this.sidebar.find(".calendar-link, .gantt-link").removeClass("hide"); + this.sidebar.find(".calendar-link").removeClass("hide"); + this.sidebar.find('.list-link[data-view="Gantt"]').removeClass('hide'); + show_list_link = true; } if(frappe.treeview_settings[this.doctype]) { this.sidebar.find(".tree-link").removeClass("hide"); } + + this.current_view = 'List'; + var route = frappe.get_route(); + if(route.length > 2 && (route[2]==='Gantt' || route[2]==='Image')) { + this.current_view = route[2]; + } + + // disable link for current view + this.sidebar.find('.list-link[data-view="'+ this.current_view +'"] a') + .attr('disabled', 'disabled').addClass('disabled'); + + // show image link if image_view + if(this.doclistview.meta.image_field) { + this.sidebar.find('.list-link[data-view="Image"]').removeClass('hide'); + show_list_link = true; + } + + if(show_list_link) { + this.sidebar.find('.list-link[data-view="List"]').removeClass('hide'); + } }, setup_reports: function() { // add reports linked to this doctype to the dropdown @@ -78,35 +104,6 @@ frappe.views.ListSidebar = Class.extend({ me.doclistview.assigned_to_me(); }); }, - setup_list_view_switching: function() { - var me = this; - if(this.doclistview.meta.image_field) { - this.page.sidebar.find(".switch-list-view").removeClass("hide"); - - var label = this.doclistview.meta.image_view ? __("Show List"): __("Show Images"); - this.page.sidebar.find(".switch-list-view a").html(label) - - var switch_list_view = function(view) { - var image_view = 0 - if(view == __("Show Images")) - image_view = 1 - - me.doclistview.meta.image_view = image_view; - - // clear and render the headers again while switching - me.doclistview.page.main.find(".list-headers").empty(); - me.doclistview.init_headers(); - me.doclistview.init_like(); - me.doclistview.init_select_all(); - - me.doclistview.refresh(true); - }; - - this.page.sidebar.find(".switch-list-view a").on("click", function() { - switch_list_view(label) - }); - } - }, get_stats: function() { var me = this return frappe.call({ diff --git a/frappe/public/js/frappe/list/listview.js b/frappe/public/js/frappe/list/listview.js index a1f44c6974..19df9c620b 100644 --- a/frappe/public/js/frappe/list/listview.js +++ b/frappe/public/js/frappe/list/listview.js @@ -214,12 +214,7 @@ frappe.views.ListView = Class.extend({ this.id_list.push(data.name); } - if(this.meta && this.meta.image_view == 0){ - this.render_list_row(row, data); - } - else{ - this.render_list_image(row, data); - } + this['render_row_' + this.doclistview.current_view](row, data); if(this.settings.post_render_item) { this.settings.post_render_item(this, row, data); @@ -228,7 +223,7 @@ frappe.views.ListView = Class.extend({ this.render_tags(row, data); }, - render_list_row: function(row, data) { + render_row_List: function(row, data) { var main = frappe.render_template("list_item_main", { data: data, columns: this.columns, @@ -244,7 +239,7 @@ frappe.views.ListView = Class.extend({ right_column: this.settings.right_column })).appendTo(row); }, - render_list_image: function(row, data) { + render_row_Image: function(row, data) { this.allowed_type = [ "Check", "Currency", "Data", "Date", "Datetime", "Float", "Int", "Link", @@ -290,7 +285,7 @@ frappe.views.ListView = Class.extend({ //me.render_timestamp_and_comments(row, data); } }); - tag_editor.$w.on("click", ".tagit-label", function() { + tag_editor.wrapper.on("click", ".tagit-label", function() { me.doclistview.set_filter("_user_tags", $(this).text()); }); diff --git a/frappe/public/js/frappe/ui/filters/filters.js b/frappe/public/js/frappe/ui/filters/filters.js index cec3a86924..31db542a50 100644 --- a/frappe/public/js/frappe/ui/filters/filters.js +++ b/frappe/public/js/frappe/ui/filters/filters.js @@ -5,22 +5,22 @@ frappe.ui.FilterList = Class.extend({ init: function(opts) { $.extend(this, opts); this.filters = []; - this.$w = this.$parent; + this.wrapper = this.$parent; this.set_events(); }, set_events: function() { var me = this; // show filters - this.$w.find('.new-filter').bind('click', function() { + this.wrapper.find('.new-filter').bind('click', function() { me.add_filter(me.doctype, 'name'); }); }, show_filters: function() { - this.$w.find('.show_filters').toggle(); + this.wrapper.find('.show_filters').toggle(); if(!this.filters.length) { this.add_filter(this.doctype, 'name'); - this.filters[0].$w.find(".filter_field input").focus(); + this.filters[0].wrapper.find(".filter_field input").focus(); } }, @@ -42,10 +42,10 @@ frappe.ui.FilterList = Class.extend({ } - this.$w.find('.show_filters').toggle(true); + this.wrapper.find('.show_filters').toggle(true); var is_new_filter = arguments.length===0; - if (is_new_filter && this.$w.find(".is-new-filter:visible").length) { + if (is_new_filter && this.wrapper.find(".is-new-filter:visible").length) { // only allow 1 new filter at a time! return; } @@ -53,7 +53,7 @@ frappe.ui.FilterList = Class.extend({ var filter = this.push_new_filter(doctype, fieldname, condition, value); if (filter && is_new_filter) { - filter.$w.addClass("is-new-filter"); + filter.wrapper.addClass("is-new-filter"); } if (filter && hidden) { @@ -131,12 +131,12 @@ frappe.ui.Filter = Class.extend({ this.set_events(); }, make: function() { - this.$w = $(frappe.render_template("edit_filter", {})).appendTo(this.flist.$w.find('.filter_area')); + this.wrapper = $(frappe.render_template("edit_filter", {})).appendTo(this.flist.wrapper.find('.filter_area')); }, make_select: function() { var me = this; this.fieldselect = new frappe.ui.FieldSelect({ - parent: this.$w.find('.fieldname_select_area'), + parent: this.wrapper.find('.fieldname_select_area'), doctype: this.doctype, filter_fields: this.filter_fields, select: function(doctype, fieldname) { @@ -150,17 +150,17 @@ frappe.ui.Filter = Class.extend({ set_events: function() { var me = this; - this.$w.find("a.remove-filter").on("click", function() { + this.wrapper.find("a.remove-filter").on("click", function() { me.remove(); }); - this.$w.find(".set-filter-and-run").on("click", function() { - me.$w.removeClass("is-new-filter"); + this.wrapper.find(".set-filter-and-run").on("click", function() { + me.wrapper.removeClass("is-new-filter"); me.flist.listobj.run(); }); // add help for "in" codition - me.$w.find('.condition').change(function() { + me.wrapper.find('.condition').change(function() { if(!me.field) return; var condition = $(this).val(); if(in_list(["in", "like", "not in", "not like"], condition)) { @@ -188,7 +188,7 @@ frappe.ui.Filter = Class.extend({ }, remove: function(dont_run) { - this.$w.remove(); + this.wrapper.remove(); this.$btn_group && this.$btn_group.remove(); this.field = null; this.flist.update_filters(); @@ -202,7 +202,7 @@ frappe.ui.Filter = Class.extend({ set_values: function(doctype, fieldname, condition, value) { // presents given (could be via tags!) this.set_field(doctype, fieldname); - if(condition) this.$w.find('.condition').val(condition).change(); + if(condition) this.wrapper.find('.condition').val(condition).change(); if(value!=null) this.field.set_input(value); }, @@ -247,7 +247,7 @@ frappe.ui.Filter = Class.extend({ old_text = me.field.get_parsed_value(); } - var field_area = me.$w.find('.filter_field').empty().get(0); + var field_area = me.wrapper.find('.filter_field').empty().get(0); var f = frappe.ui.form.make_control({ df: df, parent: field_area, @@ -301,7 +301,7 @@ frappe.ui.Filter = Class.extend({ } else if(['Text','Small Text','Text Editor','Code','Tag','Comments', 'Dynamic Link','Read Only','Assign'].indexOf(df.fieldtype)!=-1) { df.fieldtype = 'Data'; - } else if(df.fieldtype=='Link' && this.$w.find('.condition').val()!="=") { + } else if(df.fieldtype=='Link' && this.wrapper.find('.condition').val()!="=") { df.fieldtype = 'Data'; } if(df.fieldtype==="Data" && (df.options || "").toLowerCase()==="email") { @@ -313,9 +313,9 @@ frappe.ui.Filter = Class.extend({ if(!fieldtype) { // set as "like" for data fields if(df.fieldtype=='Data') { - this.$w.find('.condition').val('like'); + this.wrapper.find('.condition').val('like'); } else { - this.$w.find('.condition').val('='); + this.wrapper.find('.condition').val('='); } } }, @@ -356,14 +356,14 @@ frappe.ui.Filter = Class.extend({ }, get_condition: function() { - return this.$w.find('.condition').val(); + return this.wrapper.find('.condition').val(); }, freeze: function() { if(this.$btn_group) { // already made, just hide the condition setter this.set_filter_button_text(); - this.$w.toggle(false); + this.wrapper.toggle(false); return; } @@ -379,7 +379,7 @@ frappe.ui.Filter = Class.extend({ title="'+__("Remove Filter")+'">\ \ ') - .insertAfter(this.flist.$w.find(".set-filters .new-filter")); + .insertAfter(this.flist.wrapper.find(".set-filters .new-filter")); this.set_filter_button_text(); @@ -388,9 +388,9 @@ frappe.ui.Filter = Class.extend({ }); this.$btn_group.find(".toggle-filter").on("click", function() { - me.$w.toggle(); + me.wrapper.toggle(); }) - this.$w.toggle(false); + this.wrapper.toggle(false); }, set_filter_button_text: function() { diff --git a/frappe/public/js/frappe/ui/listing.html b/frappe/public/js/frappe/ui/listing.html index 44d57887f0..3bef38c4c1 100644 --- a/frappe/public/js/frappe/ui/listing.html +++ b/frappe/public/js/frappe/ui/listing.html @@ -27,15 +27,15 @@
    - -
    -
    -
    +
    +
    + +
    diff --git a/frappe/public/js/frappe/ui/listing.js b/frappe/public/js/frappe/ui/listing.js index 6b1bb79114..36ae779f87 100644 --- a/frappe/public/js/frappe/ui/listing.js +++ b/frappe/public/js/frappe/ui/listing.js @@ -64,11 +64,11 @@ frappe.ui.Listing = Class.extend({ $.extend(this, this.opts); $(this.parent).html(frappe.render_template("listing", this.opts)); - this.$w = $(this.parent).find('.frappe-list'); + this.wrapper = $(this.parent).find('.frappe-list'); this.set_events(); if(this.page) { - this.$w.find('.list-toolbar-wrapper').toggle(false); + this.wrapper.find('.list-toolbar-wrapper').toggle(false); } if(this.show_filters) { @@ -79,9 +79,9 @@ frappe.ui.Listing = Class.extend({ if(this.page) { return this.page.add_menu_item(label, click, icon) } else { - this.$w.find('.list-toolbar-wrapper').removeClass("hide"); + this.wrapper.find('.list-toolbar-wrapper').removeClass("hide"); $button = $('') - .appendTo(this.$w.find('.list-toolbar')) + .appendTo(this.wrapper.find('.list-toolbar')) .html((icon ? (" ") : "") + label) .click(click); return $button @@ -91,13 +91,13 @@ frappe.ui.Listing = Class.extend({ var me = this; // next page - this.$w.find('.btn-more').click(function() { + this.wrapper.find('.btn-more').click(function() { me.run(true); }); - this.$w.find(".btn-group-paging .btn").click(function() { + this.wrapper.find(".btn-group-paging .btn").click(function() { me.page_length = cint($(this).attr("data-value")); - me.$w.find(".btn-group-paging .btn-info").removeClass("btn-info"); + me.wrapper.find(".btn-group-paging .btn-info").removeClass("btn-info"); $(this).addClass("btn-info"); // always reset when changing list page length @@ -106,20 +106,20 @@ frappe.ui.Listing = Class.extend({ // select the correct page length if(this.opts.page_length != 20) { - this.$w.find(".btn-group-paging .btn-info").removeClass("btn-info"); - this.$w.find(".btn-group-paging .btn[data-value='"+ this.opts.page_length +"']").addClass('btn-info'); + this.wrapper.find(".btn-group-paging .btn-info").removeClass("btn-info"); + this.wrapper.find(".btn-group-paging .btn[data-value='"+ this.opts.page_length +"']").addClass('btn-info'); } // title if(this.title) { - this.$w.find('h3').html(this.title).toggle(true); + this.wrapper.find('h3').html(this.title).toggle(true); } // new this.set_primary_action(); if(me.no_toolbar || me.hide_toolbar) { - me.$w.find('.list-toolbar-wrapper').toggle(false); + me.wrapper.find('.list-toolbar-wrapper').toggle(false); } }, @@ -159,7 +159,7 @@ frappe.ui.Listing = Class.extend({ make_filters: function() { this.filter_list = new frappe.ui.FilterList({ listobj: this, - $parent: this.$w.find('.list-filters').toggle(true), + $parent: this.wrapper.find('.list-filters').toggle(true), doctype: this.doctype, filter_fields: this.filter_fields }); @@ -170,9 +170,9 @@ frappe.ui.Listing = Class.extend({ clear: function() { this.data = []; - this.$w.find('.result-list').empty(); - this.$w.find('.result').toggle(true); - this.$w.find('.no-result').toggle(false); + this.wrapper.find('.result-list').empty(); + this.wrapper.find('.result').toggle(true); + this.wrapper.find('.no-result').toggle(false); this.start = 0; }, @@ -274,7 +274,7 @@ frappe.ui.Listing = Class.extend({ } }, set_working: function(flag) { - this.$w.find('.img-load').toggle(flag); + this.wrapper.find('.img-load').toggle(flag); }, get_call_args: function() { // load query @@ -305,7 +305,7 @@ frappe.ui.Listing = Class.extend({ render_results: function(r) { if(this.start===0) this.clear(); - this.$w.find('.btn-more, .list-loading').toggle(false); + this.wrapper.find('.btn-more, .list-loading').toggle(false); if(r.message) { r.values = this.get_values_from_response(r.message); @@ -317,7 +317,7 @@ frappe.ui.Listing = Class.extend({ this.update_paging(r.values); } else { if(this.start===0) { - this.$w.find('.result').toggle(false); + this.wrapper.find('.result').toggle(false); var msg = this.get_no_result_message ? this.get_no_result_message() @@ -325,7 +325,7 @@ frappe.ui.Listing = Class.extend({ ? this.no_result_message : __("Nothing to show")); - this.$w.find('.no-result') + this.wrapper.find('.no-result') .html(msg) .toggle(true); } @@ -334,7 +334,7 @@ frappe.ui.Listing = Class.extend({ // callbacks if(this.onrun) this.onrun(); if(this.callback) this.callback(r); - this.$w.trigger("render-complete"); + this.wrapper.trigger("render-complete"); }, get_values_from_response: function(data) { @@ -356,21 +356,9 @@ frappe.ui.Listing = Class.extend({ }, render_rows: function(values) { // render the rows - if(this.meta && this.meta.image_view){ - var cols = values.slice(); - while (cols.length) { - row = this.add_row(cols[0]); - $("
    ").appendTo(row); - $(row).addClass('no-hover'); - this.render_image_view_row(row, cols.splice(0, 4), this, i); - } - - this.render_image_gallery(); - } else { - var m = Math.min(values.length, this.page_length); - for(var i=0; i < m; i++) { - this.render_row(this.add_row(values[i]), values[i], this, i); - } + var m = Math.min(values.length, this.page_length); + for(var i=0; i < m; i++) { + this.render_row(this.add_row(values[i]), values[i], this, i); } }, render_image_gallery: function(){ @@ -384,17 +372,17 @@ frappe.ui.Listing = Class.extend({ "assets/frappe/js/lib/gallery/css/blueimp-gallery-indicator.css" ], function(){ // remove previous gallery container - me.$w.find(".blueimp-gallery").remove(); + me.wrapper.find(".blueimp-gallery").remove(); // append gallery div var gallery = frappe.render_template("blueimp-gallery", {}); - $(gallery).appendTo(me.$w); + $(gallery).appendTo(me.wrapper); - me.$w.find(".zoom-view").click(function(event){ + me.wrapper.find(".zoom-view").click(function(event){ event.preventDefault(); opts = { doctype: me.doctype, docname: $(this).parent().attr('data-name'), - container: me.$w + container: me.wrapper }; new frappe.views.ImageView(opts); }); @@ -402,14 +390,14 @@ frappe.ui.Listing = Class.extend({ }, update_paging: function(values) { if(values.length >= this.page_length) { - this.$w.find('.btn-more').toggle(true); + this.wrapper.find('.btn-more').toggle(true); this.start += this.page_length; } }, add_row: function(row) { return $('
    ') .data("data", (this.meta && this.meta.image_view) == 0 ? row : null) - .appendTo(this.$w.find('.result-list')) + .appendTo(this.wrapper.find('.result-list')) .get(0); }, refresh: function() { diff --git a/frappe/public/js/frappe/ui/tags.js b/frappe/public/js/frappe/ui/tags.js index e68a020b76..aa8f9636cf 100644 --- a/frappe/public/js/frappe/ui/tags.js +++ b/frappe/public/js/frappe/ui/tags.js @@ -13,8 +13,8 @@ frappe.ui.TagEditor = Class.extend({ */ $.extend(this, opts); var me = this; - this.$w = $('
    ').appendTo(this.parent) - this.$tags = $('