diff options
author | zefanja <zefanja@freenet.de> | 2013-12-27 21:58:52 +0700 |
---|---|---|
committer | zefanja <zefanja@freenet.de> | 2013-12-27 21:58:52 +0700 |
commit | 4befa8b70deb1c413363e43b7ce579b3907b83e6 (patch) | |
tree | 454cfe82e6e32f8e7560e573777c6d252d99dc87 /source | |
parent | cc465575749685e7f633d694c841d1b3ee875fab (diff) | |
download | biblez-ng-4befa8b70deb1c413363e43b7ce579b3907b83e6.tar.gz |
* added settings panel
* removed deploy folder → it's in the gh-pages branch (like before)
* you test the app under http://zefanja.github.io/biblez-ng/app/
Diffstat (limited to 'source')
-rw-r--r-- | source/App.css | 16 | ||||
-rw-r--r-- | source/App.js | 15 | ||||
-rw-r--r-- | source/api.js | 11 | ||||
-rw-r--r-- | source/main.js | 46 | ||||
-rw-r--r-- | source/package.js | 1 | ||||
-rw-r--r-- | source/settings.js | 58 |
6 files changed, 141 insertions, 6 deletions
diff --git a/source/App.css b/source/App.css index f3e29bf..db42b4a 100644 --- a/source/App.css +++ b/source/App.css @@ -162,4 +162,20 @@ h3, h1 { font-size: 1.3em; +} + +/* SETTINGS */ +.settings-container { + max-width: 600px; + margin-left: auto; + margin-right: auto; + margin-top: 10px; +} + +.settings-item { + padding: 5px 0; +} + +.settings-row { + padding: 5px; }
\ No newline at end of file diff --git a/source/App.js b/source/App.js index 8dd2cb3..b07b7f4 100644 --- a/source/App.js +++ b/source/App.js @@ -11,11 +11,11 @@ enyo.kind({ fit: true, components: [ {name: "panel", kind: "Panels", fit: true, classes: "app-panels", arrangerKind: "CardArranger", draggable: false, onTransitionFinish: "handlePanels", components: [ - {name: "main", kind: "biblez.main", onOpenModuleManager: "openModuleManager", onOpenBC: "openSelector", onModuleChanged: "handleChangeModule"}, + {name: "main", kind: "biblez.main", onOpenModuleManager: "openModuleManager", onOpenBC: "openSelector", onModuleChanged: "handleChangeModule", onOpenPreferences: "openPreferences"}, {name: "moduleManager", kind: "biblez.moduleManager", onBack: "handleBack", onInstalled: "handleInstalledModule"}, {name: "bcSelector", kind: "biblez.bcSelector", onSelect: "handlePassageSelect", onBack: "handleBack"}, - {name: "moduleManagerDesktop", kind: "biblez.moduleManagerDesktop", onBack: "handleBack", onInstalled: "handleInstalledModule"} - //{name: "settings"} + {name: "moduleManagerDesktop", kind: "biblez.moduleManagerDesktop", onBack: "handleBack", onInstalled: "handleInstalledModule"}, + {name: "settings", kind: "biblez.settings", onBack: "handleBack", onChange: "handleSettings"} ]} ], @@ -56,6 +56,15 @@ enyo.kind({ return true; }, + openPreferences: function (inSender, inEvent) { + this.$.settings.setSettings(); + this.$.panel.setIndex(4); + }, + + handleSettings: function (inSender, inEvent) { + this.$.main.handleSettings(inSender, inEvent); + }, + handleChangeModule: function (inSender, inEvent) { this.$.bcSelector.setModule(inEvent.module); return true; diff --git a/source/api.js b/source/api.js index 13842b6..07f7306 100644 --- a/source/api.js +++ b/source/api.js @@ -196,4 +196,15 @@ var api = { else inCallback(inError); })); }, + + putSetting: function (inKey, inValue, inCallback) { + this.get("settings", enyo.bind(this, function (inError, inSettings) { + if(!inError) { + inSettings[inKey] = inValue; + this.put(inSettings, inCallback); + } else { + inCallback(inError); + } + })); + } };
\ No newline at end of file diff --git a/source/main.js b/source/main.js index 3f57ea3..f6b69aa 100644 --- a/source/main.js +++ b/source/main.js @@ -4,6 +4,7 @@ enyo.kind({ fit: true, events: { onOpenModuleManager: "", + onOpenPreferences: "", onModuleChanged: "", onOpenBC: "" }, @@ -22,8 +23,27 @@ enyo.kind({ {kind: "onyx.Menu", name: "moduleMenu"} ]}, {kind: "onyx.Button", name: "btnPassage", ontap: "handleBcSelector"}, - {fit: true}, - {name: "plus", kind: "onyx.IconButton", src: "assets/add.png", style:"position:absolute;right:0;", ontap: "doOpenModuleManager"}, + //{fit: true}, + {name: "actionSelector", kind: "onyx.MenuDecorator", onSelect: "actionSelected", components: [ + {kind: "onyx.IconButton", src: "assets/menu.png"}, + {kind: "onyx.Menu", name: "actionMenu", style: "width: 200px;", components: [ + {action: "moduleManager", components: [ + {kind: "onyx.IconButton", src: "assets/add.png"}, + {content: $L("Module Manager")} + ]}, + {action: "preferences", components: [ + {kind: "onyx.IconButton", src: "assets/settings.png"}, + {content: $L("Preferences")} + ]}, + {action: "bookmarks", components: [ + {kind: "onyx.IconButton", src: "assets/bookmarks.png"}, + {content: $L("Bookmarks")} + ]} + + ]} + ]}, + //{name: "btnPrefs", kind:"onyx.IconButton", src: "assets/settings.png", ontap: "handlePrefs"}, + //{name: "plus", kind: "onyx.IconButton", src: "assets/add.png", style:"position:absolute;right:0;", ontap: "doOpenModuleManager"}, {name: "bcPopup", classes: "biblez-bc-popup", kind: "onyx.Popup", modal: true, floating: true, components: [ {kind: "biblez.bcSelector", name: "bcSelector", onSelect: "passageChanged", onBack: "closePopup"} ]} @@ -78,6 +98,18 @@ enyo.kind({ this.inherited(arguments); }, + handleSettings: function (inSender, inEvent) { + api.get("settings", enyo.bind(this, function(inError, inSettings) { + if(!inError) { + this.settings = (inSettings) ? inSettings: this.settings; + if(inEvent.setting === "linebreak") + this.handlePassage(); + } else { + this.handleError("Couldn't load settings!"); + } + })); + }, + getInstalledModules: function (inSender, inEvent) { sword.moduleMgr.getModules(enyo.bind(this, function(inError, inModules) { if (!inError) { @@ -166,7 +198,7 @@ enyo.kind({ this.handleUnload(); this.$.btnPassage.setContent(this.currentPassage.label); - this.currentModule.renderText(this.currentPassage.osis, {oneVersePerLine: false}, enyo.bind(this, function (inError, inText) { + this.currentModule.renderText(this.currentPassage.osis, {oneVersePerLine: this.settings.linebreak ? this.settings.linebreak : false}, enyo.bind(this, function (inError, inText) { this.$.spinner.stop(); if(!inError) { this.$.verseScroller.scrollToTop(); @@ -251,6 +283,14 @@ enyo.kind({ return true; }, + /*Action Menu*/ + actionSelected: function (inSender, inEvent) { + if(inEvent.originator.action === "moduleManager") + this.doOpenModuleManager(); + else if(inEvent.originator.action === "preferences") + this.doOpenPreferences(); + }, + handlePanelIndex: function (inSender, inEvent) { this.panelIndex = inEvent.toIndex; }, diff --git a/source/package.js b/source/package.js index 2f89e95..4827faa 100644 --- a/source/package.js +++ b/source/package.js @@ -11,5 +11,6 @@ enyo.depends( "moduleManager.js", "moduleManagerDesktop.js", "popup.js", + "settings.js", "App.js" ); diff --git a/source/settings.js b/source/settings.js new file mode 100644 index 0000000..15086f1 --- /dev/null +++ b/source/settings.js @@ -0,0 +1,58 @@ +enyo.kind({ + name: "biblez.settings", + kind: "enyo.FittableRows", + fit: true, + events: { + onBack: "", + onChange: "" + }, + components: [ + {name: "messagePopup", kind: "onyx.Popup", scrim: true, centered: true, floating: true, classes: "message-popup"}, + {kind: "onyx.MoreToolbar", components: [ + {kind: "onyx.IconButton", src: "assets/back.png", ontap: "handleBack"}, + {content: $L("Preferences")}, + ]}, + {kind: "enyo.Scroller", touch: true, fit: true, components: [ + {classes: "settings-container", components: [ + {kind: "onyx.Groupbox", components: [ + {kind: "onyx.GroupboxHeader", content: $L("General")}, + {kind: "enyo.FittableColumns", classes: "settings-row", components: [ + {content: $L("Enable Linebreak"), classes: "settings-item", fit: true}, + {name: "tbLinebreak", kind: "onyx.ToggleButton", onChange: "toggleLinebreak"} + ]} + ]}, + ]} + + ]} + ], + + handleBack: function() { + this.doBack(); + }, + + setSettings: function () { + api.get("settings", enyo.bind(this, function(inError, inSettings) { + if(!inError) { + if(inSettings) { + this.$.tbLinebreak.value = inSettings.linebreak ? true : false; + this.$.tbLinebreak.updateVisualState(); + } + } + })); + + }, + + toggleLinebreak: function (inSender, inEvent) { + api.putSetting("linebreak", inSender.getValue(), enyo.bind(this, function (inError, inId) { + if(!inError) + this.doChange({setting: "linebreak", value: true}); + })); + }, + + handleError: function (inMessage) { + if (inMessage.message) + inMessage = inMessage.message; + this.$.messagePopup.setContent(inMessage); + this.$.messagePopup.show(); + } +});
\ No newline at end of file |