Added Polymer
This commit is contained in:
14
rpg-docs/public/bower_components/core-drag-drop/.bower.json
vendored
Normal file
14
rpg-docs/public/bower_components/core-drag-drop/.bower.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "core-drag-drop",
|
||||
"homepage": "https://github.com/Polymer/core-drag-drop",
|
||||
"version": "0.5.1",
|
||||
"_release": "0.5.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.5.1",
|
||||
"commit": "fb7c56b9db2ee1aed88d3f73f7074c92b1f252df"
|
||||
},
|
||||
"_source": "git://github.com/Polymer/core-drag-drop.git",
|
||||
"_target": "^0.5.0",
|
||||
"_originalSource": "Polymer/core-drag-drop"
|
||||
}
|
||||
114
rpg-docs/public/bower_components/core-drag-drop/core-drag-drop.html
vendored
Normal file
114
rpg-docs/public/bower_components/core-drag-drop/core-drag-drop.html
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
|
||||
<style>
|
||||
core-drag-avatar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
display: block;
|
||||
pointer-events: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!--
|
||||
@group Polymer Core Elements
|
||||
@element core-drag-drop
|
||||
@homepage github.io
|
||||
-->
|
||||
|
||||
<polymer-element name="core-drag-drop">
|
||||
<script>
|
||||
(function() {
|
||||
var avatar;
|
||||
|
||||
Polymer('core-drag-drop', {
|
||||
|
||||
observe: {
|
||||
'x y': 'coordinatesChanged'
|
||||
},
|
||||
|
||||
ready: function() {
|
||||
if (!avatar) {
|
||||
avatar = document.createElement('core-drag-avatar');
|
||||
document.body.appendChild(avatar);
|
||||
}
|
||||
this.avatar = avatar;
|
||||
this.dragging = false;
|
||||
},
|
||||
|
||||
draggingChanged: function() {
|
||||
this.avatar.style.display = this.dragging ? '' : 'none';
|
||||
},
|
||||
|
||||
coordinatesChanged: function() {
|
||||
var x = this.x, y = this.y;
|
||||
this.avatar.style.transform =
|
||||
this.avatar.style.webkitTransform =
|
||||
'translate(' + x + 'px, ' + y + 'px)';
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
var listen = function(event, handler) {
|
||||
Polymer.addEventListener(this.parentNode, event, this[handler].bind(this));
|
||||
}.bind(this);
|
||||
//
|
||||
listen('trackstart', 'trackStart');
|
||||
listen('track', 'track');
|
||||
listen('trackend', 'trackEnd');
|
||||
//
|
||||
var host = this.parentNode.host || this.parentNode;
|
||||
host.style.cssText += '; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;';
|
||||
},
|
||||
|
||||
trackStart: function(event) {
|
||||
this.avatar.style.cssText = '';
|
||||
this.dragInfo = {
|
||||
event: event,
|
||||
avatar: this.avatar
|
||||
};
|
||||
this.fire('drag-start', this.dragInfo);
|
||||
// flaw #1: what if user doesn't need `drag()`?
|
||||
this.dragging = Boolean(this.dragInfo.drag);
|
||||
},
|
||||
|
||||
track: function(event) {
|
||||
if (this.dragging) {
|
||||
this.x = event.pageX;
|
||||
this.y = event.pageY;
|
||||
this.dragInfo.event = event;
|
||||
this.dragInfo.p = {x : this.x, y: this.y};
|
||||
this.dragInfo.drag(this.dragInfo);
|
||||
}
|
||||
},
|
||||
|
||||
trackEnd: function(event) {
|
||||
if (this.dragging) {
|
||||
this.dragging = false;
|
||||
if (this.dragInfo.drop) {
|
||||
this.dragInfo.framed = this.framed(event.relatedTarget);
|
||||
this.dragInfo.event = event;
|
||||
this.dragInfo.drop(this.dragInfo);
|
||||
}
|
||||
}
|
||||
this.dragInfo = null;
|
||||
},
|
||||
|
||||
framed: function(node) {
|
||||
var local = node.getBoundingClientRect();
|
||||
return {x: this.x - local.left, y: this.y - local.top};
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
</polymer-element>
|
||||
102
rpg-docs/public/bower_components/core-drag-drop/demo.html
vendored
Normal file
102
rpg-docs/public/bower_components/core-drag-drop/demo.html
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no">
|
||||
|
||||
<title>Core Drag Drop</title>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
|
||||
<link rel="import" href="core-drag-drop.html">
|
||||
|
||||
<style>
|
||||
|
||||
html {
|
||||
font-family: 'Helvetica Neue', 'Roboto', 'Arial', sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
.box {
|
||||
display: inline-block;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
margin: 16px;
|
||||
}
|
||||
|
||||
.dropped {
|
||||
position: absolute;
|
||||
border: 1px solid black;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<div style="border: 1px dotted silver;">
|
||||
|
||||
<core-drag-drop></core-drag-drop>
|
||||
|
||||
<div class="box" style="background-color: lightblue;" draggable="false"></div>
|
||||
|
||||
<div class="box" style="background-color: orange;" draggable="false"></div>
|
||||
|
||||
<div class="box" style="background-color: lightgreen;" draggable="false"></div>
|
||||
|
||||
<div id="hello">Hello World</div>
|
||||
|
||||
</div>
|
||||
|
||||
<br><br><br><br><br><br>
|
||||
|
||||
<div id="drop" class="box" style="border: 3px solid silver; position: relative; width: 300px; height: 300px;" draggable="false"></div>
|
||||
|
||||
<script>
|
||||
addEventListener('drag-start', function(e) {
|
||||
var dragInfo = e.detail;
|
||||
// flaw #2: e vs dragInfo.event
|
||||
var color = dragInfo.event.target.style.backgroundColor;
|
||||
dragInfo.avatar.style.cssText = 'border: 3px solid ' + color + '; width: 32px; height: 32px; border-radius: 32px; background-color: whitesmoke';
|
||||
e.detail.avatar.appendChild(document.querySelector('#hello'));
|
||||
dragInfo.drag = function() {};
|
||||
dragInfo.drop = drop;
|
||||
});
|
||||
//
|
||||
function drop(dragInfo) {
|
||||
var color = dragInfo.avatar.style.borderColor;
|
||||
var dropTarget = dragInfo.event.relatedTarget;
|
||||
if (color && dropTarget.id === 'drop') {
|
||||
var f = dragInfo.framed;
|
||||
var d = document.createElement('div');
|
||||
d.className = 'dropped';
|
||||
d.style.left = f.x - 4 + 'px';
|
||||
d.style.top = f.y - 4 + 'px';
|
||||
d.style.backgroundColor = color;
|
||||
dropTarget.appendChild(d);
|
||||
dropTarget.style.backgroundColor = color;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
rpg-docs/public/bower_components/core-drag-drop/index.html
vendored
Normal file
22
rpg-docs/public/bower_components/core-drag-drop/index.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
<link rel="import" href="../core-component-page/core-component-page.html">
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<core-component-page></core-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user