diff --git a/css/legacy/messages.css b/css/legacy/messages.css index de09f4a3ff..5ca3eacda4 100644 --- a/css/legacy/messages.css +++ b/css/legacy/messages.css @@ -5,6 +5,14 @@ div.fetching { color: #888; text-align:right; } +.msgprint { + min-height: 60px; + max-height: 500px; + padding: 9px; + color: #333; + overflow: auto; +} + div.notice { postion: absolute; background-color: #000; diff --git a/css/ui/ribbons.css b/css/ui/ribbons.css new file mode 100644 index 0000000000..1b924c706a --- /dev/null +++ b/css/ui/ribbons.css @@ -0,0 +1,105 @@ +/* ribbons */ + +.ribbon-holder { + position: relative; + top: 0; + overflow: hidden; + height: 10em; + float: right; +} + +.ribbon, +.ribbon:hover { + text-decoration: none; +} + +.ribbon { + font-family: Arial, sans-serif; + letter-spacing: -.1px; + opacity: 0.95; + + padding: 0.25em 0; + position: relative; + top: 2.5em; + + /* Defaults friendly for white pages. */ + -moz-box-shadow: 0 0 13px #888; + -webkit-box-shadow: 0 0 13px #888; + color: #FFF; + display: block; + line-height: 1.35em; +} + +.ribbon .text { + padding: 0.1em 3em; +} + +.ribbon-right .ribbon { + -moz-transform: rotate(45deg); + -webkit-transform: rotate(45deg); + right: -2.6em; +} + +.ribbon-left .ribbon { + -moz-transform: rotate(-45deg); + -webkit-transform: rotate(-45deg); + left: -2.6em; +} + +.white.ribbon { + color: #111; + background-color: #F5F5F5; + background: -webkit-gradient(linear, left bottom, left top, from(#f3f3f3), to(#fff)); + -moz-box-shadow: 0 0 13px #999; + -webkit-box-shadow: 0 0 13px #999; + text-shadow: 0 0 .05em; +} + +.white.ribbon .text { + border: 1px solid #cecece; +} + +.red.ribbon { + background-color: #9a0000; + background: -webkit-gradient(linear, left bottom, left top, from(#9a0000), to(#a90000)); +} + +.red.ribbon .text { + border: 1px solid #bf6060; +} + +.green.ribbon { + background-color: #006e00; + background: -webkit-gradient(linear, left bottom, left top, from(#006e00), to(#007200)); +} + +.green.ribbon .text { + border: 1px solid #6bac6b; +} + +.darkblue.ribbon { + background-color: #121621; + color: #ecedee; +} + +.darkblue.ribbon .text { + border: 1px solid #53565e; +} + +.orange.ribbon { + background-color: #E57504; + background: -webkit-gradient(linear, left bottom, left top, from(#dc7202), to(#ee7906)); +} + +.orange.ribbon .text { + border: 1px solid #ebaa65; +} + +.gray.ribbon { + background-color: #6d6d6d; + background: -webkit-gradient(linear, left bottom, left top, from(#6a6a6a) to(#6d6d6d)); +} + +.gray.ribbon .text { + border: 1px solid #a4a4a4; +} diff --git a/css/ui/views.css b/css/ui/views.css index 7f153adcd9..aa0c4177bd 100644 --- a/css/ui/views.css +++ b/css/ui/views.css @@ -33,4 +33,5 @@ div.appframe-toolbar { background: #eeeeee; border-top: 1px solid #f8f8f8; border-bottom: 1px solid #ccc; -} \ No newline at end of file +} + diff --git a/js/legacy/utils/msgprint.js b/js/legacy/utils/msgprint.js index 08209bab9f..5c8925deb0 100644 --- a/js/legacy/utils/msgprint.js +++ b/js/legacy/utils/msgprint.js @@ -21,6 +21,39 @@ // var msg_dialog; + +function msgprint(msg, title) { + if(!msg) return; + + if(typeof(msg)!='string') + msg = JSON.stringify(msg); + + // small message + if(msg.substr(0,8)=='__small:') { + show_alert(msg.substr(8)); return; + } + + if(!msg_dialog) { + msg_dialog = new wn.ui.Dialog({ + title:"Message", + onhide: function() { + msg_dialog.msg_area.empty(); + } + }); + msg_dialog.msg_area = $('
') + .appendTo(msg_dialog.body); + } + + if(msg.search(/
|

/)==-1) + msg = replace_newlines(msg); + + msg_dialog.set_title(title || 'Message') + msg_dialog.msg_area.append(msg); + msg_dialog.show(); + +} + +/* function msgprint(msg, issmall, callback) { if(!msg) return; @@ -67,8 +100,8 @@ function msgprint(msg, issmall, callback) { msg_dialog.msg_icon.src = 'images/lib/icons/accept.gif'; $di(msg_dialog.msg_icon); msg = msg.substr(3); } - - m.innerHTML = replace_newlines(msg); + if(msg.search(/
|

/)==-1) + m.innerHTML = replace_newlines(msg); if(m.offsetHeight > 200) { $y(m, {height:'200px', width:'400px', overflow:'auto'}) @@ -76,7 +109,7 @@ function msgprint(msg, issmall, callback) { msg_dialog.custom_onhide = callback; -} +}*/ // Floating Message diff --git a/js/legacy/widgets/form/form.js b/js/legacy/widgets/form/form.js index 6125020379..22e480777b 100644 --- a/js/legacy/widgets/form/form.js +++ b/js/legacy/widgets/form/form.js @@ -318,7 +318,8 @@ _f.Frm.prototype.set_intro = function(txt) { .insertBefore(this.page_layout.body.firstChild); } if(txt) { - this.intro_area.html(txt); + if(txt.search(/

