Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyystop committed Jun 3, 2014
0 parents commit b508a55
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .gitignore
@@ -0,0 +1,14 @@
########################
# editors
########################
# WebStorm
.idea
*.iws
workspace.xml
tasks.xml

########################
# customization
########################
.ignore
bower_components
75 changes: 75 additions & 0 deletions .jshintrc
@@ -0,0 +1,75 @@
{
// Settings
//"passfail" : false, // Stop on first error. deprecated.
"maxerr" : 50, // Maximum error before stopping.


// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"couch" : false,
"dojo" : false,
"jquery" : true,
"mootools" : false,
"node" : false,
"prototypejs" : false,
"rhino" : false,
"wsh" : false,

// globals defined with apis:
// File > Setting > Libraries > jquery-2.0.0
// File > Setting > Libraries > jquery UI-1.10.2
// apis/jquery.ui.map_api.js
// apis/google_maps_api_v3_16.js
// apis/intel_api_custom.js

// Custom globals.
"predef" : [
],


// Development.
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
"devel" : true, // Allow developments statements e.g. `console.log();`.


// EcmaScript 5.
"es5" : false, // Allow EcmaScript 5 syntax.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
"strict" : false, // Require `use strict` pragma in every file.


// The Good Parts.
"asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"curly" : false, // Require {} for every new block or scope.
"eqeqeq" : true, // Require triple equals i.e. `===`.
"eqnull" : true, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"freeze" : true, // Prohibits the modification of native objects such as Array, Number, Date, etc.
"immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef" : false, // Prohibit variable use before definition.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"loopfunc" : false, // Allow functions to be defined within loops.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"regexdash" : true, // Tolerate unescaped last dash i.e. `[-...]`.
"regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
"scripturl" : false, // Tolerate script-targeted URLs.
"shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : false, // Require all non-global variables be declared before they are used.


// Personal styling prefrences.
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohipit use of empty blocks.
//"nomen" : false, // Prohibit use of initial or trailing underbars in names. deprecated.
"nonew" : true, // Prohibit use of constructors for side-effects.
//"onevar" : false, // Allow only one `var` statement per function. deprecated.
"plusplus" : true, // Prohibit use of `++` & `--`.
"sub" : false // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
//"trailing" : true, // Prohibit trailing whitespaces. deprecated.
//"white" : false // Check against strict whitespace and indentation rules. deprecated.
}
10 changes: 10 additions & 0 deletions LICENSE.md
@@ -0,0 +1,10 @@
The MIT License (MIT)
--

Copyright © 2014 John Szwaronek (<johnsz9999@gmail.com>)

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.
147 changes: 147 additions & 0 deletions README.md
@@ -0,0 +1,147 @@
# [mithril-components] (https://github.com/eddyystop/mithril-components)

Components, patterns and sample code for lhorie/mithril.js
[mithril] (https://github.com/lhorie/mithril.js).

A new-born work in progress.

## How to install
```sh
bower install mithril-components
or
bower install git://github.com/eddyystop/mithril-components
```

## UI Components
- [Table - responsive] (#table-responsive) - A responsive table.


## Docs

### <a name="UI"></UI Components


***


### <a name="table-responsive"></a>Responsive table

#### 1. Load external CSS files
```
<style>
table th{
font-weight:bold;
}
table td,
table th {
padding: 9px 10px;
text-align: left;
}
table.responsive {
margin-bottom:0;
}
.pinned {
position: absolute;
left: 0;
top: 0;
background: #fff;
width: 35%;
overflow: hidden;
overflow-x: scroll;
border-right: 1px solid #ccc;
border-left: 1px solid #ccc;
}
.pinned table {
border-right: none;
border-left: none;
width: 100%;
}
.pinned table th,
.pinned table td {
white-space: nowrap;
}
.pinned td:last-child {
border-bottom: 0;
}
div.mc-TableResponsive {
position: relative;
margin-bottom: 20px;
overflow: hidden;
border-right: 1px solid #ccc;
}
div.mc-TableResponsive div.scrollable table {
margin-left:35%;
}
div.mc-TableResponsive div.scrollable {
overflow: scroll;
overflow-y: hidden;
}
table.responsive td,
table.responsive th {
position: relative;
white-space: nowrap;
overflow: hidden;
}
</style>
```

```js
$(window).on('resize', function () {
m.startComputation();
m.endComputation();
});

var app = {
controller: function () {
var table = _getTableData(4, 8);

this.tableScrollable1 = new mc.TableResponsive.controller(table);

this.tableScrollable2 = new mc.TableResponsive.controller(table, {
isPlain: function () { return $(window).width() >= 767; }
});

function _getTableData (rows, cols) {
var table = [],
row = [];

for (var j = 1; j <= cols; j += 1) {
row.push('Header ' + j + (j === 1 ? ' aaaaaaaaaa' : ''));
}
table.push(row);

for (var i = 1; i <= rows; i += 1) {
row = [];
for (j = 1; j <= cols; j += 1) {
row.push('row ' + i + ', cell ' + j + (j === 1 ? ' aaaaaaaaaa' : ''));
}
table.push(row);
}

return table;
}
},

view: function (ctrl) {
return m('div', [
mc.TableResponsive.view(ctrl.tableScrollable1),
mc.TableResponsive.view(ctrl.tableScrollable2)
]);
}
};
```
Start downloading in parallel any CSS files not already downloaded.
We do not wait for the downloads to complete.

```js
PJAX.requireCss([
'/concat/production.css',
'/css/vendor/pjax-responsive-tables.css'
], handler );
```


## License
Copyright (c) 2014 John Szwaronek (<johnsz9999@gmail.com>).
Distributed under the MIT license. See LICENSE.md for details.

0 comments on commit b508a55

Please sign in to comment.