Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lordfriend committed Feb 9, 2014
0 parents commit 2591a5a
Show file tree
Hide file tree
Showing 12 changed files with 405 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
bower_components
.idea
25 changes: 25 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"jquery": true,
"globals": {
"angular": false
}
}
75 changes: 75 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use strict';

module.exports = function(grunt) {

// Load all grunt tasks automatically
require('load-grunt-tasks')(grunt);

// Time how long grunt task take. Can help when optimizing build times
require('time-grunt')(grunt);

//Configure grunt
grunt.initConfig({

// The actual grunt server settings
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
},
livereload: {
options: {
open: true,
base: [
'.',
'examples'
]
}
}
},

//Watch files for changes, and run tasks base on the changed files.
watch: {
js: {
files: ['src/*.js'],
tasks: ['newer:jshint:all'],
options: {
livereload: true
}
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'examples/*.html',
'examples/{,*/*.js}',
'examples{,*/}*.css',
'examples/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},

// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish')
},
all: [
'Gruntfile.js',
'src/*.js',
'examples/{,*/}*.js'
]

}
});

// Creates the 'serve' task
grunt.registerTask('serve', [
'connect:livereload',
'watch'
]);
};
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2014 Nyasoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# nya-bootstrap-select #
---

An AngularJS directive wrapper for silviomoreto's Bootstrap-select, which supports `ngRepeat` in options to dynamically build a Bootstrap-select

This project is not ready for publish yet. Test case is not written. So take your own risk.
14 changes: 14 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "nya-bootstrap-select",
"version": "1.0.0",
"dependencies": {
"angular": "*",
"bootstrap-select": "*",
"jquery": ">=1.7"
},
"devDependencies": {
"bootstrap-css":"~3.0",
"angular-mocks": "*",
"angular-scenario": "*"
}
}
39 changes: 39 additions & 0 deletions examples/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

angular.module('demoApp',['nyaBootstrapSelect'])
.controller('MainCtrl', function($scope){

var options = ['Alpha', 'Bravo', 'Charlie', 'Delta',
'Echo', 'Foxtrot', 'Golf', 'Hotel', 'Juliet', 'Kilo', 'Lima',
'Mike', 'November', 'Oscar', 'Papa', 'Quebec', 'Romeo', 'Sierra',
'Tango', 'Uniform', 'Victor', 'Whiskey', 'X-ray', 'Yankee', 'Zulu'
];

$scope.options1 = [
'Alpha',
'Bravo',
'Charlie'
];

$scope.myModel = ['Bravo'];

$scope.changeOptions = function(targetOption) {
var length = Math.max(Math.min(Math.floor(Math.random() * options.length), 10), 3);
var newOptions = {};
for(var i = 0; i < length; i++) {
newOptions[options[Math.floor(Math.random() * options.length)]] = true;
}
$scope[targetOption] = Object.keys(newOptions);
};

$scope.options2 = options.splice(0, 6);

$scope.changeModel = function(model) {
var length = Math.floor(Math.random() * $scope.options2.length);
var newModel = {};
for(var i = 0; i < length; i++) {
newModel[$scope.options2[Math.floor(Math.random() * $scope.options2.length)]] = true;
}
$scope[model] = Object.keys(newModel);
};
});
79 changes: 79 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>nya-bootstrap-select demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<link rel="stylesheet" href="../bower_components/bootstrap-css/css/bootstrap.css" type="text/css">
<link rel="stylesheet" href="../bower_components/bootstrap-select/bootstrap-select.css"/>
<link rel="stylesheet" href="main.css"/>
</head>
<body ng-app="demoApp">
<div class="masthead">
<div class="container">
<h1>nya-bootstrap-select</h1>
<p>An angular wrapper for Bootstrap-select with dynamic loading options support</p>
<a class="btn btn-default btn-lg" href="#">View on Github</a>
</div>
</div>
<div class="container" ng-controller="MainCtrl">
<section>
<h1 id="overview" class="page-header">Overview</h1>
<p>This is an angular directive wrapping for popular custom select <strong><a href="http://silviomoreto.github.io/bootstrap-select/">Bootstrap-select</a></strong>.
Unlike other <strong>directives</strong>. This directive support <code>ng-repeat</code> in <code>option</code>.
</p>
<p>All of the <strong><a href="http://silviomoreto.github.io/bootstrap-select/">Bootstrap-select</a></strong>'s function is supported.
The select result is bound to a model, so you don't need to use
<strong><a href="http://silviomoreto.github.io/bootstrap-select/">Bootstrap-select</a></strong>'s api to get value.
just write your select in the angular way
</p>
<p class="text-warning"><code>ngOptions</code> directive is not supported yet.</p>
</section>
<section>
<h1 id="example" class="page-header">Example</h1>
<h3>Dynamic modify options</h3>
<p>The select has three options initially. Click the <strong>Change Options</strong> button to change the options randomly.</p>