/)==-1) txt = '

' + txt + '

'; + this.intro_area.html(txt); } else { this.intro_area.remove(); this.intro_area = null; @@ -1096,6 +1097,8 @@ _f.set_value = function(dt, dn, fn, v) { if(changed && (d[fn]==null || v==null) && (cstr(d[fn])==cstr(v))) changed = 0; if(changed) { + //console.log('value changed for ' + dt + ', ' + dn + ', ' + fn) + var prev_unsaved = d.__unsaved d[fn] = v; d.__unsaved = 1; diff --git a/js/legacy/widgets/form/form_fields.js b/js/legacy/widgets/form/form_fields.js index d9c5dd7198..6c0972ea9e 100644 --- a/js/legacy/widgets/form/form_fields.js +++ b/js/legacy/widgets/form/form_fields.js @@ -152,14 +152,7 @@ _f.SectionBreak.prototype.refresh = function(from_form) { if(hidden) { if(this.row)this.row.hide(); } else { - if(this.collapsible) { - //this.section_expand(from_form); - //if(this.df.reqd || this.has_data()) { - // this.section_expand(from_form); - //} else { - // this.section_collapse(); - //} - } + if(this.row)this.row.show(); } } @@ -241,7 +234,8 @@ _f.TableField.prototype.make_body = function() { // description if(this.df.description) { - this.desc_area = $a(this.parent, 'div', 'help small', '', this.df.description) + this.desc_area = $a(this.parent, 'div', 'help small', + {marginBottom:'9px', marginTop:'0px'}, this.df.description) } } } diff --git a/js/legacy/widgets/form/form_header.js b/js/legacy/widgets/form/form_header.js index 86504e2efe..54931a0e22 100644 --- a/js/legacy/widgets/form/form_header.js +++ b/js/legacy/widgets/form/form_header.js @@ -31,14 +31,17 @@ _f.FrmHeader = Class.extend({ init: function(parent, frm) { this.appframe = new wn.ui.AppFrame(parent) - this.appframe.$titlebar.append('\ - '); this.$w = this.appframe.$w; }, refresh: function() { // refresh breadcrumbs - wn.views.breadcrumbs($(this.$w.find('.breadcrumb-area')), - cur_frm.meta.module, cur_frm.meta.name, cur_frm.docname); + if(cur_frm.cscript.set_breadcrumbs) { + this.appframe.clear_breadcrumbs(); + cur_frm.cscript.set_breadcrumbs(); + } else { + wn.views.breadcrumbs(this.appframe, + cur_frm.meta.module, cur_frm.meta.name, cur_frm.docname); + } this.refresh_labels(); this.refresh_toolbar(); @@ -116,6 +119,12 @@ _f.FrmHeader = Class.extend({ // Amend if(docstatus==2 && p[AMEND]) this.appframe.add_button('Amend', function() { cur_frm.amend_doc() }, 'icon-pencil'); + + // Help + if(cur_frm.meta.description) { + this.appframe.add_help_button(wn.markdown('## ' + cur_frm.doctype + '\n
\n' + + cur_frm.meta.description)); + } }, show: function() { diff --git a/js/legacy/wn/widgets/form/sidebar.js b/js/legacy/wn/widgets/form/sidebar.js index 70dc021fad..56d8f40cfd 100644 --- a/js/legacy/wn/widgets/form/sidebar.js +++ b/js/legacy/wn/widgets/form/sidebar.js @@ -160,15 +160,6 @@ wn.widgets.form.sidebar = { Sidebar: function(form) { })); }, display: function() { return !me.form.doc.__islocal } - }, - - { - title: 'Help', - render: function(wrapper) { - $(wrapper).html('
' - + wn.markdown(me.form.meta.description) + '
') - }, - display: function() { return me.form.meta.description } } ] } diff --git a/js/wn/ui/appframe.js b/js/wn/ui/appframe.js index 62b33d0768..3ca97aef74 100644 --- a/js/wn/ui/appframe.js +++ b/js/wn/ui/appframe.js @@ -18,10 +18,12 @@ wn.ui.AppFrame = Class.extend({ title: function(txt) { this.$titlebar.find('.appframe-title').html(txt); }, - add_button: function(label, click, icon) { + make_toolbar: function() { if(!this.$w.find('.appframe-toolbar').length) - this.$w.append('
'); - + this.$w.append('
'); + }, + add_button: function(label, click, icon) { + this.make_toolbar(); args = { label: label, icon:'' }; if(icon) { args.icon = ''; @@ -32,8 +34,32 @@ wn.ui.AppFrame = Class.extend({ .appendTo(this.$w.find('.appframe-toolbar')); return this.buttons[label]; }, + add_help_button: function(txt) { + this.make_toolbar(); + $('') + .data('help-text', txt) + .click(function() { msgprint($(this).data('help-text'), 'Help'); }) + .appendTo(this.$w.find('.appframe-toolbar')); + }, clear_buttons: function() { this.$w.find('.appframe-toolbar').empty(); + }, + add_breadcrumb: function(html) { + if(!this.$breadcrumbs) + this.$breadcrumbs = $('\ + ').appendTo(this.$titlebar); + + var crumb = $('').html(html); + + // first breadcrumb is a title + if(!this.$breadcrumbs.find('span').length) { + crumb.addClass('appframe-title'); + } + crumb.appendTo(this.$breadcrumbs); + }, + clear_breadcrumbs: function() { + this.$breadcrumbs && this.$breadcrumbs.empty(); } }); diff --git a/js/wn/ui/dialog.js b/js/wn/ui/dialog.js index bde93b6737..39131ab095 100644 --- a/js/wn/ui/dialog.js +++ b/js/wn/ui/dialog.js @@ -99,12 +99,13 @@ wn.widgets.FieldGroup = function() { wn.widgets.Dialog = function(opts) { - this.opts = opts; this.display = false; this.make = function(opts) { - if(opts) + if(opts) { this.opts = opts; + $.extend(this, opts); + } if(!this.opts.width) this.opts.width = 480; if(!$('#dialog-container').length) { @@ -183,7 +184,7 @@ wn.widgets.Dialog = function(opts) { this.appframe.$titlebar.find('.close').toggle(false); } - if(opts) this.make(); + if(opts) this.make(opts); } diff --git a/js/wn/views/breadcrumbs.js b/js/wn/views/breadcrumbs.js index f66075b917..b9afcec76e 100644 --- a/js/wn/views/breadcrumbs.js +++ b/js/wn/views/breadcrumbs.js @@ -1,24 +1,22 @@ wn.provide('wn.views'); -wn.views.breadcrumbs = function(parent, module, doctype, name) { - $(parent).empty(); - var $bspan = $(parent); +wn.views.breadcrumbs = function(appframe, module, doctype, name) { + appframe.clear_breadcrumbs(); if(name) { - $bspan.append('' + name + ''); + appframe.add_breadcrumb(name); } else if(doctype) { - $bspan.append('' + doctype + ' List '); + appframe.add_breadcrumb(doctype + ' List'); } else if(module) { - $bspan.append('' + module + ''); + appframe.add_breadcrumb(module); } if(name && doctype && (!locals['DocType'][doctype].issingle)) { - $bspan.append(repl(' in %(doctype)s List', + appframe.add_breadcrumb(repl(' in %(doctype)s List', {doctype: doctype})) }; if(doctype && module && wn.modules && wn.modules[module]) { - $bspan.append(repl(' in %(module)s', + appframe.add_breadcrumb(repl(' in %(module)s', {module: module, module_page: wn.modules[module] })) } - //$bspan.appendTo(parent); } \ No newline at end of file diff --git a/js/wn/views/doclistview.js b/js/wn/views/doclistview.js index 664695f943..29e206d3a7 100644 --- a/js/wn/views/doclistview.js +++ b/js/wn/views/doclistview.js @@ -74,8 +74,7 @@ wn.views.DocListView = wn.ui.Listing.extend({
'); this.appframe = new wn.ui.AppFrame(this.$page.find('.appframe-area')); - wn.views.breadcrumbs($('').appendTo(this.appframe.$titlebar), - locals.DocType[this.doctype].module, this.doctype); + wn.views.breadcrumbs(this.appframe, locals.DocType[this.doctype].module, this.doctype); }, setup: function() {