Skip to content

Commit

Permalink
Fine tuned and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Kohlhepp committed Apr 19, 2011
1 parent 0d3fc14 commit ed3171d
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 270 deletions.
86 changes: 5 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,12 @@
# [fancy settings](https://github.com/frankkohlhepp/fancy-settings)
*Create fancy, chrome-look-alike settings for your Chrome or Safari extension in minutes!*

### About
### Getting started
Welcome to fancy settings! Are you ready for tabs, groups, search, good style?
Let's get started, it takes only a few minutes...

### Howto
Download fancy settings, unzip the download and your good to go!

You can open the index.html file as-is and take a look what the result will look like.
Now, let's get your own settings in there...

There are three files that are interesting for you:

* manifest.js
* icon.png
* settings.js

If you just want to get some settings without any customization, you can just edit the manifest.json file and change the icon.
The manifest.json file includes samples of all available settings, so you can see how it works and edit it to fit your needs.

But if you want to customize, you have two options:

1. You can use the manifest to generate your settings and customize it in the settings.js file.
2. Or you can programmatically create your settings in the settings.js file and customize it right away.

To see how you can access the generated settings from the manifest, take a look at the settings.js file.

#### Create your settings programmatically
To create settings programmatically, you need a hashtable, specifying some parameters, called "params".

{
"name": "button1",
"type": "button",
"label": "Describe the action:",
"text": "Go"
}

It's similar to the part of the manifest were you specify a setting (shown above), but with two differences:

* The type is *never* included
* The name is not *always* included

The name is used by the setting creator to save what the user chose, so it's not needed for the types "description", and "button".
But the manifest generator uses the name also to save the generated setting, so you can access it later on.

Here's how you can create a setting:

var settings = new FancySettings("My Extension");

settings.create("tabName", "groupName", "type", {
// params
});

If you save the created setting in a variable, you can call the methods get() and set() on it, and add event listeners:

var settings = new FancySettings("My Extension");

var checkbox = settings.create("tabName", "groupName", "checkbox", {
"name": "checkbox1",
"label": "Enable this"
});

checkbox.get();
=> false

checkbox.set(true).get();
=> true

checkbox.addEvent("action", function (value) {
console.log("new value is ", value);
});














[Getting started](https://github.com/frankkohlhepp/fancy-settings/wiki)

### License
fancy settings is licensed under the **LGPL 2.1**.
For details see *LICENSE.txt*
4 changes: 2 additions & 2 deletions source/css/setting.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
margin-bottom: 10px;
}

.setting.label {
.setting.label, .setting.element-label {
margin-right: 5px;
font-size: 13px;
font-weight: normal;
}

.setting.label.checkbox, .setting.element.label.radio-buttons {
.setting.label.checkbox, .setting.element-label {
margin-left: 5px;
}

Expand Down
5 changes: 4 additions & 1 deletion source/js/classes/fancy-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@

// Create the setting
var bundle = group.setting.create(type, params);
bundle.searchString = bundle.searchString + " " + tabName.toLowerCase() + " " + groupName.toLowerCase();

// Index the setting
bundle.searchString = (bundle.searchString + "•" + tabName + "•" + groupName).toLowerCase();
this.search.add(bundle);

return bundle;
}
});
Expand Down
6 changes: 4 additions & 2 deletions source/js/classes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

"find": function (string) {
this.index.each((function (setting) {
setting.bundle.inject(setting.container);
setting.bundle.inject(setting.bundleContainer);
}).bind(this));

if (string.trim() === "") {
Expand All @@ -46,7 +46,9 @@
document.body.addClass("searching");
var results = this.index.filter(function (setting) {
if (setting.searchString.contains(string.trim().toLowerCase())) {
return true;
if (setting.type !== "description") {
return true;
}
}
});

Expand Down
Loading

0 comments on commit ed3171d

Please sign in to comment.