<form class="form-inline">
<p class="alert-info">The options of the select is {{options1}}</p>
<p class="alert-info">You have select {{myModel}}</p>
<button type="button" class="btn btn-primary" ng-click="changeOptions('options1')">Change Options</button>
<span>----></span>
<select id="dynamic-options" class="nya-selectpicker" ng-model="myModel" data-container="body" multiple>
<option ng-repeat="option in options1" value="{{option}}">{{option}}</option>
</select>
</form>

<h3>Dynamic modify selection</h3>
<p>The model change will affect the selection. Click the <strong>Change Model</strong> button to change the model randomly.</p>
<form class="form-inline">
<p class="alert-info">The options of the select is {{options2}}</p>
<p class="alert-info">You have select {{model2}}</p>
<button type="button" class="btn btn-primary" ng-click="changeModel('model2')">Change Model</button>
<span>----></span>
<select id="dynamic-model" class="nya-selectpicker" ng-model="model2" data-container="body" multiple>
<option ng-repeat="option in options2" value="{{option}}">{{option}}</option>
</select>
</form>

</section>
</div>
<footer class="footer">
<div class="container">
<p>Designed and built by <a href="http://nya.io">Nyasoft</p>
<p>Code licensed under MIT License</p>
</div>
</footer>


<script src="../bower_components/jquery/jquery.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/bootstrap-css/js/bootstrap.js"></script>
<script src="../bower_components/bootstrap-select/bootstrap-select.js"></script>

<script src="../src/nya-bootstrap-select.js"></script>

<script src="app.js"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions examples/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.masthead {
color: #ffffff;
padding-top: 10px;
padding-bottom: 20px;
background: #000000; /* Old browsers */
background: -moz-linear-gradient(top, #000000 0%, #45484d 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#000000), color-stop(100%,#45484d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #000000 0%,#45484d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #000000 0%,#45484d 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #000000 0%,#45484d 100%); /* IE10+ */
background: linear-gradient(to bottom, #000000 0%,#45484d 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#45484d',GradientType=0 ); /* IE6-9 */
}

.masthead h1 {
margin-top: 20px;
margin-bottom: 15px;
}

.footer {
text-align: center;
padding: 30px 0;
margin-top: 70px;
color: #ffffff;
background: #000000; /* Old browsers */
background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#000000)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #45484d 0%,#000000 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #45484d 0%,#000000 100%); /* IE10+ */
background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "nya-bootstrap-select",
"version": "1.0.0",
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-watch": "~0.5.3",
"load-grunt-tasks": "~0.3.0",
"time-grunt": "~0.2.9",
"jshint-stylish": "~0.1.5",
"grunt-newer": "~0.6.1",
"grunt-contrib-jshint": "~0.8.0",
"karma-phantomjs-launcher": "~0.1.2",
"karma": "~0.10.9"
}
}
Loading

0 comments on commit 2591a5a

Please sign in to comment.