[MERGE]Merge trunk-website-al.
bzr revid: bth@tinyerp.com-20131021065706-1j7ms6rgkcnlxzms
This commit is contained in:
commit
9bd0b9a9f4
|
@ -163,10 +163,10 @@
|
|||
|
||||
<record model="ir.attachment">
|
||||
<field name="name">vegetables</field>
|
||||
<field name="datas_fname">vegetables.jpg</field>
|
||||
<field name="datas_fname">vegetables.png</field>
|
||||
<field name="res_model">ir.ui.view</field>
|
||||
<field name="type">url</field>
|
||||
<field name="url">/website/static/src/img/library/vegetables.jpg</field>
|
||||
<field name="url">/website/static/src/img/library/vegetables.png</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.attachment">
|
||||
|
|
|
@ -14,6 +14,7 @@ import traceback
|
|||
from openerp.tools.safe_eval import safe_eval
|
||||
from openerp.exceptions import AccessError, AccessDenied
|
||||
import werkzeug
|
||||
from openerp.addons.base.ir.ir_qweb import QWebException
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -197,6 +198,16 @@ class website(osv.osv):
|
|||
qweb_context['error'] = err[1]
|
||||
logger.warn("Website Rendering Error.\n\n%s" % traceback.format_exc())
|
||||
return self.render(cr, uid, ids, 'website.401', qweb_context)
|
||||
except (QWebException,), err:
|
||||
qweb_context['traceback'] = traceback.format_exc()
|
||||
qweb_context['template'] = err.template
|
||||
qweb_context['message'] = err.message
|
||||
qweb_context['node'] = err.node and err.node.toxml()
|
||||
logger.error("Website Rendering Error.\n%(message)s\n%(node)s\n\n%(traceback)s" % qweb_context)
|
||||
return view.render(
|
||||
cr, uid,
|
||||
'website.500' if qweb_context['editable'] else 'website.404',
|
||||
qweb_context, context=context)
|
||||
except Exception:
|
||||
logger.exception("Website Rendering Error.")
|
||||
qweb_context['traceback'] = traceback.format_exc()
|
||||
|
@ -393,3 +404,13 @@ class base_language_install(osv.osv):
|
|||
'target': 'self'
|
||||
}
|
||||
return action
|
||||
|
||||
class SeoMetadata(osv.Model):
|
||||
_name = 'website.seo.metadata'
|
||||
_description = 'SEO metadata'
|
||||
|
||||
_columns = {
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2013 Mark Dalgleish
|
||||
|
||||
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.
|
|
@ -0,0 +1,308 @@
|
|||
[![Build Status](https://secure.travis-ci.org/markdalgleish/stellar.js.png)](http://travis-ci.org/markdalgleish/stellar.js)
|
||||
|
||||
# Stellar.js
|
||||
|
||||
### Parallax scrolling made easy
|
||||
|
||||
Full guide and demonstrations available at the [official Stellar.js project page](http://markdalgleish.com/projects/stellar.js/).
|
||||
|
||||
## Download
|
||||
|
||||
Get the [development](https://raw.github.com/markdalgleish/stellar.js/master/jquery.stellar.js) or [production](https://raw.github.com/markdalgleish/stellar.js/master/jquery.stellar.min.js) version, or use a [package manager](https://github.com/markdalgleish/stellar.js#package-managers).
|
||||
|
||||
## Getting Started
|
||||
|
||||
Stellar.js is a jQuery plugin that provides parallax scrolling effects to any scrolling element. The first step is to run `.stellar()` against the element:
|
||||
|
||||
``` js
|
||||
// For example:
|
||||
$(window).stellar();
|
||||
// or:
|
||||
$('#main').stellar();
|
||||
```
|
||||
|
||||
If you're running Stellar.js on 'window', you can use the shorthand:
|
||||
|
||||
``` js
|
||||
$.stellar();
|
||||
```
|
||||
|
||||
This will look for any parallax backgrounds or elements within the specified element and reposition them when the element scrolls.
|
||||
|
||||
## Mobile Support
|
||||
|
||||
Support in Mobile WebKit browsers requires a touch scrolling library, and a slightly tweaked configuration. For a full walkthrough on how to implement this correctly, read my blog post ["Mobile Parallax with Stellar.js"](http://markdalgleish.com/2012/10/mobile-parallax-with-stellar-js).
|
||||
|
||||
Please note that parallax backgrounds are not recommended in Mobile WebKit due to performance constraints. Instead, use parallax elements with static backgrounds.
|
||||
|
||||
## Parallax Elements
|
||||
|
||||
If you want elements to scroll at a different speed, add the following attribute to any element with a CSS position of absolute, relative or fixed:
|
||||
|
||||
``` html
|
||||
<div data-stellar-ratio="2">
|
||||
```
|
||||
|
||||
The ratio is relative to the natural scroll speed, so a ratio of 0.5 would cause the element to scroll at half-speed, a ratio of 1 would have no effect, and a ratio of 2 would cause the element to scroll at twice the speed. If a ratio lower than 1 is causing the element to appear jittery, try setting its CSS position to fixed.
|
||||
|
||||
In order for Stellar.js to perform its calculations correctly, all parallax elements must have their dimensions specified in pixels for the axis/axes being used for parallax effects. For example, all parallax elements for a vertical site must have a pixel height specified. If your design prohibits the use of pixels, try using the ['responsive' option](#configuring-everything).
|
||||
|
||||
## Parallax Backgrounds
|
||||
|
||||
If you want an element's background image to reposition on scroll, simply add the following attribute:
|
||||
|
||||
``` html
|
||||
<div data-stellar-background-ratio="0.5">
|
||||
```
|
||||
|
||||
As with parallax elements, the ratio is relative to the natural scroll speed. For ratios lower than 1, to avoid jittery scroll performance, set the element's CSS 'background-attachment' to fixed.
|
||||
|
||||
## Configuring Offsets
|
||||
|
||||
Stellar.js' most powerful feature is the way it aligns elements.
|
||||
|
||||
All elements will return to their original positioning when their offset parent meets the edge of the screen—plus or minus your own optional offset. This allows you to create intricate parallax patterns very easily.
|
||||
|
||||
Confused? [See how offsets are used on the Stellar.js home page.](http://markdalgleish.com/projects/stellar.js/#show-offsets)
|
||||
|
||||
To modify the offsets for all elements at once, pass in the options:
|
||||
|
||||
``` js
|
||||
$.stellar({
|
||||
horizontalOffset: 40,
|
||||
verticalOffset: 150
|
||||
});
|
||||
```
|
||||
|
||||
You can also modify the offsets on a per-element basis using the following data attributes:
|
||||
|
||||
``` html
|
||||
<div data-stellar-ratio="2"
|
||||
data-stellar-horizontal-offset="40"
|
||||
data-stellar-vertical-offset="150">
|
||||
```
|
||||
|
||||
## Configuring Offset Parents
|
||||
|
||||
By default, offsets are relative to the element's offset parent. This mirrors the way an absolutely positioned element behaves when nested inside an element with a relative position.
|
||||
|
||||
As with regular CSS, the closest parent element with a position of relative or absolute is the offset parent.
|
||||
|
||||
To override this and force the offset parent to be another element higher up the DOM, use the following data attribute:
|
||||
|
||||
``` html
|
||||
<div data-stellar-offset-parent="true">
|
||||
```
|
||||
|
||||
The offset parent can also have its own offsets:
|
||||
|
||||
``` html
|
||||
<div data-stellar-offset-parent="true"
|
||||
data-stellar-horizontal-offset="40"
|
||||
data-stellar-vertical-offset="150">
|
||||
```
|
||||
|
||||
Similar to CSS, the rules take precedence from element, to offset parent, to JavaScript options.
|
||||
|
||||
Confused? [See how offset parents are used on the Stellar.js home page.](http://markdalgleish.com/projects/stellar.js/#show-offset-parents)
|
||||
|
||||
Still confused? [See what it looks like with its default offset parents.](http://markdalgleish.com/projects/stellar.js/#show-offset-parents-default) Notice how the alignment happens on a per-letter basis? That's because each letter's containing div is its default offset parent.
|
||||
|
||||
By specifying the h2 element as the offset parent, we can ensure that the alignment of all the stars in a heading is based on the h2 and not the div further down the DOM tree.
|
||||
|
||||
## Configuring Scroll Positioning
|
||||
|
||||
You can define what it means for an element to 'scroll'. Whether it's the element's scroll position that's changing, its margins or its CSS3 'transform' position, you can define it using the 'scrollProperty' option:
|
||||
|
||||
``` js
|
||||
$('#gallery').stellar({
|
||||
scrollProperty: 'transform'
|
||||
});
|
||||
```
|
||||
|
||||
This option is what allows you to run [Stellar.js on iOS](http://markdalgleish.com/projects/stellar.js/demos/ios.html).
|
||||
|
||||
You can even define how the elements are repositioned, whether it's through standard top and left properties or using CSS3 transforms:
|
||||
|
||||
``` js
|
||||
$('#gallery').stellar({
|
||||
positionProperty: 'transform'
|
||||
});
|
||||
```
|
||||
|
||||
Don't have the level of control you need? Write a plugin!
|
||||
|
||||
Otherwise, you're ready to get started!
|
||||
|
||||
## Configuring Everything
|
||||
|
||||
Below you will find a complete list of options and matching default values:
|
||||
|
||||
``` js
|
||||
$.stellar({
|
||||
// Set scrolling to be in either one or both directions
|
||||
horizontalScrolling: true,
|
||||
verticalScrolling: true,
|
||||
|
||||
// Set the global alignment offsets
|
||||
horizontalOffset: 0,
|
||||
verticalOffset: 0,
|
||||
|
||||
// Refreshes parallax content on window load and resize
|
||||
responsive: false,
|
||||
|
||||
// Select which property is used to calculate scroll.
|
||||
// Choose 'scroll', 'position', 'margin' or 'transform',
|
||||
// or write your own 'scrollProperty' plugin.
|
||||
scrollProperty: 'scroll',
|
||||
|
||||
// Select which property is used to position elements.
|
||||
// Choose between 'position' or 'transform',
|
||||
// or write your own 'positionProperty' plugin.
|
||||
positionProperty: 'position',
|
||||
|
||||
// Enable or disable the two types of parallax
|
||||
parallaxBackgrounds: true,
|
||||
parallaxElements: true,
|
||||
|
||||
// Hide parallax elements that move outside the viewport
|
||||
hideDistantElements: true,
|
||||
|
||||
// Customise how elements are shown and hidden
|
||||
hideElement: function($elem) { $elem.hide(); },
|
||||
showElement: function($elem) { $elem.show(); }
|
||||
});
|
||||
```
|
||||
|
||||
## Writing a Scroll Property Plugin
|
||||
|
||||
Out of the box, Stellar.js supports the following scroll properties:
|
||||
'scroll', 'position', 'margin' and 'transform'.
|
||||
|
||||
If your method for creating a scrolling interface isn't covered by one of these, you can write your own. For example, if 'margin' didn't exist yet you could write it like so:
|
||||
|
||||
``` js
|
||||
$.stellar.scrollProperty.margin = {
|
||||
getLeft: function($element) {
|
||||
return parseInt($element.css('margin-left'), 10) * -1;
|
||||
},
|
||||
getTop: function($element) {
|
||||
return parseInt($element.css('margin-top'), 10) * -1;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now, you can specify this scroll property in Stellar.js' configuration.
|
||||
|
||||
``` js
|
||||
$.stellar({
|
||||
scrollProperty: 'margin'
|
||||
});
|
||||
```
|
||||
|
||||
## Writing a Position Property Plugin
|
||||
|
||||
Stellar.js has two methods for positioning elements built in: 'position' for modifying its top and left properties, and 'transform' for using CSS3 transforms.
|
||||
|
||||
If you need more control over how elements are positioned, you can write your own setter functions. For example, if 'position' didn't exist yet, it could be written as a plugin like this:
|
||||
|
||||
``` js
|
||||
$.stellar.positionProperty.position = {
|
||||
setTop: function($element, newTop, originalTop) {
|
||||
$element.css('top', newTop);
|
||||
},
|
||||
setLeft: function($element, newLeft, originalLeft) {
|
||||
$element.css('left', newLeft);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now, you can specify this position property in Stellar.js' configuration.
|
||||
|
||||
``` js
|
||||
$.stellar({
|
||||
positionProperty: 'position'
|
||||
});
|
||||
```
|
||||
|
||||
If, for technical reasons, you need to set both properties at once, you can define a single 'setPosition' function:
|
||||
|
||||
``` js
|
||||
$.stellar.positionProperty.foobar = {
|
||||
setPosition: function($element, newLeft, originalLeft, newTop, originalTop) {
|
||||
$element.css('transform', 'translate3d(' +
|
||||
(newLeft - originalLeft) + 'px, ' +
|
||||
(newTop - originalTop) + 'px, ' +
|
||||
'0)');
|
||||
}
|
||||
}
|
||||
|
||||
$.stellar({
|
||||
positionProperty: 'foobar'
|
||||
});
|
||||
```
|
||||
|
||||
## Package Managers
|
||||
|
||||
Stellar.js can be installed with [Bower](http://twitter.github.com/bower/):
|
||||
|
||||
``` bash
|
||||
$ bower install jquery.stellar
|
||||
```
|
||||
|
||||
## Sites Using Stellar.js
|
||||
|
||||
* [National Geographic - Alien Deep Interactive](http://channel.nationalgeographic.com/channel/alien-deep/interactives/alien-deep-interactive)
|
||||
* [François Hollande](http://www.parti-socialiste.fr/latimelineduchangement)
|
||||
* [Brabus Private Aviation](http://www.brabus-aviation.com/)
|
||||
* [Mary and Frankie's Wedding](http://www.maryandfrankiewedding.com/)
|
||||
* [IT Support London](http://www.itsupportlondon.com)
|
||||
* [Ashford University](http://bright.ashford.edu)
|
||||
* [Clif Adventures](http://www.clifbar.com/adventures)
|
||||
* [Mindster](http://www.mindster.org)
|
||||
* [WS Interactive](http://www.ws-interactive.fr/methode)
|
||||
* [Moire Mag - Untitled](http://www.moiremag.net/untitled)
|
||||
* [Carnival of Courage](http://www.carnivalofcourage.com.au)
|
||||
* [Ian Poulter](http://www.ianpoulter.com)
|
||||
* [360 Strategy Group](http://360strategygroup.com)
|
||||
* [Code, Love and Boards](http://codeloveandboards.com/)
|
||||
|
||||
I'm sure there are heaps more. [Let me know if you'd like me to feature your site here.](http://twitter.com/markdalgleish)
|
||||
|
||||
## How to Build
|
||||
|
||||
Stellar.js uses [Node.js](nodejs.org), [Grunt](http://gruntjs.com) and [PhantomJS](http://phantomjs.org/).
|
||||
|
||||
Once you've got Node and PhantomJS set up, install the dependencies:
|
||||
|
||||
`$ npm install`
|
||||
|
||||
To lint, test and minify the project, simply run the following command:
|
||||
|
||||
`$ grunt`
|
||||
|
||||
Each of the build steps are also available individually.
|
||||
|
||||
`$ grunt test` to test the code using QUnit and PhantomJS:
|
||||
|
||||
`$ grunt lint` to validate the code using JSHint.
|
||||
|
||||
`$ grunt watch` to continuously lint and test the code while developing.
|
||||
|
||||
## Contributing to Stellar.js
|
||||
|
||||
Ensure that you successfully test and build the project with `$ grunt` before committing.
|
||||
|
||||
Make sure that all plugin changes are made in `src/jquery.stellar.js` (`/jquery.stellar.js` and `/jquery.stellar.min.js` are generated by Grunt).
|
||||
|
||||
If you want to contribute in a way that changes the API, please file an issue before submitting a pull request so we can discuss how to appropriately integrate your ideas.
|
||||
|
||||
## Questions?
|
||||
|
||||
Contact me on GitHub or Twitter: [@markdalgleish](http://twitter.com/markdalgleish)
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2013, Mark Dalgleish
|
||||
This content is released under the MIT license
|
||||
http://markdalgleish.mit-license.org
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "jquery.stellar",
|
||||
"version": "0.6.2",
|
||||
"main": ["./jquery.stellar.js"],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.4.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*global module:false*/
|
||||
module.exports = function(grunt) {
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
pkg: '<json:package.json>',
|
||||
meta: {
|
||||
banner: '/*!\n' +
|
||||
' * <%= pkg.title || pkg.name %> v<%= pkg.version %>\n' +
|
||||
' * <%= pkg.homepage %>\n' +
|
||||
' * \n' +
|
||||
' * Copyright <%= grunt.template.today("yyyy") %>, <%= pkg.author.name %>\n' +
|
||||
' * This content is released under the <%= _.pluck(pkg.licenses, "type").join(", ") %> license<%= pkg.licenses.length === 1 ? "" : "s" %>\n' +
|
||||
' * <%= _.pluck(pkg.licenses, "url").join(", ") %>\n' +
|
||||
' */',
|
||||
microbanner: '/*! <%= pkg.title || pkg.name %> v<%= pkg.version %> | Copyright <%= grunt.template.today("yyyy") %>, <%= pkg.author.name %> | <%= pkg.homepage %> | <%= _.pluck(pkg.licenses, "url").join(", ") %> */'
|
||||
},
|
||||
lint: {
|
||||
files: ['grunt.js', 'test/**/*.js', 'src/**/*.js']
|
||||
},
|
||||
server: {
|
||||
port: 8573
|
||||
},
|
||||
qunit: {
|
||||
urls: ['1.4.3', '1.10.1', '2.0.2'].map(function(version) {
|
||||
return 'http://localhost:<%= server.port %>/test/jquery.stellar.html?jquery=' + version;
|
||||
})
|
||||
},
|
||||
concat: {
|
||||
dist: {
|
||||
src: ['<banner:meta.banner>', '<file_strip_banner:src/<%= pkg.name %>.js>'],
|
||||
dest: '<%= pkg.name %>.js'
|
||||
}
|
||||
},
|
||||
min: {
|
||||
dist: {
|
||||
src: ['<banner:meta.microbanner>', '<config:concat.dist.dest>'],
|
||||
dest: '<%= pkg.name %>.min.js'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: '<config:lint.files>',
|
||||
tasks: 'server lint qunit'
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
evil: true,
|
||||
curly: false,
|
||||
eqeqeq: true,
|
||||
immed: true,
|
||||
latedef: true,
|
||||
newcap: true,
|
||||
noarg: true,
|
||||
sub: true,
|
||||
undef: true,
|
||||
boss: true,
|
||||
browser: true
|
||||
},
|
||||
globals: {
|
||||
jQuery: true
|
||||
}
|
||||
},
|
||||
uglify: {}
|
||||
});
|
||||
|
||||
// Default task.
|
||||
grunt.registerTask('default', 'server lint qunit concat min');
|
||||
|
||||
grunt.registerTask('test', 'server lint qunit');
|
||||
|
||||
};
|
|
@ -0,0 +1,660 @@
|
|||
/*!
|
||||
* Stellar.js v0.6.2
|
||||
* http://markdalgleish.com/projects/stellar.js
|
||||
*
|
||||
* Copyright 2013, Mark Dalgleish
|
||||
* This content is released under the MIT license
|
||||
* http://markdalgleish.mit-license.org
|
||||
*/
|
||||
|
||||
;(function($, window, document, undefined) {
|
||||
|
||||
var pluginName = 'stellar',
|
||||
defaults = {
|
||||
scrollProperty: 'scroll',
|
||||
positionProperty: 'position',
|
||||
horizontalScrolling: true,
|
||||
verticalScrolling: true,
|
||||
horizontalOffset: 0,
|
||||
verticalOffset: 0,
|
||||
responsive: false,
|
||||
parallaxBackgrounds: true,
|
||||
parallaxElements: true,
|
||||
hideDistantElements: true,
|
||||
hideElement: function($elem) { $elem.hide(); },
|
||||
showElement: function($elem) { $elem.show(); }
|
||||
},
|
||||
|
||||
scrollProperty = {
|
||||
scroll: {
|
||||
getLeft: function($elem) { return $elem.scrollLeft(); },
|
||||
setLeft: function($elem, val) { $elem.scrollLeft(val); },
|
||||
|
||||
getTop: function($elem) { return $elem.scrollTop(); },
|
||||
setTop: function($elem, val) { $elem.scrollTop(val); }
|
||||
},
|
||||
position: {
|
||||
getLeft: function($elem) { return parseInt($elem.css('left'), 10) * -1; },
|
||||
getTop: function($elem) { return parseInt($elem.css('top'), 10) * -1; }
|
||||
},
|
||||
margin: {
|
||||
getLeft: function($elem) { return parseInt($elem.css('margin-left'), 10) * -1; },
|
||||
getTop: function($elem) { return parseInt($elem.css('margin-top'), 10) * -1; }
|
||||
},
|
||||
transform: {
|
||||
getLeft: function($elem) {
|
||||
var computedTransform = getComputedStyle($elem[0])[prefixedTransform];
|
||||
return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[4], 10) * -1 : 0);
|
||||
},
|
||||
getTop: function($elem) {
|
||||
var computedTransform = getComputedStyle($elem[0])[prefixedTransform];
|
||||
return (computedTransform !== 'none' ? parseInt(computedTransform.match(/(-?[0-9]+)/g)[5], 10) * -1 : 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
positionProperty = {
|
||||
position: {
|
||||
setLeft: function($elem, left) { $elem.css('left', left); },
|
||||
setTop: function($elem, top) { $elem.css('top', top); }
|
||||
},
|
||||
transform: {
|
||||
setPosition: function($elem, left, startingLeft, top, startingTop) {
|
||||
$elem[0].style[prefixedTransform] = 'translate3d(' + (left - startingLeft) + 'px, ' + (top - startingTop) + 'px, 0)';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Returns a function which adds a vendor prefix to any CSS property name
|
||||
vendorPrefix = (function() {
|
||||
var prefixes = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/,
|
||||
style = $('script')[0].style,
|
||||
prefix = '',
|
||||
prop;
|
||||
|
||||
for (prop in style) {
|
||||
if (prefixes.test(prop)) {
|
||||
prefix = prop.match(prefixes)[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ('WebkitOpacity' in style) { prefix = 'Webkit'; }
|
||||
if ('KhtmlOpacity' in style) { prefix = 'Khtml'; }
|
||||
|
||||
return function(property) {
|
||||
return prefix + (prefix.length > 0 ? property.charAt(0).toUpperCase() + property.slice(1) : property);
|
||||
};
|
||||
}()),
|
||||
|
||||
prefixedTransform = vendorPrefix('transform'),
|
||||
|
||||
supportsBackgroundPositionXY = $('<div />', { style: 'background:#fff' }).css('background-position-x') !== undefined,
|
||||
|
||||
setBackgroundPosition = (supportsBackgroundPositionXY ?
|
||||
function($elem, x, y) {
|
||||
$elem.css({
|
||||
'background-position-x': x,
|
||||
'background-position-y': y
|
||||
});
|
||||
} :
|
||||
function($elem, x, y) {
|
||||
$elem.css('background-position', x + ' ' + y);
|
||||
}
|
||||
),
|
||||
|
||||
getBackgroundPosition = (supportsBackgroundPositionXY ?
|
||||
function($elem) {
|
||||
return [
|
||||
$elem.css('background-position-x'),
|
||||
$elem.css('background-position-y')
|
||||
];
|
||||
} :
|
||||
function($elem) {
|
||||
return $elem.css('background-position').split(' ');
|
||||
}
|
||||
),
|
||||
|
||||
requestAnimFrame = (
|
||||
window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
setTimeout(callback, 1000 / 60);
|
||||
}
|
||||
);
|
||||
|
||||
function Plugin(element, options) {
|
||||
this.element = element;
|
||||
this.options = $.extend({}, defaults, options);
|
||||
|
||||
this._defaults = defaults;
|
||||
this._name = pluginName;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype = {
|
||||
init: function() {
|
||||
this.options.name = pluginName + '_' + Math.floor(Math.random() * 1e9);
|
||||
|
||||
this._defineElements();
|
||||
this._defineGetters();
|
||||
this._defineSetters();
|
||||
this._handleWindowLoadAndResize();
|
||||
this._detectViewport();
|
||||
|
||||
this.refresh({ firstLoad: true });
|
||||
|
||||
if (this.options.scrollProperty === 'scroll') {
|
||||
this._handleScrollEvent();
|
||||
} else {
|
||||
this._startAnimationLoop();
|
||||
}
|
||||
},
|
||||
_defineElements: function() {
|
||||
if (this.element === document.body) this.element = window;
|
||||
this.$scrollElement = $(this.element);
|
||||
this.$element = (this.element === window ? $('body') : this.$scrollElement);
|
||||
this.$viewportElement = (this.options.viewportElement !== undefined ? $(this.options.viewportElement) : (this.$scrollElement[0] === window || this.options.scrollProperty === 'scroll' ? this.$scrollElement : this.$scrollElement.parent()) );
|
||||
},
|
||||
_defineGetters: function() {
|
||||
var self = this,
|
||||
scrollPropertyAdapter = scrollProperty[self.options.scrollProperty];
|
||||
|
||||
this._getScrollLeft = function() {
|
||||
return scrollPropertyAdapter.getLeft(self.$scrollElement);
|
||||
};
|
||||
|
||||
this._getScrollTop = function() {
|
||||
return scrollPropertyAdapter.getTop(self.$scrollElement);
|
||||
};
|
||||
},
|
||||
_defineSetters: function() {
|
||||
var self = this,
|
||||
scrollPropertyAdapter = scrollProperty[self.options.scrollProperty],
|
||||
positionPropertyAdapter = positionProperty[self.options.positionProperty],
|
||||
setScrollLeft = scrollPropertyAdapter.setLeft,
|
||||
setScrollTop = scrollPropertyAdapter.setTop;
|
||||
|
||||
this._setScrollLeft = (typeof setScrollLeft === 'function' ? function(val) {
|
||||
setScrollLeft(self.$scrollElement, val);
|
||||
} : $.noop);
|
||||
|
||||
this._setScrollTop = (typeof setScrollTop === 'function' ? function(val) {
|
||||
setScrollTop(self.$scrollElement, val);
|
||||
} : $.noop);
|
||||
|
||||
this._setPosition = positionPropertyAdapter.setPosition ||
|
||||
function($elem, left, startingLeft, top, startingTop) {
|
||||
if (self.options.horizontalScrolling) {
|
||||
positionPropertyAdapter.setLeft($elem, left, startingLeft);
|
||||
}
|
||||
|
||||
if (self.options.verticalScrolling) {
|
||||
positionPropertyAdapter.setTop($elem, top, startingTop);
|
||||
}
|
||||
};
|
||||
},
|
||||
_handleWindowLoadAndResize: function() {
|
||||
var self = this,
|
||||
$window = $(window);
|
||||
|
||||
if (self.options.responsive) {
|
||||
$window.bind('load.' + this.name, function() {
|
||||
self.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
$window.bind('resize.' + this.name, function() {
|
||||
self._detectViewport();
|
||||
|
||||
if (self.options.responsive) {
|
||||
self.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
refresh: function(options) {
|
||||
var self = this,
|
||||
oldLeft = self._getScrollLeft(),
|
||||
oldTop = self._getScrollTop();
|
||||
|
||||
if (!options || !options.firstLoad) {
|
||||
this._reset();
|
||||
}
|
||||
|
||||
this._setScrollLeft(0);
|
||||
this._setScrollTop(0);
|
||||
|
||||
this._setOffsets();
|
||||
this._findParticles();
|
||||
this._findBackgrounds();
|
||||
|
||||
// Fix for WebKit background rendering bug
|
||||
if (options && options.firstLoad && /WebKit/.test(navigator.userAgent)) {
|
||||
$(window).load(function() {
|
||||
var oldLeft = self._getScrollLeft(),
|
||||
oldTop = self._getScrollTop();
|
||||
|
||||
self._setScrollLeft(oldLeft + 1);
|
||||
self._setScrollTop(oldTop + 1);
|
||||
|
||||
self._setScrollLeft(oldLeft);
|
||||
self._setScrollTop(oldTop);
|
||||
});
|
||||
}
|
||||
|
||||
this._setScrollLeft(oldLeft);
|
||||
this._setScrollTop(oldTop);
|
||||
},
|
||||
_detectViewport: function() {
|
||||
var viewportOffsets = this.$viewportElement.offset(),
|
||||
hasOffsets = viewportOffsets !== null && viewportOffsets !== undefined;
|
||||
|
||||
this.viewportWidth = this.$viewportElement.width();
|
||||
this.viewportHeight = this.$viewportElement.height();
|
||||
|
||||
this.viewportOffsetTop = (hasOffsets ? viewportOffsets.top : 0);
|
||||
this.viewportOffsetLeft = (hasOffsets ? viewportOffsets.left : 0);
|
||||
},
|
||||
_findParticles: function() {
|
||||
var self = this,
|
||||
scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop();
|
||||
|
||||
if (this.particles !== undefined) {
|
||||
for (var i = this.particles.length - 1; i >= 0; i--) {
|
||||
this.particles[i].$element.data('stellar-elementIsActive', undefined);
|
||||
}
|
||||
}
|
||||
|
||||
this.particles = [];
|
||||
|
||||
if (!this.options.parallaxElements) return;
|
||||
|
||||
this.$element.find('[data-stellar-ratio]').each(function(i) {
|
||||
var $this = $(this),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
positionLeft,
|
||||
positionTop,
|
||||
marginLeft,
|
||||
marginTop,
|
||||
$offsetParent,
|
||||
offsetLeft,
|
||||
offsetTop,
|
||||
parentOffsetLeft = 0,
|
||||
parentOffsetTop = 0,
|
||||
tempParentOffsetLeft = 0,
|
||||
tempParentOffsetTop = 0;
|
||||
|
||||
// Ensure this element isn't already part of another scrolling element
|
||||
if (!$this.data('stellar-elementIsActive')) {
|
||||
$this.data('stellar-elementIsActive', this);
|
||||
} else if ($this.data('stellar-elementIsActive') !== this) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.options.showElement($this);
|
||||
|
||||
// Save/restore the original top and left CSS values in case we refresh the particles or destroy the instance
|
||||
if (!$this.data('stellar-startingLeft')) {
|
||||
$this.data('stellar-startingLeft', $this.css('left'));
|
||||
$this.data('stellar-startingTop', $this.css('top'));
|
||||
} else {
|
||||
$this.css('left', $this.data('stellar-startingLeft'));
|
||||
$this.css('top', $this.data('stellar-startingTop'));
|
||||
}
|
||||
|
||||
positionLeft = $this.position().left;
|
||||
positionTop = $this.position().top;
|
||||
|
||||
// Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8)
|
||||
marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10);
|
||||
marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10);
|
||||
|
||||
offsetLeft = $this.offset().left - marginLeft;
|
||||
offsetTop = $this.offset().top - marginTop;
|
||||
|
||||
// Calculate the offset parent
|
||||
$this.parents().each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.data('stellar-offset-parent') === true) {
|
||||
parentOffsetLeft = tempParentOffsetLeft;
|
||||
parentOffsetTop = tempParentOffsetTop;
|
||||
$offsetParent = $this;
|
||||
|
||||
return false;
|
||||
} else {
|
||||
tempParentOffsetLeft += $this.position().left;
|
||||
tempParentOffsetTop += $this.position().top;
|
||||
}
|
||||
});
|
||||
|
||||
// Detect the offsets
|
||||
horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset));
|
||||
verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset));
|
||||
|
||||
// Add our object to the particles collection
|
||||
self.particles.push({
|
||||
$element: $this,
|
||||
$offsetParent: $offsetParent,
|
||||
isFixed: $this.css('position') === 'fixed',
|
||||
horizontalOffset: horizontalOffset,
|
||||
verticalOffset: verticalOffset,
|
||||
startingPositionLeft: positionLeft,
|
||||
startingPositionTop: positionTop,
|
||||
startingOffsetLeft: offsetLeft,
|
||||
startingOffsetTop: offsetTop,
|
||||
parentOffsetLeft: parentOffsetLeft,
|
||||
parentOffsetTop: parentOffsetTop,
|
||||
stellarRatio: ($this.data('stellar-ratio') !== undefined ? $this.data('stellar-ratio') : 1),
|
||||
width: $this.outerWidth(true),
|
||||
height: $this.outerHeight(true),
|
||||
isHidden: false
|
||||
});
|
||||
});
|
||||
},
|
||||
_findBackgrounds: function() {
|
||||
var self = this,
|
||||
scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop(),
|
||||
$backgroundElements;
|
||||
|
||||
this.backgrounds = [];
|
||||
|
||||
if (!this.options.parallaxBackgrounds) return;
|
||||
|
||||
$backgroundElements = this.$element.find('[data-stellar-background-ratio]');
|
||||
|
||||
if (this.$element.data('stellar-background-ratio')) {
|
||||
$backgroundElements = $backgroundElements.add(this.$element);
|
||||
}
|
||||
|
||||
$backgroundElements.each(function() {
|
||||
var $this = $(this),
|
||||
backgroundPosition = getBackgroundPosition($this),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
positionLeft,
|
||||
positionTop,
|
||||
marginLeft,
|
||||
marginTop,
|
||||
offsetLeft,
|
||||
offsetTop,
|
||||
$offsetParent,
|
||||
parentOffsetLeft = 0,
|
||||
parentOffsetTop = 0,
|
||||
tempParentOffsetLeft = 0,
|
||||
tempParentOffsetTop = 0;
|
||||
|
||||
// Ensure this element isn't already part of another scrolling element
|
||||
if (!$this.data('stellar-backgroundIsActive')) {
|
||||
$this.data('stellar-backgroundIsActive', this);
|
||||
} else if ($this.data('stellar-backgroundIsActive') !== this) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Save/restore the original top and left CSS values in case we destroy the instance
|
||||
if (!$this.data('stellar-backgroundStartingLeft')) {
|
||||
$this.data('stellar-backgroundStartingLeft', backgroundPosition[0]);
|
||||
$this.data('stellar-backgroundStartingTop', backgroundPosition[1]);
|
||||
} else {
|
||||
setBackgroundPosition($this, $this.data('stellar-backgroundStartingLeft'), $this.data('stellar-backgroundStartingTop'));
|
||||
}
|
||||
|
||||
// Catch-all for margin top/left properties (these evaluate to 'auto' in IE7 and IE8)
|
||||
marginLeft = ($this.css('margin-left') === 'auto') ? 0 : parseInt($this.css('margin-left'), 10);
|
||||
marginTop = ($this.css('margin-top') === 'auto') ? 0 : parseInt($this.css('margin-top'), 10);
|
||||
|
||||
offsetLeft = $this.offset().left - marginLeft - scrollLeft;
|
||||
offsetTop = $this.offset().top - marginTop - scrollTop;
|
||||
|
||||
// Calculate the offset parent
|
||||
$this.parents().each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
if ($this.data('stellar-offset-parent') === true) {
|
||||
parentOffsetLeft = tempParentOffsetLeft;
|
||||
parentOffsetTop = tempParentOffsetTop;
|
||||
$offsetParent = $this;
|
||||
|
||||
return false;
|
||||
} else {
|
||||
tempParentOffsetLeft += $this.position().left;
|
||||
tempParentOffsetTop += $this.position().top;
|
||||
}
|
||||
});
|
||||
|
||||
// Detect the offsets
|
||||
horizontalOffset = ($this.data('stellar-horizontal-offset') !== undefined ? $this.data('stellar-horizontal-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-horizontal-offset') !== undefined ? $offsetParent.data('stellar-horizontal-offset') : self.horizontalOffset));
|
||||
verticalOffset = ($this.data('stellar-vertical-offset') !== undefined ? $this.data('stellar-vertical-offset') : ($offsetParent !== undefined && $offsetParent.data('stellar-vertical-offset') !== undefined ? $offsetParent.data('stellar-vertical-offset') : self.verticalOffset));
|
||||
|
||||
self.backgrounds.push({
|
||||
$element: $this,
|
||||
$offsetParent: $offsetParent,
|
||||
isFixed: $this.css('background-attachment') === 'fixed',
|
||||
horizontalOffset: horizontalOffset,
|
||||
verticalOffset: verticalOffset,
|
||||
startingValueLeft: backgroundPosition[0],
|
||||
startingValueTop: backgroundPosition[1],
|
||||
startingBackgroundPositionLeft: (isNaN(parseInt(backgroundPosition[0], 10)) ? 0 : parseInt(backgroundPosition[0], 10)),
|
||||
startingBackgroundPositionTop: (isNaN(parseInt(backgroundPosition[1], 10)) ? 0 : parseInt(backgroundPosition[1], 10)),
|
||||
startingPositionLeft: $this.position().left,
|
||||
startingPositionTop: $this.position().top,
|
||||
startingOffsetLeft: offsetLeft,
|
||||
startingOffsetTop: offsetTop,
|
||||
parentOffsetLeft: parentOffsetLeft,
|
||||
parentOffsetTop: parentOffsetTop,
|
||||
stellarRatio: ($this.data('stellar-background-ratio') === undefined ? 1 : $this.data('stellar-background-ratio'))
|
||||
});
|
||||
});
|
||||
},
|
||||
_reset: function() {
|
||||
var particle,
|
||||
startingPositionLeft,
|
||||
startingPositionTop,
|
||||
background,
|
||||
i;
|
||||
|
||||
for (i = this.particles.length - 1; i >= 0; i--) {
|
||||
particle = this.particles[i];
|
||||
startingPositionLeft = particle.$element.data('stellar-startingLeft');
|
||||
startingPositionTop = particle.$element.data('stellar-startingTop');
|
||||
|
||||
this._setPosition(particle.$element, startingPositionLeft, startingPositionLeft, startingPositionTop, startingPositionTop);
|
||||
|
||||
this.options.showElement(particle.$element);
|
||||
|
||||
particle.$element.data('stellar-startingLeft', null).data('stellar-elementIsActive', null).data('stellar-backgroundIsActive', null);
|
||||
}
|
||||
|
||||
for (i = this.backgrounds.length - 1; i >= 0; i--) {
|
||||
background = this.backgrounds[i];
|
||||
|
||||
background.$element.data('stellar-backgroundStartingLeft', null).data('stellar-backgroundStartingTop', null);
|
||||
|
||||
setBackgroundPosition(background.$element, background.startingValueLeft, background.startingValueTop);
|
||||
}
|
||||
},
|
||||
destroy: function() {
|
||||
this._reset();
|
||||
|
||||
this.$scrollElement.unbind('resize.' + this.name).unbind('scroll.' + this.name);
|
||||
this._animationLoop = $.noop;
|
||||
|
||||
$(window).unbind('load.' + this.name).unbind('resize.' + this.name);
|
||||
},
|
||||
_setOffsets: function() {
|
||||
var self = this,
|
||||
$window = $(window);
|
||||
|
||||
$window.unbind('resize.horizontal-' + this.name).unbind('resize.vertical-' + this.name);
|
||||
|
||||
if (typeof this.options.horizontalOffset === 'function') {
|
||||
this.horizontalOffset = this.options.horizontalOffset();
|
||||
$window.bind('resize.horizontal-' + this.name, function() {
|
||||
self.horizontalOffset = self.options.horizontalOffset();
|
||||
});
|
||||
} else {
|
||||
this.horizontalOffset = this.options.horizontalOffset;
|
||||
}
|
||||
|
||||
if (typeof this.options.verticalOffset === 'function') {
|
||||
this.verticalOffset = this.options.verticalOffset();
|
||||
$window.bind('resize.vertical-' + this.name, function() {
|
||||
self.verticalOffset = self.options.verticalOffset();
|
||||
});
|
||||
} else {
|
||||
this.verticalOffset = this.options.verticalOffset;
|
||||
}
|
||||
},
|
||||
_repositionElements: function() {
|
||||
var scrollLeft = this._getScrollLeft(),
|
||||
scrollTop = this._getScrollTop(),
|
||||
horizontalOffset,
|
||||
verticalOffset,
|
||||
particle,
|
||||
fixedRatioOffset,
|
||||
background,
|
||||
bgLeft,
|
||||
bgTop,
|
||||
isVisibleVertical = true,
|
||||
isVisibleHorizontal = true,
|
||||
newPositionLeft,
|
||||
newPositionTop,
|
||||
newOffsetLeft,
|
||||
newOffsetTop,
|
||||
i;
|
||||
|
||||
// First check that the scroll position or container size has changed
|
||||
if (this.currentScrollLeft === scrollLeft && this.currentScrollTop === scrollTop && this.currentWidth === this.viewportWidth && this.currentHeight === this.viewportHeight) {
|
||||
return;
|
||||
} else {
|
||||
this.currentScrollLeft = scrollLeft;
|
||||
this.currentScrollTop = scrollTop;
|
||||
this.currentWidth = this.viewportWidth;
|
||||
this.currentHeight = this.viewportHeight;
|
||||
}
|
||||
|
||||
// Reposition elements
|
||||
for (i = this.particles.length - 1; i >= 0; i--) {
|
||||
particle = this.particles[i];
|
||||
|
||||
fixedRatioOffset = (particle.isFixed ? 1 : 0);
|
||||
|
||||
// Calculate position, then calculate what the particle's new offset will be (for visibility check)
|
||||
if (this.options.horizontalScrolling) {
|
||||
newPositionLeft = (scrollLeft + particle.horizontalOffset + this.viewportOffsetLeft + particle.startingPositionLeft - particle.startingOffsetLeft + particle.parentOffsetLeft) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionLeft;
|
||||
newOffsetLeft = newPositionLeft - particle.startingPositionLeft + particle.startingOffsetLeft;
|
||||
} else {
|
||||
newPositionLeft = particle.startingPositionLeft;
|
||||
newOffsetLeft = particle.startingOffsetLeft;
|
||||
}
|
||||
|
||||
if (this.options.verticalScrolling) {
|
||||
newPositionTop = (scrollTop + particle.verticalOffset + this.viewportOffsetTop + particle.startingPositionTop - particle.startingOffsetTop + particle.parentOffsetTop) * -(particle.stellarRatio + fixedRatioOffset - 1) + particle.startingPositionTop;
|
||||
newOffsetTop = newPositionTop - particle.startingPositionTop + particle.startingOffsetTop;
|
||||
} else {
|
||||
newPositionTop = particle.startingPositionTop;
|
||||
newOffsetTop = particle.startingOffsetTop;
|
||||
}
|
||||
|
||||
// Check visibility
|
||||
if (this.options.hideDistantElements) {
|
||||
isVisibleHorizontal = !this.options.horizontalScrolling || newOffsetLeft + particle.width > (particle.isFixed ? 0 : scrollLeft) && newOffsetLeft < (particle.isFixed ? 0 : scrollLeft) + this.viewportWidth + this.viewportOffsetLeft;
|
||||
isVisibleVertical = !this.options.verticalScrolling || newOffsetTop + particle.height > (particle.isFixed ? 0 : scrollTop) && newOffsetTop < (particle.isFixed ? 0 : scrollTop) + this.viewportHeight + this.viewportOffsetTop;
|
||||
}
|
||||
|
||||
if (isVisibleHorizontal && isVisibleVertical) {
|
||||
if (particle.isHidden) {
|
||||
this.options.showElement(particle.$element);
|
||||
particle.isHidden = false;
|
||||
}
|
||||
|
||||
this._setPosition(particle.$element, newPositionLeft, particle.startingPositionLeft, newPositionTop, particle.startingPositionTop);
|
||||
} else {
|
||||
if (!particle.isHidden) {
|
||||
this.options.hideElement(particle.$element);
|
||||
particle.isHidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reposition backgrounds
|
||||
for (i = this.backgrounds.length - 1; i >= 0; i--) {
|
||||
background = this.backgrounds[i];
|
||||
|
||||
fixedRatioOffset = (background.isFixed ? 0 : 1);
|
||||
bgLeft = (this.options.horizontalScrolling ? (scrollLeft + background.horizontalOffset - this.viewportOffsetLeft - background.startingOffsetLeft + background.parentOffsetLeft - background.startingBackgroundPositionLeft) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueLeft);
|
||||
bgTop = (this.options.verticalScrolling ? (scrollTop + background.verticalOffset - this.viewportOffsetTop - background.startingOffsetTop + background.parentOffsetTop - background.startingBackgroundPositionTop) * (fixedRatioOffset - background.stellarRatio) + 'px' : background.startingValueTop);
|
||||
|
||||
setBackgroundPosition(background.$element, bgLeft, bgTop);
|
||||
}
|
||||
},
|
||||
_handleScrollEvent: function() {
|
||||
var self = this,
|
||||
ticking = false;
|
||||
|
||||
var update = function() {
|
||||
self._repositionElements();
|
||||
ticking = false;
|
||||
};
|
||||
|
||||
var requestTick = function() {
|
||||
if (!ticking) {
|
||||
requestAnimFrame(update);
|
||||
ticking = true;
|
||||
}
|
||||
};
|
||||
|
||||
this.$scrollElement.bind('scroll.' + this.name, requestTick);
|
||||
requestTick();
|
||||
},
|
||||
_startAnimationLoop: function() {
|
||||
var self = this;
|
||||
|
||||
this._animationLoop = function() {
|
||||
requestAnimFrame(self._animationLoop);
|
||||
self._repositionElements();
|
||||
};
|
||||
this._animationLoop();
|
||||
}
|
||||
};
|
||||
|
||||
$.fn[pluginName] = function (options) {
|
||||
var args = arguments;
|
||||
if (options === undefined || typeof options === 'object') {
|
||||
return this.each(function () {
|
||||
if (!$.data(this, 'plugin_' + pluginName)) {
|
||||
$.data(this, 'plugin_' + pluginName, new Plugin(this, options));
|
||||
}
|
||||
});
|
||||
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
||||
return this.each(function () {
|
||||
var instance = $.data(this, 'plugin_' + pluginName);
|
||||
if (instance instanceof Plugin && typeof instance[options] === 'function') {
|
||||
instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
||||
}
|
||||
if (options === 'destroy') {
|
||||
$.data(this, 'plugin_' + pluginName, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$[pluginName] = function(options) {
|
||||
var $window = $(window);
|
||||
return $window.stellar.apply($window, Array.prototype.slice.call(arguments, 0));
|
||||
};
|
||||
|
||||
// Expose the scroll and position property function hashes so they can be extended
|
||||
$[pluginName].scrollProperty = scrollProperty;
|
||||
$[pluginName].positionProperty = positionProperty;
|
||||
|
||||
// Expose the plugin class so it can be modified
|
||||
window.Stellar = Plugin;
|
||||
}(jQuery, this, document));
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "jquery.stellar",
|
||||
"title": "Stellar.js",
|
||||
"version": "0.6.2",
|
||||
"description": "Parallax scrolling made easy.",
|
||||
"homepage": "http://markdalgleish.com/projects/stellar.js",
|
||||
"author": {
|
||||
"name": "Mark Dalgleish",
|
||||
"url": "http://markdalgleish.com"
|
||||
},
|
||||
"keywords": [
|
||||
"parallax",
|
||||
"scroll",
|
||||
"effect",
|
||||
"animation"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://markdalgleish.mit-license.org"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.4.3"
|
||||
},
|
||||
"bugs": "https://github.com/markdalgleish/stellar.js/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/markdalgleish/stellar.js.git"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Mark Dalgleish",
|
||||
"url": "http://markdalgleish.com"
|
||||
}
|
||||
],
|
||||
"files": [
|
||||
"jquery.stellar.js"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.3.17"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "stellar",
|
||||
"title": "Stellar.js",
|
||||
"version": "0.6.2",
|
||||
"description": "Parallax scrolling made easy.",
|
||||
"homepage": "http://markdalgleish.com/projects/stellar.js",
|
||||
"author": {
|
||||
"name": "Mark Dalgleish",
|
||||
"url": "http://markdalgleish.com"
|
||||
},
|
||||
"keywords": [
|
||||
"parallax",
|
||||
"scroll",
|
||||
"effect",
|
||||
"animation"
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://markdalgleish.mit-license.org"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.4.3"
|
||||
},
|
||||
"bugs": "https://github.com/markdalgleish/stellar.js/issues",
|
||||
"docs": "http://markdalgleish.com/projects/stellar.js/docs",
|
||||
"download": "https://github.com/markdalgleish/stellar.js#download"
|
||||
}
|
|
@ -305,87 +305,53 @@ table.editorbar-panel td.selected {
|
|||
}
|
||||
|
||||
/* ---- SNIPPETS DROP ZONES ---- */
|
||||
#dark_for_dropzone {
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 0.4;
|
||||
z-index: 1000;
|
||||
pointer-events: none;
|
||||
}
|
||||
#dark_for_dropzone td {
|
||||
background: black;
|
||||
}
|
||||
#dark_for_dropzone td.center.active {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.oe_drop_zone, .oe_drop_zone_style {
|
||||
border: none;
|
||||
background: rgba(100, 255, 255, 0.9);
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.oe_drop_zone div, .oe_drop_zone_style div {
|
||||
margin: 0;
|
||||
line-height: 48px;
|
||||
text-align: center;
|
||||
color: magenta;
|
||||
font-weight: bold;
|
||||
font-size: 24px;
|
||||
}
|
||||
.oe_drop_zone .oe_active, .oe_drop_zone_style .oe_active {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.oe_drop_zone_style div {
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.oe_drop_zone {
|
||||
.oe_drop_zone.oe_insert {
|
||||
display: block;
|
||||
height: 48px;
|
||||
margin: 0px;
|
||||
margin-top: -4px;
|
||||
margin-bottom: -44px;
|
||||
z-index: 1002;
|
||||
-webkit-transition: margin 250ms linear;
|
||||
-moz-transition: margin 250ms linear;
|
||||
-o-transition: margin 250ms linear;
|
||||
transition: margin 250ms linear;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
z-index: 1000;
|
||||
}
|
||||
.oe_drop_zone:not(.oe_vertical):before {
|
||||
.oe_drop_zone.oe_insert:not(.oe_vertical):before {
|
||||
content: "";
|
||||
display: block;
|
||||
border-top: dashed 2px rgba(209, 178, 255, 0.72);
|
||||
position: relative;
|
||||
top: 0px;
|
||||
}
|
||||
.oe_drop_zone.oe_hover:before {
|
||||
.oe_drop_zone.oe_insert.oe_hover:before {
|
||||
border-top: dashed 2px rgba(116, 255, 161, 0.72);
|
||||
}
|
||||
.oe_drop_zone.oe_vertical {
|
||||
.oe_drop_zone.oe_insert.oe_vertical {
|
||||
width: 48px;
|
||||
float: left;
|
||||
position: relative;
|
||||
margin: 4px -24px !important;
|
||||
margin: 0px -24px !important;
|
||||
}
|
||||
.oe_drop_zone.oe_vertical div {
|
||||
display: none;
|
||||
}
|
||||
.oe_drop_zone.oe_overlay {
|
||||
.oe_drop_zone.oe_insert.oe_overlay {
|
||||
border-radius: 3px;
|
||||
background: rgba(153, 0, 255, 0.5);
|
||||
}
|
||||
.oe_drop_zone.oe_drop_active {
|
||||
background: rgba(100, 255, 255, 0.3);
|
||||
|
||||
.oe_drop_zone, .oe_drop_zone_style {
|
||||
border: none;
|
||||
background: rgba(153, 0, 255, 0.3);
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.oe_drop_zone.oe_drop_active div {
|
||||
display: none;
|
||||
}
|
||||
.oe_drop_zone.oe_drop_active .oe_active {
|
||||
display: block;
|
||||
.oe_drop_zone.oe_hover, .oe_drop_zone_style.oe_hover {
|
||||
background: rgba(0, 255, 133, 0.3);
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.oe_drop_zone_style {
|
||||
|
|
|
@ -242,45 +242,16 @@ table.editorbar-panel
|
|||
|
||||
/* ---- SNIPPETS DROP ZONES ---- */
|
||||
|
||||
#dark_for_dropzone
|
||||
width: 100%
|
||||
position: absolute
|
||||
top: 0
|
||||
left: 0
|
||||
opacity: 0.4
|
||||
z-index: 1000
|
||||
pointer-events: none
|
||||
td
|
||||
background: #000
|
||||
&.center.active
|
||||
background: transparent
|
||||
|
||||
.oe_drop_zone, .oe_drop_zone_style
|
||||
border: none
|
||||
background: rgba(100, 255, 255, .9)
|
||||
+border-radius(4px)
|
||||
div
|
||||
margin: 0
|
||||
line-height: 48px
|
||||
text-align: center
|
||||
color: #FF00FF
|
||||
font-weight: bold
|
||||
font-size: 24px
|
||||
.oe_active
|
||||
display: none
|
||||
|
||||
.oe_drop_zone_style div
|
||||
line-height: 24px
|
||||
|
||||
.oe_drop_zone
|
||||
.oe_drop_zone.oe_insert
|
||||
display: block
|
||||
height: 48px
|
||||
margin: 0px
|
||||
margin-top: -4px
|
||||
margin-bottom: -44px
|
||||
z-index: 1002
|
||||
@include transition(margin 250ms linear)
|
||||
width: 100%
|
||||
position: absolute
|
||||
z-index: 1000
|
||||
&:not(.oe_vertical):before
|
||||
content: ""
|
||||
display: block
|
||||
|
@ -293,17 +264,22 @@ table.editorbar-panel
|
|||
width: 48px
|
||||
float: left
|
||||
position: relative
|
||||
margin: 4px -24px !important
|
||||
div
|
||||
display: none
|
||||
margin: 0px -24px !important
|
||||
&.oe_overlay
|
||||
border-radius: 3px
|
||||
&.oe_drop_active
|
||||
background: rgba(100, 255, 255, .3)
|
||||
div
|
||||
display: none
|
||||
.oe_active
|
||||
display: block
|
||||
//@include background-image( repeating-linear-gradient(45deg, rgba(255,255,255,.1) ,rgba(255,255,255,.1) 35px, rgba(0,0,0,.1) 35px, rgba(0,0,0,.1) 75px))
|
||||
//background-size: 100px 100px
|
||||
background: rgba(153, 0, 255,.5)
|
||||
|
||||
.oe_drop_zone, .oe_drop_zone_style
|
||||
border: none
|
||||
//@include background-image( repeating-linear-gradient(45deg, rgba(255,255,255,.1) ,rgba(255,255,255,.1) 35px, rgba(0,0,0,.1) 35px, rgba(0,0,0,.1) 75px))
|
||||
//background-size: 100px 100px
|
||||
background: rgba(153, 0, 255, .3)
|
||||
+border-radius(4px)
|
||||
&.oe_hover
|
||||
background: rgba(0, 255, 133, .3)
|
||||
z-index: 1001
|
||||
|
||||
.oe_drop_zone_style
|
||||
color: white
|
||||
|
|
|
@ -216,4 +216,5 @@
|
|||
[data-snippet-id] {
|
||||
min-height: 10px;
|
||||
min-width: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -234,10 +234,7 @@ footer {
|
|||
}
|
||||
|
||||
.oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child {
|
||||
position: relative;
|
||||
}
|
||||
.oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child div, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child div {
|
||||
display: none;
|
||||
position: static;
|
||||
}
|
||||
|
||||
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before {
|
||||
|
@ -361,21 +358,17 @@ footer {
|
|||
.parallax_quote .carousel-indicators .active {
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
.parallax_full {
|
||||
min-height: 650px;
|
||||
background: #eee top center no-repeat fixed;
|
||||
width: 100%;
|
||||
.parallax {
|
||||
background-attachment: fixed;
|
||||
background-size: 100%;
|
||||
padding: 0px;
|
||||
}
|
||||
.parallax_full.oe_small .container {
|
||||
.parallax.oe_small {
|
||||
height: 200px;
|
||||
}
|
||||
.parallax_full.oe_medium .container {
|
||||
.parallax.oe_medium {
|
||||
height: 300px;
|
||||
}
|
||||
.parallax_full.oe_big .container {
|
||||
.parallax.oe_big {
|
||||
height: 450px;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,9 +161,7 @@ footer
|
|||
height: 220px !important
|
||||
|
||||
.oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child
|
||||
position: relative
|
||||
div
|
||||
display: none
|
||||
position: static
|
||||
|
||||
.oe_structure.oe_empty:empty:before, [data-oe-type=html]:empty:before, .oe_structure.oe_empty > .oe_drop_zone.oe_insert:only-child:before, [data-oe-type=html] > .oe_drop_zone.oe_insert:only-child:before
|
||||
content: 'Click Edit To Create Content'
|
||||
|
@ -277,17 +275,14 @@ footer
|
|||
.active
|
||||
background-color: grey
|
||||
|
||||
.parallax_full
|
||||
min-height: 650px
|
||||
background: #eee top center no-repeat fixed
|
||||
width: 100%
|
||||
.parallax
|
||||
background-attachment: fixed
|
||||
background-size: 100%
|
||||
padding: 0px
|
||||
&.oe_small .container
|
||||
&.oe_small
|
||||
height: 200px
|
||||
&.oe_medium .container
|
||||
&.oe_medium
|
||||
height: 300px
|
||||
&.oe_big .container
|
||||
&.oe_big
|
||||
height: 450px
|
||||
|
||||
/* -- Hack for removing double scrollbar from mobile preview -- */
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 163 KiB |
Binary file not shown.
After Width: | Height: | Size: 209 KiB |
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
|
@ -311,6 +311,7 @@
|
|||
},
|
||||
});
|
||||
|
||||
var blocks_selector = _.keys(CKEDITOR.dtd.$block).join(',');
|
||||
/* ----- RICH TEXT EDITOR ---- */
|
||||
website.RTE = openerp.Widget.extend({
|
||||
tagName: 'li',
|
||||
|
@ -324,6 +325,103 @@
|
|||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* In Webkit-based browsers, triple-click will select a paragraph up to
|
||||
* the start of the next "paragraph" including any empty space
|
||||
* inbetween. When said paragraph is removed or altered, it nukes
|
||||
* the empty space and brings part of the content of the next
|
||||
* "paragraph" (which may well be e.g. an image) into the current one,
|
||||
* completely fucking up layouts and breaking snippets.
|
||||
*
|
||||
* Try to fuck around with selections on triple-click to attempt to
|
||||
* fix this garbage behavior.
|
||||
*
|
||||
* Note: for consistent behavior we may actually want to take over
|
||||
* triple-clicks, in all browsers in order to ensure consistent cross-
|
||||
* platform behavior instead of being at the mercy of rendering engines
|
||||
* & platform selection quirks?
|
||||
*/
|
||||
webkitSelectionFixer: function (root) {
|
||||
root.addEventListener('click', function (e) {
|
||||
// only webkit seems to have a fucked up behavior, ignore others
|
||||
// FIXME: $.browser goes away in jquery 1.9...
|
||||
if (!$.browser.webkit) { return; }
|
||||
// http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mouseevents
|
||||
// The detail attribute indicates the number of times a mouse button has been pressed
|
||||
// we just want the triple click
|
||||
if (e.detail !== 3) { return; }
|
||||
|
||||
// Get closest block-level element to the triple-clicked
|
||||
// element (using ckeditor's block list because why not)
|
||||
var $closest_block = $(e.target).closest(blocks_selector);
|
||||
|
||||
// manually set selection range to the content of the
|
||||
// triple-clicked block-level element, to avoid crossing over
|
||||
// between block-level elements
|
||||
document.getSelection().selectAllChildren($closest_block[0]);
|
||||
});
|
||||
},
|
||||
tableNavigation: function (root) {
|
||||
var self = this;
|
||||
$(root).on('keydown', function (e) {
|
||||
// ignore non-TAB
|
||||
if (e.which !== 9) { return; }
|
||||
|
||||
if (self.handleTab(e)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Performs whatever operation is necessary on a [TAB] hit, returns
|
||||
* ``true`` if the event's default should be cancelled (if the TAB was
|
||||
* handled by the function)
|
||||
*/
|
||||
handleTab: function (event) {
|
||||
var forward = !event.shiftKey;
|
||||
|
||||
var root = window.getSelection().getRangeAt(0).commonAncestorContainer;
|
||||
var $cell = $(root).closest('td,th');
|
||||
|
||||
if (!$cell.length) { return false; }
|
||||
|
||||
var cell = $cell[0];
|
||||
|
||||
// find cell in same row
|
||||
var row = cell.parentNode;
|
||||
var sibling = row.cells[cell.cellIndex + (forward ? 1 : -1)];
|
||||
if (sibling) {
|
||||
document.getSelection().selectAllChildren(sibling);
|
||||
return true;
|
||||
}
|
||||
|
||||
// find cell in previous/next row
|
||||
var table = row.parentNode;
|
||||
var sibling_row = table.rows[row.rowIndex + (forward ? 1 : -1)];
|
||||
if (sibling_row) {
|
||||
var new_cell = sibling_row.cells[forward ? 0 : sibling_row.cells.length - 1];
|
||||
document.getSelection().selectAllChildren(new_cell);
|
||||
return true;
|
||||
}
|
||||
|
||||
// at edge cells, copy word/openoffice behavior: if going backwards
|
||||
// from first cell do nothing, if going forwards from last cell add
|
||||
// a row
|
||||
if (forward) {
|
||||
var row_size = row.cells.length;
|
||||
var new_row = document.createElement('tr');
|
||||
while(row_size--) {
|
||||
var newcell = document.createElement('td');
|
||||
// zero-width space
|
||||
newcell.textContent = '\u200B';
|
||||
new_row.appendChild(newcell);
|
||||
}
|
||||
table.appendChild(new_row);
|
||||
document.getSelection().selectAllChildren(new_row.cells[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
start_edition: function ($elements) {
|
||||
var self = this;
|
||||
// create a single editor for the whole page
|
||||
|
@ -331,6 +429,8 @@
|
|||
$(root).on('dragstart', 'img', function (e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
this.webkitSelectionFixer(root);
|
||||
this.tableNavigation(root);
|
||||
var editor = this.editor = CKEDITOR.inline(root, self._config());
|
||||
editor.on('instanceReady', function () {
|
||||
editor.setReadOnly(false);
|
||||
|
@ -341,6 +441,10 @@
|
|||
|
||||
self.setup_editables(root);
|
||||
|
||||
// disable firefox's broken table resizing thing
|
||||
document.execCommand("enableObjectResizing", false, "false");
|
||||
document.execCommand("enableInlineTableEditing", false, "false");
|
||||
|
||||
self.trigger('rte:ready');
|
||||
});
|
||||
},
|
||||
|
@ -401,7 +505,7 @@
|
|||
'indentblock', 'indentlist', 'justify',
|
||||
'list', 'pastefromword', 'pastetext', 'preview',
|
||||
'removeformat', 'resize', 'save', 'selectall', 'stylescombo',
|
||||
'tab', 'table', 'templates', 'toolbar', 'undo', 'wysiwygarea'
|
||||
'table', 'templates', 'toolbar', 'undo', 'wysiwygarea'
|
||||
];
|
||||
return {
|
||||
// FIXME
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
},
|
||||
save: function () {
|
||||
this.snippets.make_active(false);
|
||||
|
||||
// TODO TOFIX: call clean_for_save on all snippets of the page, not only modified ones
|
||||
// important for banner of parallax that changes data automatically.
|
||||
this.snippets.clean_for_save();
|
||||
remove_added_snippet_id();
|
||||
this._super();
|
||||
|
@ -319,32 +322,17 @@
|
|||
|
||||
}
|
||||
|
||||
var $dark = $(openerp.qweb.render('website.snippet_dark_for_dropzone'))
|
||||
.css('height', $("body")[0].scrollHeight + 'px');
|
||||
$("body").append($dark);
|
||||
|
||||
$('.oe_drop_zone').droppable({
|
||||
over: function(){
|
||||
if( action === 'insert'){
|
||||
dropped = true;
|
||||
$(this).first().addClass("oe_drop_active").after($toInsert);
|
||||
$dark.find("td:first")
|
||||
.css('height', $toInsert.offset().top+'px');
|
||||
$dark.find("tr:eq(1) td:first")
|
||||
.css('width', $toInsert.offset().left+'px');
|
||||
$dark.find("td.center")
|
||||
.addClass("active")
|
||||
.css('height', $toInsert.outerHeight()+'px')
|
||||
.css('width', $toInsert.outerWidth()+'px');
|
||||
$(this).first().after($toInsert);
|
||||
}
|
||||
},
|
||||
out: function(){
|
||||
if( action === 'insert'){
|
||||
$(this).removeClass("oe_drop_active");
|
||||
dropped = false;
|
||||
$toInsert.detach();
|
||||
$dark.find("td.center").removeClass("active");
|
||||
$("body").scroll(); // trigger a scroll to reset position for jquery api
|
||||
}
|
||||
},
|
||||
drop: function(){
|
||||
|
@ -353,8 +341,15 @@
|
|||
});
|
||||
},
|
||||
stop: function(ev, ui){
|
||||
if (action === 'insert' && ! dropped) {
|
||||
var el = $('.oe_drop_zone').nearest({x: ui.position.left, y: ui.position.top}).first()
|
||||
if (el) {
|
||||
el.after($toInsert)
|
||||
dropped = true;
|
||||
}
|
||||
}
|
||||
|
||||
$('.oe_drop_zone').droppable('destroy').remove();
|
||||
$("#dark_for_dropzone").remove();
|
||||
if (dropped) {
|
||||
var $target = false;
|
||||
if(action === 'insert'){
|
||||
|
@ -405,7 +400,7 @@
|
|||
var sibling_selector = selector.siblings;
|
||||
var vertical_child_selector = selector.vertical_children;
|
||||
|
||||
var zone_template = openerp.qweb.render('website.snippet_drop_zone');
|
||||
var zone_template = "<div class='oe_drop_zone oe_insert'></div>";
|
||||
|
||||
if(child_selector){
|
||||
self.dom_filter(child_selector).each(function (){
|
||||
|
@ -425,7 +420,7 @@
|
|||
var temp_left = 0;
|
||||
$zone.find('> *:not(.oe_drop_zone):visible').each(function () {
|
||||
var $col = $(this);
|
||||
$template.css('height', ($col.outerHeight() + parseInt($col.css("margin-top")) + parseInt($col.css("margin-bottom")) - 8)+'px');
|
||||
$template.css('height', ($col.outerHeight() + parseInt($col.css("margin-top")) + parseInt($col.css("margin-bottom")))+'px');
|
||||
$lastinsert = $template.clone();
|
||||
$(this).after($lastinsert);
|
||||
|
||||
|
@ -594,8 +589,7 @@
|
|||
* Displayed into the overlay options on focus
|
||||
*/
|
||||
_readXMLData: function() {
|
||||
var self = this;
|
||||
this.$el = this.parent.$snippets.filter(function () { return $(this).data("snippet-id") == self.snippet_id; }).clone();
|
||||
this.$el = this.parent.$snippets.siblings("[data-snippet-id='"+this.snippet_id+"']").clone();
|
||||
this.$editor = this.$el.find(".oe_snippet_options");
|
||||
var $options = this.$overlay.find(".oe_overlay_options");
|
||||
this.$editor.prependTo($options.find(".oe_options ul"));
|
||||
|
@ -630,28 +624,18 @@
|
|||
});
|
||||
},
|
||||
_drag_and_drop_after_insert_dropzone: function (){},
|
||||
_drag_and_drop_active_drop_zone: function (){
|
||||
_drag_and_drop_active_drop_zone: function ($zones){
|
||||
var self = this;
|
||||
var $dark = $("#dark_for_dropzone");
|
||||
$('.oe_drop_zone').droppable({
|
||||
$zones.droppable({
|
||||
over: function(){
|
||||
$(this).first().addClass("oe_drop_active").after(self.$target);
|
||||
$dark.find("td:first")
|
||||
.css('height', self.$target.offset().top+'px');
|
||||
$dark.find("tr:eq(1) td:first")
|
||||
.css('width', self.$target.offset().left+'px');
|
||||
$dark.find("td.center")
|
||||
.addClass("active")
|
||||
.css('height', self.$target.outerHeight()+'px')
|
||||
.css('width', self.$target.outerWidth()+'px');
|
||||
$(".oe_drop_zone.hide").removeClass("hide");
|
||||
$(this).addClass("hide").first().after(self.$target);
|
||||
self.dropped = true;
|
||||
},
|
||||
out: function(){
|
||||
$(this).removeClass("oe_drop_active");
|
||||
$dark.find("td.center").removeClass("active");
|
||||
$(this).removeClass("hide");
|
||||
self.$target.detach();
|
||||
self.dropped = false;
|
||||
$("body").scroll(); // trigger a scroll to reset position for jquery api
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -675,12 +659,8 @@
|
|||
|
||||
$("body").addClass('move-important');
|
||||
|
||||
var $dark = $(openerp.qweb.render('website.snippet_dark_for_dropzone'))
|
||||
.css('height', $("body")[0].scrollHeight + 'px');
|
||||
$("body").append($dark);
|
||||
|
||||
self._drag_and_drop_after_insert_dropzone();
|
||||
self._drag_and_drop_active_drop_zone();
|
||||
self._drag_and_drop_active_drop_zone($('.oe_drop_zone'));
|
||||
},
|
||||
_drag_and_drop_stop: function (){
|
||||
var self = this;
|
||||
|
@ -690,7 +670,6 @@
|
|||
self.$overlay.removeClass("hidden");
|
||||
$("body").removeClass('move-important');
|
||||
$('.oe_drop_zone').droppable('destroy').remove();
|
||||
$('#dark_for_dropzone').remove();
|
||||
$(".oe_drop_clone, .oe_drop_to_remove").remove();
|
||||
self.parent.editor_busy = false;
|
||||
self.get_parent_block();
|
||||
|
@ -988,25 +967,23 @@
|
|||
|
||||
_drag_and_drop_after_insert_dropzone: function(){
|
||||
var self = this;
|
||||
// commented for perf
|
||||
|
||||
// var $zones = $(".row:has(> .oe_drop_zone)").each(function () {
|
||||
// var $row = $(this);
|
||||
// var width = $row.innerWidth();
|
||||
// var pos = 0;
|
||||
// while (width > pos + self.size.width) {
|
||||
// var $last = $row.find("> .oe_drop_zone:last");
|
||||
// $last.each(function () {
|
||||
// pos = $(this).position().left;
|
||||
// });
|
||||
// if (width > pos + self.size.width) {
|
||||
// $row.append("<div class='col-md-1 oe_drop_to_remove'/>");
|
||||
// var $add_drop = $last.clone();
|
||||
// $row.append($add_drop);
|
||||
// self._drag_and_drop_active_drop_zone($add_drop);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
var $zones = $(".row:has(> .oe_drop_zone)").each(function () {
|
||||
var $row = $(this);
|
||||
var width = $row.innerWidth();
|
||||
var pos = 0;
|
||||
while (width > pos + self.size.width) {
|
||||
var $last = $row.find("> .oe_drop_zone:last");
|
||||
$last.each(function () {
|
||||
pos = $(this).position().left;
|
||||
});
|
||||
if (width > pos + self.size.width) {
|
||||
$row.append("<div class='col-md-1 oe_drop_to_remove'/>");
|
||||
var $add_drop = $last.clone();
|
||||
$row.append($add_drop);
|
||||
self._drag_and_drop_active_drop_zone($add_drop);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
_drag_and_drop_start: function () {
|
||||
this._super();
|
||||
|
@ -1044,7 +1021,7 @@
|
|||
|
||||
website.snippet.animationRegistry.carousel = website.snippet.Animation.extend({
|
||||
start: function () {
|
||||
this.$target.carousel();
|
||||
this.$target.carousel({interval: false});
|
||||
},
|
||||
});
|
||||
website.snippet.editorRegistry.carousel = website.snippet.editorRegistry.resize.extend({
|
||||
|
@ -1100,6 +1077,14 @@
|
|||
self.$target.carousel();
|
||||
});
|
||||
|
||||
this.$target.on('dblclick', '.item.active .carousel-image img', function (event) {
|
||||
var $img = $(event.currentTarget);
|
||||
var editor = new website.editor.ImageDialog();
|
||||
editor.on('start', self, function (o) {o.url = $img.attr("src");});
|
||||
editor.on('save', self, function (o) {$img.attr("src", o.url);});
|
||||
editor.appendTo($('body'));
|
||||
});
|
||||
|
||||
this.rebind_event();
|
||||
},
|
||||
// rebind event to active carousel on edit mode
|
||||
|
@ -1215,7 +1200,62 @@
|
|||
website.snippet.editorRegistry.parallax = website.snippet.editorRegistry.resize.extend({
|
||||
start : function () {
|
||||
this._super();
|
||||
this.change_background(this.$target, 'ul[name="parallax-background"]');
|
||||
this.change_background($('.parallax', this.$target), 'ul[name="parallax-background"]');
|
||||
this.scroll();
|
||||
this.change_size();
|
||||
},
|
||||
scroll: function(){
|
||||
var self = this;
|
||||
var $ul = this.$editor.find('ul[name="parallax-scroll"]');
|
||||
var $li = $ul.find("li");
|
||||
var $parallax = this.$target.find('.parallax');
|
||||
var speed = $parallax.data('stellar-background-ratio') || 0.5 ;
|
||||
|
||||
$ul.find('[data-value="' + speed + '"]').addClass('active');
|
||||
$li.on('click', function (event) {
|
||||
$li.removeClass("active");
|
||||
$(this).addClass("active");
|
||||
var speed = $(this).data('value')
|
||||
$parallax.attr('data-stellar-background-ratio', speed);
|
||||
});
|
||||
|
||||
},
|
||||
clean_for_save: function () {
|
||||
this._super();
|
||||
this.$target.find(".parallax").css("background-position", '');
|
||||
},
|
||||
change_size: function () {
|
||||
var self = this;
|
||||
var $el = $('.oe_big,.oe_medium,.oe_small', this.$target);
|
||||
|
||||
var size = 'oe_big';
|
||||
if ($el.hasClass('oe_small'))
|
||||
size = 'oe_small';
|
||||
else if ($el.hasClass('oe_medium'))
|
||||
size = 'oe_medium';
|
||||
|
||||
var $ul = this.$editor.find('ul[name="parallax-size"]');
|
||||
var $li = $ul.find("li");
|
||||
|
||||
$ul.find('[data-value="' + size + '"]').addClass('active');
|
||||
|
||||
$li.on('click', function (event) {
|
||||
$li.removeClass("active");
|
||||
$(this).addClass("active");
|
||||
})
|
||||
.on('mouseover', function (event) {
|
||||
$el.removeClass('oe_big oe_small oe_medium');
|
||||
$el.addClass($(event.currentTarget).data("value"));
|
||||
})
|
||||
.on('mouseout', function (event) {
|
||||
$el.removeClass('oe_big oe_small oe_medium');
|
||||
$el.addClass($ul.find('li.active').data("value"));
|
||||
});
|
||||
}
|
||||
});
|
||||
website.snippet.animationRegistry.parallax = website.snippet.Animation.extend({
|
||||
start: function () {
|
||||
$.stellar({ horizontalScrolling: false, verticalOffset: 0 });
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<h3 class="page-header mt16">1. Define Keywords <small>describing your page content</small></h3>
|
||||
<div class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<label for="seo_page_keywords" class="col-lg-2 control-label">Add keywords:</label>
|
||||
<label for="seo_page_keywords" class="col-lg-2 control-label">Add keyword:</label>
|
||||
<div class="col-lg-4">
|
||||
<div class="input-group">
|
||||
<input type="text" name="seo_page_keywords" class="form-control" maxlength="30"/>
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
this one:
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-sm-offset-3 oe_drop_zone_style text-center">
|
||||
<div>drop in this zone</div>
|
||||
<div class="col-sm-4 col-sm-offset-4 oe_drop_zone_style text-center">
|
||||
<span class="mt16">drop in this zone</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-muted">
|
||||
|
@ -57,25 +57,6 @@
|
|||
<div id='oe_snippets'></div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.snippet_drop_zone">
|
||||
<div class='oe_drop_zone oe_insert'>
|
||||
<div>Drag your block here (move your mouse in this zone)</div>
|
||||
<div class="oe_active">Drop your block</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.snippet_dark_for_dropzone">
|
||||
<div id="dark_for_dropzone">
|
||||
<table width="100%" height="100%">
|
||||
<tbody>
|
||||
<tr><td colspan="3"></td></tr>
|
||||
<tr><td></td><td class="center"></td><td></td></tr>
|
||||
<tr><td colspan="3"></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="website.snippet_overlay">
|
||||
<div class="oe_overlay">
|
||||
<div class="oe_overlay_options">
|
||||
|
|
|
@ -677,41 +677,40 @@
|
|||
<img class="oe_snippet_thumbnail_img" src="/website/static/src/img/blocks/block_parallax.png"/>
|
||||
<span class="oe_snippet_thumbnail_title">Parallax</span>
|
||||
</div>
|
||||
<li class="oe_snippet_options dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Size</a>
|
||||
<ul class="dropdown-menu" name="parallax-size">
|
||||
<li data-value="oe_small"><a>Small</a></li>
|
||||
<li data-value="oe_medium"><a>Medium</a></li>
|
||||
<li data-value="oe_big"><a>Big</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="oe_snippet_options dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Background</a>
|
||||
<ul class="dropdown-menu" name="parallax-background">
|
||||
<li data-value="/website/static/src/img/banner/aqua.jpg"><a>Aqua</a></li>
|
||||
<li data-value="/website/static/src/img/banner/baby_blue.jpg"><a>Baby Blue</a></li>
|
||||
<li data-value="/website/static/src/img/banner/black.jpg"><a>Black</a></li>
|
||||
<li data-value="/website/static/src/img/banner/business_guy.jpg"><a>Business Guy</a></li>
|
||||
<li data-value="/website/static/src/img/banner/color_splash.jpg"><a>Color Splash</a></li>
|
||||
<li data-value="/website/static/src/img/banner/flower_field.jpg"><a>Flowers Field</a></li>
|
||||
<li data-value="/website/static/src/img/banner/greenfields.jpg"><a>Greenfields</a></li>
|
||||
<li data-value="/website/static/src/img/banner/landscape.jpg"><a>Landscape</a></li>
|
||||
<li data-value="/website/static/src/img/banner/mango.jpg"><a>Mango</a></li>
|
||||
<li data-value="/website/static/src/img/parallax/parallax_photo1.jpg"><a>Photo Woman</a></li>
|
||||
<li data-value="/website/static/src/img/banner/mountains.jpg"><a>Mountains</a></li>
|
||||
<li data-value="/website/static/src/img/banner/orange_red.jpg"><a>Orange Red</a></li>
|
||||
<li data-value="/website/static/src/img/banner/flower.jpg"><a>Purple</a></li>
|
||||
<li data-value="/website/static/src/img/banner/velour.jpg"><a>Velour</a></li>
|
||||
<li data-value="/website/static/src/img/banner/wood.jpg"><a>Wood</a></li>
|
||||
<li data-value="/website/static/src/img/banner/yellow_green.jpg"><a>Yellow Green</a></li>
|
||||
<li class="oe_custom_bg"><a><b>Chose your picture</b></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<section class="oe_snippet_body parallax_full oe_structure" style="background-image: url('/website/static/src/img/banner/greenfields.jpg')">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12 mt128 mb32">
|
||||
<h1 class="text-center">
|
||||
<b>A Great Title</b>
|
||||
</h1>
|
||||
<h3 class="text-center">
|
||||
And a motivating subtitle
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
<li class="oe_snippet_options dropdown-submenu">
|
||||
<a tabindex="-1" href="#">Scroll Speed</a>
|
||||
<ul class="dropdown-menu" name="parallax-scroll">
|
||||
<li data-value="0"><a>Static</a></li>
|
||||
<li data-value="0.3"><a>Very Slow</a></li>
|
||||
<li data-value="0.6"><a>Slow</a></li>
|
||||
<li data-value="1"><a>Fixed</a></li>
|
||||
<li data-value="1.5"><a>Fast</a></li>
|
||||
<li data-value="2"><a>Very Fast</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<div class="oe_snippet_body" style="position:relative">
|
||||
<div class="parallax oe_structure oe_small" style="background-image: url('/website/static/src/img/parallax/parallax_photo1.jpg')" data-stellar-background-ratio="0.3">
|
||||
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-snippet-id="parallax_quote" data-selector-children=".oe_structure, [data-oe-type=html]">
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
</t>
|
||||
<t t-call="website.theme"/>
|
||||
|
||||
|
||||
<script type="text/javascript" src="/web/static/lib/es5-shim/es5-shim.min.js"></script>
|
||||
<script type="text/javascript" src="/web/static/lib/underscore/underscore.js"></script>
|
||||
<script type="text/javascript" src="/web/static/lib/underscore.string/lib/underscore.string.js"></script>
|
||||
|
@ -53,6 +54,7 @@
|
|||
<script type="text/javascript" src="/web/static/lib/qweb/qweb2.js"></script>
|
||||
<script type="text/javascript" src="/web/static/src/js/openerpframework.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/website/static/lib/stellar/jquery.stellar.js"></script>
|
||||
<script type="text/javascript" src="/website/static/src/js/website.js"></script>
|
||||
|
||||
<t t-if="editable">
|
||||
|
@ -359,7 +361,12 @@
|
|||
<div class="oe_structure">
|
||||
<h1 class="container mt32">500: Internal Server Error!</h1>
|
||||
</div>
|
||||
<pre t-if="editable" t-esc="traceback"/>
|
||||
<t t-if="editable">
|
||||
<h3>An exception appear in the template: <span id="exception_template" t-esc="template"/></h3>
|
||||
<b id="exception_message" t-esc="message"/>
|
||||
<pre id="exception_node" t-esc="node"/>
|
||||
<pre id="exception_traceback" t-esc="traceback"/>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
|
@ -455,7 +462,7 @@ Sitemap: <t t-esc="url_root"/>sitemap.xml
|
|||
<div class="oe_structure"/>
|
||||
<div class="container mb32">
|
||||
<div class="row col-wrap" id="aboutus">
|
||||
<section class="headertop needhead col-sm-12 text-center parallax_full" id="header-section" style="background-position: 50% -64px;" data-snippet-id="parallax">
|
||||
<section class="headertop needhead col-sm-12 text-center parallax" id="header-section" style="background-position: 50% -64px;" data-snippet-id="parallax">
|
||||
<header class="container">
|
||||
<div class="row-fluid">
|
||||
<div class="wrap-hero">
|
||||
|
|
|
@ -31,7 +31,7 @@ import difflib
|
|||
class BlogCategory(osv.Model):
|
||||
_name = 'blog.category'
|
||||
_description = 'Blog Category'
|
||||
_inherit = ['mail.thread']
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_order = 'name'
|
||||
|
||||
_columns = {
|
||||
|
@ -41,15 +41,13 @@ class BlogCategory(osv.Model):
|
|||
'blog.post', 'category_id',
|
||||
'Blogs',
|
||||
),
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
|
||||
|
||||
class BlogTag(osv.Model):
|
||||
_name = 'blog.tag'
|
||||
_description = 'Blog Tag'
|
||||
_inherit = ['website.seo.metadata']
|
||||
_order = 'name'
|
||||
|
||||
_columns = {
|
||||
|
@ -57,16 +55,13 @@ class BlogTag(osv.Model):
|
|||
'blog_post_ids': fields.many2many(
|
||||
'blog.post', string='Posts',
|
||||
),
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
|
||||
|
||||
class BlogPost(osv.Model):
|
||||
_name = "blog.post"
|
||||
_description = "Blog Post"
|
||||
_inherit = ['mail.thread']
|
||||
_inherit = ['mail.thread', 'website.seo.metadata']
|
||||
_order = 'write_date DESC'
|
||||
# maximum number of characters to display in summary
|
||||
_shorten_max_char = 250
|
||||
|
@ -150,9 +145,6 @@ class BlogPost(osv.Model):
|
|||
'res.users', 'Last Contributor',
|
||||
select=True, readonly=True,
|
||||
),
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
|
||||
def create_history(self, cr, uid, ids, vals, context=None):
|
||||
|
|
|
@ -32,7 +32,8 @@ class product(osv.osv):
|
|||
|
||||
|
||||
class event(osv.osv):
|
||||
_inherit = 'event.event'
|
||||
_name = 'event.event'
|
||||
_inherit = ['event.event','website.seo.metadata']
|
||||
_columns = {
|
||||
'twitter_hashtag': fields.char('Twitter Hashtag'),
|
||||
'website_published': fields.boolean('Available in the website'),
|
||||
|
@ -45,9 +46,6 @@ class event(osv.osv):
|
|||
string='Website Messages',
|
||||
help="Website communication history",
|
||||
),
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
_defaults = {
|
||||
'website_published': False,
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
import models
|
||||
import controllers
|
|
@ -47,7 +47,8 @@ class website_project(http.Controller):
|
|||
project = project_obj.browse(request.cr, request.uid, project_id, request.context)
|
||||
|
||||
render_values = {
|
||||
'project': project
|
||||
'project': project,
|
||||
'main_object': project,
|
||||
}
|
||||
return request.website.render("website_project.index", render_values)
|
||||
|
||||
|
@ -59,6 +60,7 @@ class website_project(http.Controller):
|
|||
task = task_obj.browse(cr, uid, task_id, context=context)
|
||||
|
||||
render_values = {
|
||||
'task': task
|
||||
'task': task,
|
||||
'main_object': task,
|
||||
}
|
||||
return request.website.render("website_project.task", render_values)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
import website_project
|
|
@ -0,0 +1,9 @@
|
|||
from openerp.osv import orm
|
||||
|
||||
class project(orm.Model):
|
||||
_name = 'project.project'
|
||||
_inherit = ['project.project','website.seo.metadata']
|
||||
|
||||
class task(orm.Model):
|
||||
_name = 'project.task'
|
||||
_inherit = ['project.task','website.seo.metadata']
|
|
@ -30,8 +30,9 @@ class product_pricelist(osv.Model):
|
|||
|
||||
|
||||
class product_template(osv.Model):
|
||||
_inherit = "product.template"
|
||||
_inherit = ["product.template", "website.seo.metadata"]
|
||||
_order = 'website_sequence desc, website_published, name'
|
||||
_name = 'product.template'
|
||||
|
||||
def _website_url(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
|
@ -50,9 +51,6 @@ class product_template(osv.Model):
|
|||
'website_style_ids' : fields.many2many('website.product.style','product_website_style_rel', 'product_id', 'style_id', 'Styles'),
|
||||
'website_sequence': fields.integer('Sequence', help="Determine the display order in the Website E-commerce"),
|
||||
'website_url': fields.function(_website_url, string="Website url"),
|
||||
'website_meta_title': fields.char("Website meta title", size=70, translate=True),
|
||||
'website_meta_description': fields.text("Website meta description", size=160, translate=True),
|
||||
'website_meta_keywords': fields.char("Website meta keywords", translate=True),
|
||||
}
|
||||
_defaults = {
|
||||
'website_size_x': 1,
|
||||
|
|
|
@ -29,14 +29,25 @@ class attributes(osv.Model):
|
|||
result.update(dict(cr.fetchall()))
|
||||
return result
|
||||
|
||||
def _get_min_max(self, cr, uid, ids, context=None):
|
||||
result = {}
|
||||
for value in self.pool.get('product.attribute.product').browse(cr, uid, ids, context=context):
|
||||
if value.type == 'float':
|
||||
result[value.attribute_id.id] = True
|
||||
return result.keys()
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=64, translate=True, required=True),
|
||||
'type': fields.selection([('distinct', 'Distinct'), ('float', 'Float')], "Type", required=True),
|
||||
'value_ids': fields.one2many('product.attribute.value', 'attribute_id', 'Values'),
|
||||
'product_ids': fields.one2many('product.attribute.product', 'attribute_id', 'Products'),
|
||||
|
||||
'float_max': fields.function(_get_float_max, type='float', string="Max", relation='product.attribute.product',store=True),
|
||||
'float_min': fields.function(_get_float_min, type='float', string="Min", relation='product.attribute.product',store=True),
|
||||
'float_max': fields.function(_get_float_max, type='float', string="Max", store={
|
||||
'product.attribute.product': (_get_min_max, ['value','attribute_id'], 20),
|
||||
}),
|
||||
'float_min': fields.function(_get_float_min, type='float', string="Min", store={
|
||||
'product.attribute.product': (_get_min_max, ['value','attribute_id'], 20),
|
||||
}),
|
||||
}
|
||||
_defaults = {
|
||||
'type': 'distinct'
|
||||
|
|
Loading…
Reference in New Issue