Sfoglia il codice sorgente

updated calculator:

version-14
Rushabh Mehta 11 anni fa
parent
commit
b3b25f501e
2 ha cambiato i file con 12 aggiunte e 9 eliminazioni
  1. +11
    -8
      frappe/public/js/frappe/ui/toolbar/search.js
  2. +1
    -1
      frappe/public/js/frappe/ui/toolbar/toolbar.js

+ 11
- 8
frappe/public/js/frappe/ui/toolbar/search.js Vedi File

@@ -169,22 +169,25 @@ frappe.search.verbs = [
} }
}, },


// pages
// calculator
function(txt) { function(txt) {
var first = txt.substr(0,1); var first = txt.substr(0,1);
if(first==parseInt(first) || first==="(" || first==="=") { if(first==parseInt(first) || first==="(" || first==="=") {
if(first==="=") { if(first==="=") {
txt = txt.substr(1); txt = txt.substr(1);
} }

try {
var val = eval(txt);
} catch(e) {
var val = e.message;
}

frappe.search.options.push({ frappe.search.options.push({
value: __('Calculate "{0}"', [txt]),
match: txt,
value: $.format('"{0}" = {1}', [txt, val]),
match: val,
onclick: function(match) { onclick: function(match) {
try {
msgprint(eval(match), __('Calculate "{0}"', [match]));
} catch(e) {
msgprint(e.message);
}
msgprint(match, "Result");
} }
}); });
}; };


+ 1
- 1
frappe/public/js/frappe/ui/toolbar/toolbar.js Vedi File

@@ -45,7 +45,7 @@ frappe.ui.toolbar.Toolbar = Class.extend({
placeholder="' + __("Search or type a command") + '" \ placeholder="' + __("Search or type a command") + '" \
style="padding: 2px 6px; height: 24px; margin-top: 5px; \ style="padding: 2px 6px; height: 24px; margin-top: 5px; \
margin-left: 10px; background-color: #ddd; \ margin-left: 10px; background-color: #ddd; \
min-width: 200px; \
min-width: 250px; \
border-radius: 10px;">\ border-radius: 10px;">\
</div>\ </div>\
</form>\ </form>\


Caricamento…
Annulla
Salva