Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Commit

Permalink
A long dump of changes (had to develop behind a curtain for various r…
Browse files Browse the repository at this point in the history
…easons, and failed to do the right thing re: small pushes). Things brings the source up to parity with the dropmocks.com web service.
  • Loading branch information
glenmurphy committed Jan 13, 2011
1 parent 56140b1 commit b63c97a
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 108 deletions.
Empty file removed files/__init__.py
Empty file.
Binary file modified files/delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion files/editor.css
Expand Up @@ -24,7 +24,7 @@
}
.dm-editor .listname {
cursor:pointer;
width:180px;
width:164px;
}
.title .delete {
position:absolute;
Expand All @@ -43,6 +43,23 @@
.title .delete:hover {
background-position:-16 -16;
}
.title .minimize {
position:absolute;
right:24px;
top:50%;
margin-top:-8px;
display:inline;
background-image:url(/s/delete.png);
background-position:-32 0;
background-repeat:no-repeat;
overflow:hidden;
width:16px;
height:16px;
cursor:pointer;
}
.title .minimize:hover {
background-position:-32 -16;
}
.dm-editor .listname:hover {
background-color:#fff9c2;
}
Expand Down
14 changes: 10 additions & 4 deletions files/editor.js
Expand Up @@ -11,12 +11,19 @@ function Editor(mocklist) {

var delete_button = createElement('div', 'delete', this.node_title_);
addEventListener(delete_button, 'click', this.titleDeleteClicked_.bind(this));
var minimize_button = createElement('div', 'minimize', this.node_title_);
addEventListener(minimize_button, 'click', this.titleClicked_.bind(this));

addEventListener(this.node_name_, 'click', this.nameClicked_.bind(this));
this.node_body_ = createElement('div', 'body', this.node_);
this.node_filelist_ = createElement('div', 'filelist', this.node_body_);

this.node_insert_ = createElement('div', 'insert-indicator', this.node_);

this.node_access_url_ = createElement('div', 'access-url', this.node_body_);
this.node_access_url_.style.display = 'none';
//this.node_hider_ = createElement('div', 'hider', this.node_body_);
//setText(this.node_hider_, "Hide editor");

// Sometimes we have to do things (such as get a mocklist id and key)
// before we can send the file.
Expand All @@ -40,7 +47,7 @@ function Editor(mocklist) {
}

this.node_status_ = createElement('div', 'dm-editor-status hidden', document.body);

addEventListener(document.body, 'dragover', this.dragOver_.bind(this));
addEventListener(document.body, 'dragenter', this.dragEnter_.bind(this));
addEventListener(document.body, 'dragleave', this.dragLeave_.bind(this));
Expand Down Expand Up @@ -340,9 +347,8 @@ Editor.prototype.fileDropped = function(e) {
}

Editor.prototype.showAccessURL_ = function(url) {
if (!this.node_access_url_)
this.node_access_url_ = createElement('div', 'access-url', this.node_body_);

this.node_access_url_.style.display = 'block';

//var full_url = window.location.protocol + '//' + window.location.host + url
var full_url = 'http://dropmocks.com' + url;
this.node_access_url_.innerHTML = 'Share this URL: <a href="' + full_url + '">' + full_url + '</a>';
Expand Down
10 changes: 9 additions & 1 deletion files/functions.js
Expand Up @@ -14,12 +14,20 @@ Function.prototype.bind = function(thisObj, var_args) {

function createElement(type, className, parent) {
var el = document.createElement(type);
document.
el.className = className;
if (parent) parent.appendChild(el);
return el;
}

function getPosition(obj) {
var pos = {x : 0, y : 0}
do {
pos.x += obj.offsetLeft;
pos.y += obj.offsetTop;
} while (obj = obj.offsetParent);
return pos;
}

function min(a, b) { return (a < b) ? a : b; }
if (!('console' in window)) {
window.console = [];
Expand Down
83 changes: 69 additions & 14 deletions files/menu.css
@@ -1,7 +1,6 @@

.home {
position:absolute;
bottom:1px;
top:1px;
right:0px;
padding:5px;
z-index:10000;
Expand All @@ -10,8 +9,40 @@
.home .menuitem {
margin-left:12px;
}
.home .menulink {
display:inline-block;
cursor:pointer;
margin-left:12px;
color:#999;
}

.leftbar {
position:absolute;
top:1px;
left:0px;
padding:5px;
z-index:10000;
-webkit-transition:all 0.2s;
}
.rightbar {
position:absolute;
top:1px;
right:0px;
padding:5px;
z-index:1;
-webkit-transition:all 0.2s;
}
.leftbar .menuitem {
margin-right:9px;
}
.leftbar .menulink {
display:inline-block;
cursor:pointer;
margin-right:12px;
color:#999;
}

.home .button {
.button {
background: #75B5F4;
background: -moz-linear-gradient(top, #75B5F4 0%, #5BA3EA 44%, #3A89D8 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#75B5F4), color-stop(44%,#5BA3EA), color-stop(100%,#3A89D8)); /* webkit */
Expand All @@ -35,9 +66,10 @@
cursor:pointer;
text-decoration:none;
display:inline-block;
color:white;
}

.home .button:hover {
.button:hover {
background: #7ABEFF; /* old browsers */
background: -moz-linear-gradient(top, #7ABEFF 0%, #5BA3EA 44%, #3884D1 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#7ABEFF), color-stop(44%,#5BA3EA), color-stop(100%,#3884D1)); /* webkit */
Expand All @@ -49,7 +81,7 @@
-webkit-box-shadow: inset 0 1px 0 0 #7abdff, 0px 1px 2px rgba(0,0,0,0.3);;
}

.home .button:active {
.button:active {
background: #75B5F4;
background: -moz-linear-gradient(top, #75B5F4 0%, #5BA3EA 44%, #3A89D8 100%); /* firefox */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#75B5F4), color-stop(44%,#5BA3EA), color-stop(100%,#3A89D8)); /* webkit */
Expand All @@ -62,16 +94,39 @@
-webkit-box-shadow: inset 1px 1px 1px 1px rgba(0, 0, 0, 0.1);
}

.sharebar {
.list {
display:block;
position:absolute;
bottom:1px;
left:0px;
padding:5px;
z-index:10000;
-webkit-transition:all 0.2s;
border:1px solid black;
z-index:2000;
background-color:white;
font-family:helvetica, arial, sans-serif;
font-size:12px;
border:1px solid rgba(0,0,0,0.5);
padding:3px 6px 3px 8px;
margin-top:2px;
margin-left:-9px;
-webkit-box-shadow:1px 1px 4px rgba(0, 0, 0, 0.3);
-webkit-transition:-webkit-transform 0.2s, opacity 0.2s;
line-height:23px;
min-width:160px;
}
.list.hidden {
-webkit-transform:translate(0px, -5px);
opacity:0;
pointer-events:none;
}

.sharebar div {
display:inline-block;
margin-right:12px;
.listitem {
display:block;
text-decoration:none;
color:#666;
}
.listitem.selected {
font-weight:bold;
color:black;
}
.listitem:hover {
color:black;
text-decoration:underline;
}
65 changes: 41 additions & 24 deletions files/menu.js
@@ -1,6 +1,6 @@
function Menu(mocklist, user) {
this.page_mocklist_ = mocklist;
this.page_mocklist_.addListener(this.mockListListener_.bind(this));
this.page_mocklist_.addListener(this.mockListListener_.bind(this), false);
this.signed_in_ = user.signed_in;

// Doesn't contain valid mocklist data, just id and name.
Expand All @@ -12,41 +12,50 @@ function Menu(mocklist, user) {
// Edit controls (right side).
this.node_ = createElement('div', 'home', document.body);

this.node_new_ = createElement('a', 'menuitem', this.node_);
this.node_new_.href = '/';

this.node_menu_ = createElement('select', 'menuitem', this.node_);
/*
var opt = new Option("Your mocks:", "", false, false);
this.node_menu_.options[this.node_menu_.length] = opt;
addEventListener(this.node_menu_, 'change', this.menuChanged_.bind(this));
*/

this.node_left_ = createElement('div', 'leftbar', document.body);
this.node_right_ = createElement('div', 'rightbar', document.body);

this.node_new_ = createElement('a', 'menuitem', this.node_left_);
this.node_new_.href = '/';

if (this.signed_in_) {
this.node_name_ = createElement('a', 'menuitem', this.node_);
setText(this.node_name_, this.username_);

this.node_sign_ = createElement('a', 'menuitem', this.node_);
this.node_sign_ = createElement('a', 'menulink', this.node_left_);
this.node_sign_.href = this.sign_out_url_;
setText(this.node_sign_, "Sign out");
} else {
this.node_sign_ = createElement('a', 'menuitem button', this.node_);
this.node_sign_ = createElement('a', 'menulink', this.node_left_);
this.node_sign_.href = this.sign_in_url_;

this.node_new_.className = 'menuitem button';
setText(this.node_sign_, "Sign in");
}
}

this.node_menu_ = new MenuMocks('Your mocks', this.node_left_);

// Sharing bar (left side).
this.node_share_ = createElement('div', 'sharebar', document.body);
//this.node_about_ = createElement('a', 'menulink', this.node_left_);
//setText(this.node_about_, 'About');
// this.node_about_.href = '#';
//this.node_about_.addEventListener("click", this.handleAbout_.bind(this), false);


this.node_tweet_ = createElement('div', '', this.node_share_);
this.node_tweet_ = createElement('div', 'menuitem', this.node_right_);
this.node_tweet_.innerHTML = '<a href="http://twitter.com/share" class="twitter-share-button" data-text="I liked this gallery on dropmocks:" data-count="none">Share on Twitter</a>';

var twitter_script = document.createElement('script');
twitter_script.async = true;
twitter_script.src = 'http://platform.twitter.com/widgets.js';
twitter_script.defer = true;
this.node_share_.appendChild(twitter_script);

this.node_right_.appendChild(twitter_script);
this.update_();
}

Expand All @@ -68,6 +77,10 @@ Menu.prototype.mockListListener_ = function(e) {
}
}

Menu.prototype.handleAbout_ = function(e) {
e.preventDefault();
}

Menu.prototype.getMockListById = function(id) {
for (var i = 0, mocklist; mocklist = this.mocklists_[i]; i++) {
if (mocklist.id == id) {
Expand All @@ -78,10 +91,9 @@ Menu.prototype.getMockListById = function(id) {
}

Menu.prototype.update_ = function() {
window.console.log("Menu updating");

this.node_new_.style.display = (this.page_mocklist_.id) ? 'inline-block' : 'none';
this.node_share_.style.display = (this.page_mocklist_.id) ? 'block' : 'none';
//this.node_left_.style.display = (this.page_mocklist_.id) ? 'block' : 'none';
this.node_right_.style.display = (this.page_mocklist_.key || !this.page_mocklist_.id) ? 'none' : 'block';

if (this.signed_in_ || this.page_mocklist_.key) {
setText(this.node_new_, 'New');
Expand All @@ -91,20 +103,25 @@ Menu.prototype.update_ = function() {
// this.node_sign_.style.display = 'none';
}

this.node_menu_.options.length = 1;
for (var i = 0, mocklist; mocklist = this.mocklists_[i]; i++) {
var selected = (mocklist.id == this.page_mocklist_.id);
var name = mocklist.name ? mocklist.name : mocklist.id;
var opt = new Option(name, mocklist.id, selected, selected);
this.node_menu_.options[this.node_menu_.length] = opt;
this.node_menu_.clearItems();
if (this.mocklists_.length == 0) {
this.node_menu_.setVisible(false);
} else {
for (var i = 0, mocklist; mocklist = this.mocklists_[i]; i++) {
var selected = (mocklist.id == this.page_mocklist_.id);
var name = mocklist.name ? mocklist.name : mocklist.id;
this.node_menu_.addItem(name, '/m' + mocklist.id, selected);
}
this.node_menu_.setVisible(true);
}

// this.node_menu_.style.display = (this.mocklists_.length) ? 'inline-block' : 'none';
}

/*
Menu.prototype.menuChanged_ = function() {
var v = this.node_menu_.value;
if (v) {
window.location.href = MockList.URL_VIEWER_BASE + v;
}
}
}
*/

0 comments on commit b63c97a

Please sign in to comment.