Skip to content

Commit

Permalink
App.Utils.Iterator ajout�
Browse files Browse the repository at this point in the history
  • Loading branch information
Daome committed Feb 19, 2012
1 parent d0043f1 commit 10a9ac3
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 55 deletions.
8 changes: 5 additions & 3 deletions css/index.css
Expand Up @@ -53,22 +53,24 @@ span.tip{
margin-left:auto;
margin-right:auto;
width:90%;
text-align: center;
}
.nav{
width:160px;
}
.nav button:hover{
.nav input[type=button]:hover{
background:#BBB;
}
.nav button:active{
.nav input[type=button]:active{
background:#888;
color:#EEE;
}
.nav button{
.nav input[type=button]{
display:inline-block;
background:#EEE;
border:1px solid #AAA;
width:150px;
height:20px;
}

canvas{
Expand Down
12 changes: 9 additions & 3 deletions css/messagebox.css
@@ -1,5 +1,4 @@
.messagebox.background{
visibility:hidden;
position: fixed;
top:0;
left:0;
Expand All @@ -8,6 +7,11 @@
background: url('../img/messageboxbackground.png');
z-index: 1000;
display: block;
-webkit-transition:all 1s;
-moz-transition:all 1s;
-o-transition:all 1s;
-ms-transition:all 1s;
transition:all 1s;
}
.messagebox .box{
position:relative;
Expand All @@ -27,10 +31,12 @@
.messagebox .box .inner{

overflow:auto;
top:25%;
height:50%;
top:15%;
height:75%;
z-index: 1003;
background: #FFF;
border-radius:10px;
padding:15px:


}
45 changes: 1 addition & 44 deletions index.html
Expand Up @@ -53,53 +53,10 @@ <h3>Color picker</h3>
</div>
<div style='clear:both;'>Designed by M.PARAISO</div>
</div>
<div class="messagebox background">
<div class="messagebox background" id='thickbox' style='visibility:hidden;opacity:0'>
<div class="box">
<div class="outer">
<div class="messagebox box inner">
this is a message box with many elements
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</div>

</div>
Expand Down
54 changes: 52 additions & 2 deletions js/faviconbuilder.coffee
Expand Up @@ -94,6 +94,49 @@ class App.Utils.DefaultMenu
{label:"thickbox test",action:"showthickbox",title:"Show thick box , just a javascript CSS test , no special functionalities"}
]

###
class App.Utils.Iterator extends Array
constructor:->
@push i for i in arguments
@iter = 0
next:->
@[++@iter] if @iter < @length-1
previous:->
@[--@iter] if @iter>0
hasNext:->
if @[@iter+1]
true
else
false
hasPrevious:->
if @[@iter-1]
true
else
false
###


App.Utils.Iterator = do->
Iterator = ->
array = Array.apply(this,arguments)
iter = 0
return {
getArray:->
array
getValue:->
array[iter]
next:->
array[++iter] if iter < array.length-1
previous:->
array[--iter] if iter>0
hasNext:->
return if array[iter+1] then true else return false
hasPrevious:->
return if array[iter-1]then true else return false
}

return Iterator

### MODELS ###
class App.Models.Color
constructor:(@title="Eraser",@color=null,@alpha=1)->
Expand Down Expand Up @@ -312,8 +355,10 @@ class App.Views.Menu
render:->
@model.targetId.innerHTML = ""
for i in [0...@model.items.length]
button = document.createElement("button")
button.innerText = @model.items[i].label
button = document.createElement("input")
#button.innerText = @model.items[i].label
button.setAttribute("value",@model.items[i].label)
button.setAttribute("type","button")
button.setAttribute("id",@model.items[i].action)
button.setAttribute("title",@model.items[i].title)
button.dataset?= {}
Expand All @@ -336,6 +381,7 @@ class App.Controllers.Application
class Main
constructor:->
version = 0.1
@thickbox = document.getElementById("thickbox")
$target = document.getElementById("target")
$canvasPreview = document.getElementById("canvasPreview")
$colorSelector = document.getElementById("colorSelector")
Expand Down Expand Up @@ -428,5 +474,9 @@ class Main
@updateViews()
showThickbox:(e)=>
console.log e,"show thickbox"
@thickbox.style.visibility = if @thickbox.style.visibility == "hidden" then "visible" else "hidden"
@thickbox.style.opacity = if parseInt(@thickbox.style.opacity)<1 then 1 else 0
@thickbox.onclick= (e)=>
@showThickbox(e)
window?.onload = ->
window?.main = new Main()
73 changes: 70 additions & 3 deletions js/faviconbuilder.js
Expand Up @@ -165,6 +165,65 @@ App.Utils.DefaultMenu = (function() {

})();

/*
class App.Utils.Iterator extends Array
constructor:->
@push i for i in arguments
@iter = 0
next:->
@[++@iter] if @iter < @length-1
previous:->
@[--@iter] if @iter>0
hasNext:->
if @[@iter+1]
true
else
false
hasPrevious:->
if @[@iter-1]
true
else
false
*/

App.Utils.Iterator = (function() {
var Iterator;
Iterator = function() {
var array, iter;
array = Array.apply(this, arguments);
iter = 0;
return {
getArray: function() {
return array;
},
getValue: function() {
return array[iter];
},
next: function() {
if (iter < array.length - 1) return array[++iter];
},
previous: function() {
if (iter > 0) return array[--iter];
},
hasNext: function() {
if (array[iter + 1]) {
return true;
} else {
return false;
}
},
hasPrevious: function() {
if (array[iter - 1]) {
return true;
} else {
return false;
}
}
};
};
return Iterator;
})();

/* MODELS
*/

Expand Down Expand Up @@ -626,8 +685,9 @@ App.Views.Menu = (function() {
_this = this;
this.model.targetId.innerHTML = "";
for (i = 0, _ref = this.model.items.length; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {
button = document.createElement("button");
button.innerText = this.model.items[i].label;
button = document.createElement("input");
button.setAttribute("value", this.model.items[i].label);
button.setAttribute("type", "button");
button.setAttribute("id", this.model.items[i].action);
button.setAttribute("title", this.model.items[i].title);
if (button.dataset == null) button.dataset = {};
Expand Down Expand Up @@ -683,6 +743,7 @@ Main = (function() {
this.clickcell = __bind(this.clickcell, this);
var $canvasPreview, $colorSelector, $factorSelector, $menu, $target, $title, defaultColor, title, version;
version = 0.1;
this.thickbox = document.getElementById("thickbox");
$target = document.getElementById("target");
$canvasPreview = document.getElementById("canvasPreview");
$colorSelector = document.getElementById("colorSelector");
Expand Down Expand Up @@ -803,7 +864,13 @@ Main = (function() {
};

Main.prototype.showThickbox = function(e) {
return console.log(e, "show thickbox");
var _this = this;
console.log(e, "show thickbox");
this.thickbox.style.visibility = this.thickbox.style.visibility === "hidden" ? "visible" : "hidden";
this.thickbox.style.opacity = parseInt(this.thickbox.style.opacity) < 1 ? 1 : 0;
return this.thickbox.onclick = function(e) {
return _this.showThickbox(e);
};
};

return Main;
Expand Down

0 comments on commit 10a9ac3

Please sign in to comment.