开发者社区> 镜像站> NPM> derby-header
derby-header
Derby layout with persistent header
Last updated 3 years ago by fctsvirus .
MIT · Original npm · Tarball · package.json
$ cnpm install derby-header 
SYNC missed versions from official npm registry.

Derby-Header

Derby layout with persistent header

Usage

In your derby-app:

var derby = require('derby');

// Just require the package
require('derby-header');

var app = derby.createApp('twopages', __filename);

So, you have the layout:

<html>
  <head>
     <!-- ....... -->
  </head>
  <body>
    <div id=header>
      <view is="Header"/>
    </div>
    <div id=body>
      <view is="Body"/>
    </div>
  </body>
</html>

All html in the #header-element is persistent and doesn't erase when app-routes are changing. You also can use components inside the #header.

The package is created for client rendering. So, if you want to subscribe to some data for your header use component "create"-function. For example:

in my index.html:

<!-- classic body layout-->
<Body:>
  <view is="{{$render.ns}}"/>
  
<Header:>
  <view is="header"/>
 

"header"-component example:

module.exports = Header;

function Header(){}

Header.prototype.view = __dirname;
Header.prototype.style = __dirname;
Header.prototype.name = header;

Header.prototype.init = function(model){
}

Header.prototype.create = function(model){
  // Create a childModel with 'global' context
  // if we use regular root-model the subscription
  // is unsubscribed after url is changed
  
  this.globalModel = model.root.context('global');

  var items = this.globalModel.query('items', {});

  items.subscribe(function(err){
    items.ref(model.path('items'));
    model.set('loaded', true);
  });
}

Header.prototype.destroy = function(){
  this.globalModel.unload();
}

index.html

<index:>
  {{if loaded}}
    <!-- ... -->
  {{/}}

The MIT License

Copyright (c) 2015 Artur Zayats

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.

Current Tags

  • 6.0.3                                ...           latest (3 years ago)

23 Versions

  • 6.0.3                                ...           3 years ago
  • 6.0.2                                ...           3 years ago
  • 6.0.1                                ...           3 years ago
  • 6.0.0                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.5.1                                ...           3 years ago
  • 4.5.0                                ...           4 years ago
  • 4.4.0                                ...           4 years ago
  • 4.3.1                                ...           4 years ago
  • 4.3.0                                ...           4 years ago
  • 4.2.3                                ...           4 years ago
  • 4.2.2                                ...           4 years ago
  • 4.2.1                                ...           4 years ago
  • 4.2.0                                ...           4 years ago
  • 4.1.0                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.0.1                                ...           4 years ago
  • 2.1.0                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.0                                ...           6 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (0)
None