Skip to content

Commit

Permalink
updated build file and added LICENSE
Browse files Browse the repository at this point in the history
  • Loading branch information
codehugger committed Dec 19, 2012
1 parent 44e1262 commit bb93411
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 47 deletions.
28 changes: 28 additions & 0 deletions LICENSE
@@ -0,0 +1,28 @@
/**
* Copyright (c) Bjarki Gudlaugsson (codehugger at codehuggers.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* * Neither the name of the <ORGANIZATION> nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
10 changes: 7 additions & 3 deletions README.md
Expand Up @@ -15,6 +15,10 @@ $(element).categorypicker({
});
```

## Live Example

There is a live example available on [jsFiddle]()

## Options

**selectedCategories:** a collection of pre-selected categories. (default: [])
Expand All @@ -32,19 +36,19 @@ $(element).categorypicker({
**onUpdate:** a callback used when the selection changes (default: undefined)

**rootTemplate:** the template surrounding the categorypicker. Default:

```html
<div class="categorypicker"></div>
```

**listTemplate:** the template for the list. Default:

```html
<ul class="list"></ul>
```

**itemTemplate:** the template for the items in the list. Default:

```html
<li class="item"></li>
```
Expand Down
50 changes: 36 additions & 14 deletions build.js
@@ -1,28 +1,50 @@
var compressor = require('node-minify');
var fs = require('fs');

fs.exists('./build', function (exists) {
if (!exists) {
fs.mkdirSync('./build');
}
});

/*
* jquery-categorypicker.min.js
*/
new compressor.minify({
type: 'yui-js',
fileIn: ['./jquery-categorypicker.js'],
fileOut: './build/categorypicker.min.js',
callback: function(err){
fileIn: './src/jquery-categorypicker.js',
fileOut: './jquery-categorypicker.min.js',
callback: function(err) {
if (err) { console.log(err); }
else { console.log(this.fileOut); }
else {
// include LICENSE
new compressor.minify({
type: 'no-compress',
fileIn: [
'LICENSE',
'./jquery-categorypicker.min.js'],
fileOut: './jquery-categorypicker.min.js',
callback: function(err) {
console.log(this.fileOut);
}
});
}
}
});

/*
* jquery-categorypicker-ko.min.js
*/
new compressor.minify({
type: 'yui-js',
fileIn: ['./jquery-categorypicker.js', './jquery-categorypicker-ko.js'],
fileOut: './build/categorypicker-ko.min.js',
callback: function(err){
fileIn: './src/jquery-categorypicker-ko.js',
fileOut: './jquery-categorypicker-ko.min.js',
callback: function(err) {
if (err) { console.log(err); }
else { console.log(this.fileOut); }
else {
// include LICENSE
new compressor.minify({
type: 'no-compress',
fileIn: ['LICENSE', './jquery-categorypicker-ko.min.js'],
fileOut: './jquery-categorypicker-ko.min.js',
callback: function(err) {
console.log(this.fileOut);
}
});
}
}
});
4 changes: 2 additions & 2 deletions index-ko.html
Expand Up @@ -4,8 +4,8 @@
<title>jquery-categorypicker</title>
<script src="./vendor/jquery.min.js"></script>
<script src="./vendor/ko.min.js"></script>
<script src="./jquery-categorypicker.js"></script>
<script src="./jquery-categorypicker-ko.js"></script>
<script src="./src/jquery-categorypicker.js"></script>
<script src="./src/jquery-categorypicker-ko.js"></script>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -3,7 +3,7 @@
<head>
<title>jquery-categorypicker</title>
<script src="./vendor/jquery.min.js"></script>
<script src="./jquery-categorypicker.js"></script>
<script src="./src/jquery-categorypicker.js"></script>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body>
Expand Down
30 changes: 30 additions & 0 deletions jquery-categorypicker-ko.min.js
@@ -0,0 +1,30 @@
/**
* Copyright (c) Bjarki Gudlaugsson (codehugger at codehuggers.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* * Neither the name of the <ORGANIZATION> nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

ko.bindingHandlers.categorypicker={update:function(e,h,c){var j=h(),f=c();var d=ko.utils.unwrapObservable(j);var b=ko.utils.unwrapObservable(f.availableCategories);var a=ko.utils.unwrapObservable(f.idField);var i=ko.utils.unwrapObservable(f.sortField);var k=ko.utils.unwrapObservable(f.valueField);var g=ko.utils.unwrapObservable(f.displayField);$(e).categorypicker({selectedCategories:d,availableCategories:b,idField:a,sortField:i,valueField:k,displayField:g,onUpdate:function(l){j(l)}})}};
30 changes: 30 additions & 0 deletions jquery-categorypicker.min.js
@@ -0,0 +1,30 @@
/**
* Copyright (c) Bjarki Gudlaugsson (codehugger at codehuggers.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* * Neither the name of the <ORGANIZATION> nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

(function(a){a.fn.categorypicker=function(i,b){var m=this;var h,f;var g;function j(p){var q=p.target.id;var o=p.target.checked;var n=[];a.each(f,function(r,s){if(q!==s[idField]){n.push(s)}});if(o){a.each(h,function(r,s){if(q===s[idField]){n.push(s)}})}f=n;f.sort(function(s,r){return s[sortField]>r[sortField]});e()}function e(){if(onUpdate){onUpdate(f)}}function d(o){var n=a(itemTemplate);var p=a('<input type="checkbox">');p.attr("id",o[idField]);p.attr("value",o[valueField]);a.each(f,function(q,r){if(r[idField]===o[idField]){p.attr("checked",true)}});p.on("click",j);n.html(p);n.append(o[displayField]);return n}function k(){var n=a(listTemplate);a.each(h,function(o,p){n.append(d(p))});return n}function c(){var n=a(g);n.append(k());m.html(n)}function l(n){if(n===undefined){n={}}h=n.availableCategories||[];f=n.selectedCategories||[];idField=n.idField||"id";sortField=n.sortField||idField;valueField=n.valueField||"value";displayField=n.displayField||"value";onUpdate=n.onUpdate;g=n.rootTemplate||'<div class="categorypicker"></div>';listTemplate=n.listTemplate||'<ul class="list"></ul>';itemTemplate=n.itemTemplate||'<li class="item"></li>';c();e();return m}return l(i,b)}})(jQuery);
File renamed without changes.
27 changes: 0 additions & 27 deletions jquery-categorypicker.js → src/jquery-categorypicker.js
@@ -1,31 +1,4 @@
(function ($) {
/*
jquery-categorypicker
Copyright (c) 2012, Bjarki Gudlaugsson (codehugger) <codehugger@codehuggers.com>
All rights reserved.
This code is distributed under the terms of the BSD licence
Redistribution and use of this software in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.
* The names of the contributors to this file may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

$.fn.categorypicker = function (categories, opts) {
var self = this;
Expand Down

0 comments on commit bb93411

Please sign in to comment.