Commit e0d94f9a authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_officejs: Update default parameters for automatic redirection and default search engine

parent b25768be
......@@ -44,8 +44,8 @@
var gadget = this,
portal_type = null,
option = {
auto_redirect: false,
search_engine: ""
auto_redirect: true,
search_engine: "https://duckduckgo.com/?q="
};
return new RSVP.Queue()
......
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1499162399.03</float>
<float>1499162533.71</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -14,6 +14,15 @@
</head>
<body>
<fieldset class="ui-controlgroup ui-corner-all">
<div class="center ui-controlgroup-controls">
<div class="ui-field-contain">
<p>To use the bookmark manager as a search engine, add this url to the search engine list of your browser : </p>
<input type="text" class="search-engine-url" style="font-weight:bold;" readonly></input>
</div>
</div>
</fieldset>
<form class="options">
<fieldset class="ui-controlgroup ui-corner-all">
<div class="center ui-controlgroup-controls">
......@@ -25,7 +34,7 @@
<div class="ui-field-contain">
<label for="search_engine">Default Search Engine :</label>
<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset">
<input type="text" name="search_engine" value="https://duckduckgo.com/?q=">
<input type="text" name="search_engine">
</div>
</div>
......@@ -35,8 +44,5 @@
</fieldset>
</form>
<hr />
<p>To use the bookmark manager as a search engine, add this url to the search engine list of your browser : <span class="search-engine-url" style="font-weight:bold;"></span></p>
</body>
</html>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.64450.52709.9386</string> </value>
<value> <string>960.32715.46116.17902</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1485780641.43</float>
<float>1499161500.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -2,7 +2,7 @@
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS) {
"use strict";
function saveOptionDict(gadget) {
var option_dict = {
search_engine: gadget.props.element.querySelector(".options input[name=\"search_engine\"]").value,
......@@ -11,20 +11,6 @@
return gadget.setSetting("option", option_dict);
}
function setSearchUrl(gadget) {
return RSVP.Queue()
.push(function() {
return gadget.getSetting("option");
})
.push(function(option) {
return gadget.getUrlFor({page: 'bookmark_dispatcher'});
})
.push(function(url) {
url = window.location.origin + window.location.pathname + url + '&search=%s';
gadget.props.element.getElementsByClassName("search-engine-url")[0].innerHTML = url;
});
}
rJS(window)
.ready(function (g) {
g.props = {};
......@@ -55,20 +41,25 @@
return RSVP.Queue()
// Set the URL used to set the Bookmark Manager as a search engine.
.push(function () {
return setSearchUrl(gadget);
return gadget.getUrlFor({page: 'bookmark_dispatcher'});
})
// Set elements in form to reflect option dict
.push(function () {
return gadget.getSetting("option")
.push(function(option_dict) {
if (option_dict) {
gadget.props.element.querySelector(".options input[name=\"search_engine\"]").value = option_dict.search_engine;
gadget.props.element.querySelector(".options input[name=\"auto_redirect\"]").checked = option_dict.auto_redirect;
}
});
.push(function (url) {
url = window.location.origin + window.location.pathname
+ url + '&search=%s';
gadget.props.element.getElementsByClassName("search-engine-url")[0].value = url;
return gadget.getSetting("option");
})
// Adds a save button
.push(gadget.updateHeader({title: 'Bookmark Manager Preferences', save_action: true}));
.push(function (option_dict) {
if (option_dict === undefined) {
option_dict = {
search_engine: "https://duckduckgo.com/?q=",
auto_redirect: true
};
}
gadget.props.element.querySelector(".options input[name=\"search_engine\"]").value = option_dict.search_engine;
gadget.props.element.querySelector(".options input[name=\"auto_redirect\"]").checked = option_dict.auto_redirect;
return gadget.updateHeader({title: 'Bookmark Manager Preferences', save_action: true});
});
})
.onEvent("submit", function () {
saveOptionDict(this);
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>956.64450.52709.9386</string> </value>
<value> <string>960.32743.2629.17442</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1485780623.37</float>
<float>1499161566.28</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment