wordpress-starter 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -1
- data/README.md +12 -0
- data/lib/wordpress-starter.rb +2 -1
- data/templates/bootstrap/404.php +24 -0
- data/templates/bootstrap/admin/README.txt +25 -0
- data/templates/bootstrap/admin/assets/css/admin-style.css +838 -0
- data/templates/bootstrap/admin/assets/css/colorpicker.css +177 -0
- data/templates/bootstrap/admin/assets/images/1col.png +0 -0
- data/templates/bootstrap/admin/assets/images/2-col-portfolio.png +0 -0
- data/templates/bootstrap/admin/assets/images/2cl.png +0 -0
- data/templates/bootstrap/admin/assets/images/2cr.png +0 -0
- data/templates/bootstrap/admin/assets/images/3-col-portfolio.png +0 -0
- data/templates/bootstrap/admin/assets/images/3cm.png +0 -0
- data/templates/bootstrap/admin/assets/images/3cr.png +0 -0
- data/templates/bootstrap/admin/assets/images/4-col-portfolio.png +0 -0
- data/templates/bootstrap/admin/assets/images/accept.png +0 -0
- data/templates/bootstrap/admin/assets/images/button_check.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/blank.gif +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_background.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hex.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_b.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_h.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_hsb_s.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_indic.gif +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_overlay.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_b.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_g.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_rgb_r.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_select.gif +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/colorpicker_submit.png +0 -0
- data/templates/bootstrap/admin/assets/images/colorpicker/select.png +0 -0
- data/templates/bootstrap/admin/assets/images/dropdown-arrow.png +0 -0
- data/templates/bootstrap/admin/assets/images/favicon.ico +0 -0
- data/templates/bootstrap/admin/assets/images/icon-add.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-backup.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-delete.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-docs.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-edit.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-home.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-info.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-notice.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-paint.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-settings.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-slider.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon-warn.png +0 -0
- data/templates/bootstrap/admin/assets/images/icon_option.png +0 -0
- data/templates/bootstrap/admin/assets/images/loading-bottom.gif +0 -0
- data/templates/bootstrap/admin/assets/images/select.png +0 -0
- data/templates/bootstrap/admin/assets/images/sign_warning.png +0 -0
- data/templates/bootstrap/admin/assets/images/stop.png +0 -0
- data/templates/bootstrap/admin/assets/images/toggle_tabs.png +0 -0
- data/templates/bootstrap/admin/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/templates/bootstrap/admin/assets/images/warning.png +0 -0
- data/templates/bootstrap/admin/assets/images/wrench.png +0 -0
- data/templates/bootstrap/admin/assets/images/wrench16.png +0 -0
- data/templates/bootstrap/admin/assets/js/ajaxupload.js +606 -0
- data/templates/bootstrap/admin/assets/js/colorpicker.js +455 -0
- data/templates/bootstrap/admin/assets/js/cookie.js +1 -0
- data/templates/bootstrap/admin/assets/js/jquery.maskedinput-1.2.2.js +252 -0
- data/templates/bootstrap/admin/assets/js/jquery.tipsy.js +241 -0
- data/templates/bootstrap/admin/assets/js/of-medialibrary-uploader.js +168 -0
- data/templates/bootstrap/admin/assets/js/smof.js +623 -0
- data/templates/bootstrap/admin/classes/class.options-machine.php +627 -0
- data/templates/bootstrap/admin/front-end/options.php +77 -0
- data/templates/bootstrap/admin/functions/functions.admin.php +76 -0
- data/templates/bootstrap/admin/functions/functions.interface.php +232 -0
- data/templates/bootstrap/admin/functions/functions.load.php +14 -0
- data/templates/bootstrap/admin/functions/functions.mediauploader.php +194 -0
- data/templates/bootstrap/admin/functions/functions.options.php +508 -0
- data/templates/bootstrap/admin/functions/functions.php +0 -0
- data/templates/bootstrap/admin/index.php +87 -0
- data/templates/bootstrap/admin/layouts/default.css +0 -0
- data/templates/bootstrap/admin/layouts/placebo.css +0 -0
- data/templates/bootstrap/archive.php +57 -0
- data/templates/bootstrap/category.php +40 -0
- data/templates/bootstrap/comments.php +65 -0
- data/templates/bootstrap/content-aside.php +26 -0
- data/templates/bootstrap/content-image.php +29 -0
- data/templates/bootstrap/content-link.php +27 -0
- data/templates/bootstrap/content-none.php +21 -0
- data/templates/bootstrap/content-page.php +24 -0
- data/templates/bootstrap/content-quote.php +26 -0
- data/templates/bootstrap/content-status.php +33 -0
- data/templates/bootstrap/content.php +67 -0
- data/templates/bootstrap/editor-style.scss +72 -0
- data/templates/bootstrap/footer.php +29 -0
- data/templates/bootstrap/functions.php +1528 -0
- data/templates/bootstrap/header.php +74 -0
- data/templates/bootstrap/ie.scss +1 -0
- data/templates/bootstrap/images/bg/bg0.png +0 -0
- data/templates/bootstrap/images/bg/bg1.png +0 -0
- data/templates/bootstrap/images/bg/bg10.png +0 -0
- data/templates/bootstrap/images/bg/bg11.png +0 -0
- data/templates/bootstrap/images/bg/bg2.png +0 -0
- data/templates/bootstrap/images/bg/bg3.png +0 -0
- data/templates/bootstrap/images/bg/bg4.png +0 -0
- data/templates/bootstrap/images/bg/bg5.png +0 -0
- data/templates/bootstrap/images/bg/bg6.jpg +0 -0
- data/templates/bootstrap/images/bg/bg7.jpg +0 -0
- data/templates/bootstrap/images/bg/bg8.png +0 -0
- data/templates/bootstrap/images/bg/bg9.png +0 -0
- data/templates/bootstrap/images/glyphicons-halflings-white.png +0 -0
- data/templates/bootstrap/images/glyphicons-halflings.png +0 -0
- data/templates/bootstrap/index.php +19 -0
- data/templates/bootstrap/javascripts/app.js +6 -0
- data/templates/bootstrap/javascripts/bootstrap.js +2159 -0
- data/templates/bootstrap/javascripts/bootstrap.min.js +6 -0
- data/templates/{project/javascripts/moderninzr.min.js → bootstrap/javascripts/modernizr.min.js} +0 -0
- data/templates/bootstrap/languages/readme.txt +6 -0
- data/templates/bootstrap/license.txt +281 -0
- data/templates/bootstrap/loop.php +30 -0
- data/templates/bootstrap/manifest.rb +156 -0
- data/templates/bootstrap/options.php +42 -0
- data/templates/bootstrap/page.php +29 -0
- data/templates/bootstrap/print.scss +104 -0
- data/templates/bootstrap/readme.txt +6 -0
- data/templates/bootstrap/sass/_app.scss +10 -0
- data/templates/bootstrap/sass/_settings.scss +301 -0
- data/templates/bootstrap/screen.scss +1 -0
- data/templates/bootstrap/screenshot.png +0 -0
- data/templates/bootstrap/search.php +31 -0
- data/templates/bootstrap/searchform.php +31 -0
- data/templates/bootstrap/sidebar.php +15 -0
- data/templates/bootstrap/single.php +31 -0
- data/templates/bootstrap/style.css +18 -0
- data/templates/bootstrap/tag.php +41 -0
- data/templates/foundation/functions.php +8 -9
- data/templates/foundation/sass/_app.scss +2 -0
- data/templates/project/functions.php +1 -1
- data/templates/project/javascripts/app.js +2 -5
- data/templates/project/javascripts/modernizr.min.js +4 -0
- data/templates/project/manifest.rb +1 -1
- metadata +141 -2
@@ -0,0 +1,177 @@
|
|
1
|
+
.colorpicker {
|
2
|
+
width: 356px;
|
3
|
+
height: 176px;
|
4
|
+
overflow: hidden;
|
5
|
+
position: absolute;
|
6
|
+
background: url(../images/colorpicker/colorpicker_background.png);
|
7
|
+
font-family: Arial, Helvetica, sans-serif;
|
8
|
+
display: none;
|
9
|
+
}
|
10
|
+
.colorpicker_color {
|
11
|
+
width: 150px;
|
12
|
+
height: 150px;
|
13
|
+
left: 14px;
|
14
|
+
top: 13px;
|
15
|
+
position: absolute;
|
16
|
+
background: #f00;
|
17
|
+
overflow: hidden;
|
18
|
+
cursor: crosshair;
|
19
|
+
}
|
20
|
+
.colorpicker_color div {
|
21
|
+
position: absolute;
|
22
|
+
top: 0;
|
23
|
+
left: 0;
|
24
|
+
width: 150px;
|
25
|
+
height: 150px;
|
26
|
+
background: url(../images/colorpicker/colorpicker_overlay.png);
|
27
|
+
}
|
28
|
+
.colorpicker_color div div {
|
29
|
+
position: absolute;
|
30
|
+
top: 0;
|
31
|
+
left: 0;
|
32
|
+
width: 11px;
|
33
|
+
height: 11px;
|
34
|
+
overflow: hidden;
|
35
|
+
background: url(../images/colorpicker/colorpicker_select.gif);
|
36
|
+
margin: -5px 0 0 -5px;
|
37
|
+
}
|
38
|
+
.colorpicker_hue {
|
39
|
+
position: absolute;
|
40
|
+
top: 13px;
|
41
|
+
left: 171px;
|
42
|
+
width: 35px;
|
43
|
+
height: 150px;
|
44
|
+
cursor: n-resize;
|
45
|
+
}
|
46
|
+
.colorpicker_hue div {
|
47
|
+
position: absolute;
|
48
|
+
width: 35px;
|
49
|
+
height: 9px;
|
50
|
+
overflow: hidden;
|
51
|
+
background: url(../images/colorpicker/colorpicker_indic.gif) left top;
|
52
|
+
margin: -4px 0 0 0;
|
53
|
+
left: 0px;
|
54
|
+
}
|
55
|
+
.colorpicker_new_color {
|
56
|
+
position: absolute;
|
57
|
+
width: 60px;
|
58
|
+
height: 30px;
|
59
|
+
left: 213px;
|
60
|
+
top: 13px;
|
61
|
+
background: #f00;
|
62
|
+
}
|
63
|
+
.colorpicker_current_color {
|
64
|
+
position: absolute;
|
65
|
+
width: 60px;
|
66
|
+
height: 30px;
|
67
|
+
left: 283px;
|
68
|
+
top: 13px;
|
69
|
+
background: #f00;
|
70
|
+
}
|
71
|
+
.colorpicker input {
|
72
|
+
background-color: transparent;
|
73
|
+
border: 1px solid transparent;
|
74
|
+
position: absolute;
|
75
|
+
font-size: 10px;
|
76
|
+
font-family: Arial, Helvetica, sans-serif;
|
77
|
+
color: #898989;
|
78
|
+
top: 4px;
|
79
|
+
right: 11px;
|
80
|
+
text-align: right;
|
81
|
+
margin: 0;
|
82
|
+
padding: 0;
|
83
|
+
height: 12px;
|
84
|
+
}
|
85
|
+
.colorpicker_hex {
|
86
|
+
position: absolute;
|
87
|
+
width: 72px;
|
88
|
+
height: 22px;
|
89
|
+
background: url(../images/colorpicker/colorpicker_hex.png) top;
|
90
|
+
left: 212px;
|
91
|
+
top: 142px;
|
92
|
+
}
|
93
|
+
.colorpicker_hex input {
|
94
|
+
right: 6px;
|
95
|
+
}
|
96
|
+
.colorpicker_field {
|
97
|
+
height: 22px;
|
98
|
+
width: 62px;
|
99
|
+
background-position: top;
|
100
|
+
position: absolute;
|
101
|
+
}
|
102
|
+
.colorpicker_field span {
|
103
|
+
position: absolute;
|
104
|
+
width: 12px;
|
105
|
+
height: 22px;
|
106
|
+
overflow: hidden;
|
107
|
+
top: 0;
|
108
|
+
right: 0;
|
109
|
+
cursor: n-resize;
|
110
|
+
}
|
111
|
+
.colorpicker_rgb_r {
|
112
|
+
background-image: url(../images/colorpicker/colorpicker_rgb_r.png);
|
113
|
+
top: 52px;
|
114
|
+
left: 212px;
|
115
|
+
}
|
116
|
+
.colorpicker_rgb_g {
|
117
|
+
background-image: url(../images/colorpicker/colorpicker_rgb_g.png);
|
118
|
+
top: 82px;
|
119
|
+
left: 212px;
|
120
|
+
}
|
121
|
+
.colorpicker_rgb_b {
|
122
|
+
background-image: url(../images/colorpicker/colorpicker_rgb_b.png);
|
123
|
+
top: 112px;
|
124
|
+
left: 212px;
|
125
|
+
}
|
126
|
+
.colorpicker_hsb_h {
|
127
|
+
background-image: url(../images/colorpicker/colorpicker_hsb_h.png);
|
128
|
+
top: 52px;
|
129
|
+
left: 282px;
|
130
|
+
}
|
131
|
+
.colorpicker_hsb_s {
|
132
|
+
background-image: url(../images/colorpicker/colorpicker_hsb_s.png);
|
133
|
+
top: 82px;
|
134
|
+
left: 282px;
|
135
|
+
}
|
136
|
+
.colorpicker_hsb_b {
|
137
|
+
background-image: url(../images/colorpicker/colorpicker_hsb_b.png);
|
138
|
+
top: 112px;
|
139
|
+
left: 282px;
|
140
|
+
}
|
141
|
+
.colorpicker_submit {
|
142
|
+
position: absolute;
|
143
|
+
width: 22px;
|
144
|
+
height: 22px;
|
145
|
+
background: url(../images/colorpicker/colorpicker_submit.png) top;
|
146
|
+
left: 322px;
|
147
|
+
top: 142px;
|
148
|
+
overflow: hidden;
|
149
|
+
}
|
150
|
+
.colorpicker_focus {
|
151
|
+
background-position: center;
|
152
|
+
}
|
153
|
+
.colorpicker_hex.colorpicker_focus {
|
154
|
+
background-position: bottom;
|
155
|
+
}
|
156
|
+
.colorpicker_submit.colorpicker_focus {
|
157
|
+
background-position: bottom;
|
158
|
+
}
|
159
|
+
.colorpicker_slider {
|
160
|
+
background-position: bottom;
|
161
|
+
}
|
162
|
+
|
163
|
+
.colorSelector {
|
164
|
+
position: relative;
|
165
|
+
width: 27px;
|
166
|
+
height: 27px;
|
167
|
+
background: url(../images/colorpicker/select.png);
|
168
|
+
float:left;
|
169
|
+
}
|
170
|
+
.colorSelector div {
|
171
|
+
position: absolute;
|
172
|
+
top: 4px;
|
173
|
+
left: 3px;
|
174
|
+
width: 21px;
|
175
|
+
height: 19px;
|
176
|
+
background: url(../images/colorpicker/select.png) center;
|
177
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,606 @@
|
|
1
|
+
/**
|
2
|
+
* AJAX Upload
|
3
|
+
* Project page - http://valums.com/ajax-upload/
|
4
|
+
* Copyright (c) 2008 Andris Valums, http://valums.com
|
5
|
+
* Licensed under the MIT license (http://valums.com/mit-license/)
|
6
|
+
*/
|
7
|
+
(function(){
|
8
|
+
|
9
|
+
var d = document, w = window;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Get element by id
|
13
|
+
*/
|
14
|
+
function get(element){
|
15
|
+
if (typeof element == "string")
|
16
|
+
element = d.getElementById(element);
|
17
|
+
return element;
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Attaches event to a dom element
|
22
|
+
*/
|
23
|
+
function addEvent(el, type, fn){
|
24
|
+
if (w.addEventListener){
|
25
|
+
el.addEventListener(type, fn, false);
|
26
|
+
} else if (w.attachEvent){
|
27
|
+
var f = function(){
|
28
|
+
fn.call(el, w.event);
|
29
|
+
};
|
30
|
+
el.attachEvent('on' + type, f)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Creates and returns element from html chunk
|
37
|
+
*/
|
38
|
+
var toElement = function(){
|
39
|
+
var div = d.createElement('div');
|
40
|
+
return function(html){
|
41
|
+
div.innerHTML = html;
|
42
|
+
var el = div.childNodes[0];
|
43
|
+
div.removeChild(el);
|
44
|
+
return el;
|
45
|
+
}
|
46
|
+
}();
|
47
|
+
|
48
|
+
function hasClass(ele,cls){
|
49
|
+
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
|
50
|
+
}
|
51
|
+
function addClass(ele,cls) {
|
52
|
+
if (!hasClass(ele,cls)) ele.className += " "+cls;
|
53
|
+
}
|
54
|
+
function removeClass(ele,cls) {
|
55
|
+
var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
|
56
|
+
ele.className=ele.className.replace(reg,' ');
|
57
|
+
}
|
58
|
+
|
59
|
+
// getOffset function copied from jQuery lib (http://jquery.com/)
|
60
|
+
if (document.documentElement["getBoundingClientRect"]){
|
61
|
+
// Get Offset using getBoundingClientRect
|
62
|
+
// http://ejohn.org/blog/getboundingclientrect-is-awesome/
|
63
|
+
var getOffset = function(el){
|
64
|
+
var box = el.getBoundingClientRect(),
|
65
|
+
doc = el.ownerDocument,
|
66
|
+
body = doc.body,
|
67
|
+
docElem = doc.documentElement,
|
68
|
+
|
69
|
+
// for ie
|
70
|
+
clientTop = docElem.clientTop || body.clientTop || 0,
|
71
|
+
clientLeft = docElem.clientLeft || body.clientLeft || 0,
|
72
|
+
|
73
|
+
// In Internet Explorer 7 getBoundingClientRect property is treated as physical,
|
74
|
+
// while others are logical. Make all logical, like in IE8.
|
75
|
+
|
76
|
+
zoom = 1;
|
77
|
+
|
78
|
+
if (body.getBoundingClientRect) {
|
79
|
+
var bound = body.getBoundingClientRect();
|
80
|
+
zoom = (bound.right - bound.left)/body.clientWidth;
|
81
|
+
}
|
82
|
+
|
83
|
+
if (zoom > 1){
|
84
|
+
clientTop = 0;
|
85
|
+
clientLeft = 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
var top = box.top/zoom + (window.pageYOffset || docElem && docElem.scrollTop/zoom || body.scrollTop/zoom) - clientTop,
|
89
|
+
left = box.left/zoom + (window.pageXOffset|| docElem && docElem.scrollLeft/zoom || body.scrollLeft/zoom) - clientLeft;
|
90
|
+
|
91
|
+
return {
|
92
|
+
top: top,
|
93
|
+
left: left
|
94
|
+
};
|
95
|
+
}
|
96
|
+
|
97
|
+
} else {
|
98
|
+
// Get offset adding all offsets
|
99
|
+
var getOffset = function(el){
|
100
|
+
if (w.jQuery){
|
101
|
+
return jQuery(el).offset();
|
102
|
+
}
|
103
|
+
|
104
|
+
var top = 0, left = 0;
|
105
|
+
do {
|
106
|
+
top += el.offsetTop || 0;
|
107
|
+
left += el.offsetLeft || 0;
|
108
|
+
}
|
109
|
+
while (el = el.offsetParent);
|
110
|
+
|
111
|
+
return {
|
112
|
+
left: left,
|
113
|
+
top: top
|
114
|
+
};
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
function getBox(el){
|
119
|
+
var left, right, top, bottom;
|
120
|
+
var offset = getOffset(el);
|
121
|
+
left = offset.left;
|
122
|
+
top = offset.top;
|
123
|
+
|
124
|
+
right = left + el.offsetWidth;
|
125
|
+
bottom = top + el.offsetHeight;
|
126
|
+
|
127
|
+
return {
|
128
|
+
left: left,
|
129
|
+
right: right,
|
130
|
+
top: top,
|
131
|
+
bottom: bottom
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Crossbrowser mouse coordinates
|
137
|
+
*/
|
138
|
+
function getMouseCoords(e){
|
139
|
+
// pageX/Y is not supported in IE
|
140
|
+
// http://www.quirksmode.org/dom/w3c_cssom.html
|
141
|
+
if (!e.pageX && e.clientX){
|
142
|
+
// In Internet Explorer 7 some properties (mouse coordinates) are treated as physical,
|
143
|
+
// while others are logical (offset).
|
144
|
+
var zoom = 1;
|
145
|
+
var body = document.body;
|
146
|
+
|
147
|
+
if (body.getBoundingClientRect) {
|
148
|
+
var bound = body.getBoundingClientRect();
|
149
|
+
zoom = (bound.right - bound.left)/body.clientWidth;
|
150
|
+
}
|
151
|
+
|
152
|
+
return {
|
153
|
+
x: e.clientX / zoom + d.body.scrollLeft + d.documentElement.scrollLeft,
|
154
|
+
y: e.clientY / zoom + d.body.scrollTop + d.documentElement.scrollTop
|
155
|
+
};
|
156
|
+
}
|
157
|
+
|
158
|
+
return {
|
159
|
+
x: e.pageX,
|
160
|
+
y: e.pageY
|
161
|
+
};
|
162
|
+
|
163
|
+
}
|
164
|
+
/**
|
165
|
+
* Function generates unique id
|
166
|
+
*/
|
167
|
+
var getUID = function(){
|
168
|
+
var id = 0;
|
169
|
+
return function(){
|
170
|
+
return 'ValumsAjaxUpload' + id++;
|
171
|
+
}
|
172
|
+
}();
|
173
|
+
|
174
|
+
function fileFromPath(file){
|
175
|
+
return file.replace(/.*(\/|\\)/, "");
|
176
|
+
}
|
177
|
+
|
178
|
+
function getExt(file){
|
179
|
+
return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
|
180
|
+
}
|
181
|
+
|
182
|
+
/**
|
183
|
+
* Cross-browser way to get xhr object
|
184
|
+
*/
|
185
|
+
var getXhr = function(){
|
186
|
+
var xhr;
|
187
|
+
|
188
|
+
return function(){
|
189
|
+
if (xhr) return xhr;
|
190
|
+
|
191
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
192
|
+
xhr = new XMLHttpRequest();
|
193
|
+
} else {
|
194
|
+
var v = [
|
195
|
+
"Microsoft.XmlHttp",
|
196
|
+
"MSXML2.XmlHttp.5.0",
|
197
|
+
"MSXML2.XmlHttp.4.0",
|
198
|
+
"MSXML2.XmlHttp.3.0",
|
199
|
+
"MSXML2.XmlHttp.2.0"
|
200
|
+
];
|
201
|
+
|
202
|
+
for (var i=0; i < v.length; i++){
|
203
|
+
try {
|
204
|
+
xhr = new ActiveXObject(v[i]);
|
205
|
+
break;
|
206
|
+
} catch (e){}
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
return xhr;
|
211
|
+
}
|
212
|
+
}();
|
213
|
+
|
214
|
+
// Please use AjaxUpload , Ajax_upload will be removed in the next version
|
215
|
+
Ajax_upload = AjaxUpload = function(button, options){
|
216
|
+
if (button.jquery){
|
217
|
+
// jquery object was passed
|
218
|
+
button = button[0];
|
219
|
+
} else if (typeof button == "string" && /^#.*/.test(button)){
|
220
|
+
button = button.slice(1);
|
221
|
+
}
|
222
|
+
button = get(button);
|
223
|
+
|
224
|
+
this._input = null;
|
225
|
+
this._button = button;
|
226
|
+
this._disabled = false;
|
227
|
+
this._submitting = false;
|
228
|
+
// Variable changes to true if the button was clicked
|
229
|
+
// 3 seconds ago (requred to fix Safari on Mac error)
|
230
|
+
this._justClicked = false;
|
231
|
+
this._parentDialog = d.body;
|
232
|
+
|
233
|
+
if (window.jQuery && jQuery.ui && jQuery.ui.dialog){
|
234
|
+
var parentDialog = jQuery(this._button).parents('.ui-dialog');
|
235
|
+
if (parentDialog.length){
|
236
|
+
this._parentDialog = parentDialog[0];
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
this._settings = {
|
241
|
+
// Location of the server-side upload script
|
242
|
+
action: 'upload.php',
|
243
|
+
// File upload name
|
244
|
+
name: 'userfile',
|
245
|
+
// Additional data to send
|
246
|
+
data: {},
|
247
|
+
// Submit file as soon as it's selected
|
248
|
+
autoSubmit: true,
|
249
|
+
// The type of data that you're expecting back from the server.
|
250
|
+
// Html and xml are detected automatically.
|
251
|
+
// Only useful when you are using json data as a response.
|
252
|
+
// Set to "json" in that case.
|
253
|
+
responseType: false,
|
254
|
+
// Location of the server-side script that fixes Safari
|
255
|
+
// hanging problem returning "Connection: close" header
|
256
|
+
closeConnection: '',
|
257
|
+
// Class applied to button when mouse is hovered
|
258
|
+
hoverClass: 'button_hover',
|
259
|
+
// When user selects a file, useful with autoSubmit disabled
|
260
|
+
onChange: function(file, extension){},
|
261
|
+
// Callback to fire before file is uploaded
|
262
|
+
// You can return false to cancel upload
|
263
|
+
onSubmit: function(file, extension){},
|
264
|
+
// Fired when file upload is completed
|
265
|
+
// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
|
266
|
+
onComplete: function(file, response) {}
|
267
|
+
};
|
268
|
+
|
269
|
+
// Merge the users options with our defaults
|
270
|
+
for (var i in options) {
|
271
|
+
this._settings[i] = options[i];
|
272
|
+
}
|
273
|
+
|
274
|
+
this._createInput();
|
275
|
+
this._rerouteClicks();
|
276
|
+
}
|
277
|
+
|
278
|
+
// assigning methods to our class
|
279
|
+
AjaxUpload.prototype = {
|
280
|
+
setData : function(data){
|
281
|
+
this._settings.data = data;
|
282
|
+
},
|
283
|
+
disable : function(){
|
284
|
+
this._disabled = true;
|
285
|
+
},
|
286
|
+
enable : function(){
|
287
|
+
this._disabled = false;
|
288
|
+
},
|
289
|
+
// removes instance
|
290
|
+
destroy : function(){
|
291
|
+
if(this._input){
|
292
|
+
if(this._input.parentNode){
|
293
|
+
this._input.parentNode.removeChild(this._input);
|
294
|
+
}
|
295
|
+
this._input = null;
|
296
|
+
}
|
297
|
+
},
|
298
|
+
/**
|
299
|
+
* Creates invisible file input above the button
|
300
|
+
*/
|
301
|
+
_createInput : function(){
|
302
|
+
var self = this;
|
303
|
+
var input = d.createElement("input");
|
304
|
+
input.setAttribute('type', 'file');
|
305
|
+
input.setAttribute('name', this._settings.name);
|
306
|
+
var styles = {
|
307
|
+
'position' : 'absolute'
|
308
|
+
,'margin': '-5px 0 0 -175px'
|
309
|
+
,'padding': 0
|
310
|
+
,'width': '220px'
|
311
|
+
,'height': '30px'
|
312
|
+
,'fontSize': '14px'
|
313
|
+
,'opacity': 0
|
314
|
+
,'cursor': 'pointer'
|
315
|
+
,'display' : 'none'
|
316
|
+
,'zIndex' : 2147483583 //Max zIndex supported by Opera 9.0-9.2x
|
317
|
+
// Strange, I expected 2147483647
|
318
|
+
// Doesn't work in IE :(
|
319
|
+
//,'direction' : 'ltr'
|
320
|
+
};
|
321
|
+
for (var i in styles){
|
322
|
+
input.style[i] = styles[i];
|
323
|
+
}
|
324
|
+
|
325
|
+
// Make sure that element opacity exists
|
326
|
+
// (IE uses filter instead)
|
327
|
+
if ( ! (input.style.opacity === "0")){
|
328
|
+
input.style.filter = "alpha(opacity=0)";
|
329
|
+
}
|
330
|
+
|
331
|
+
this._parentDialog.appendChild(input);
|
332
|
+
|
333
|
+
addEvent(input, 'change', function(){
|
334
|
+
// get filename from input
|
335
|
+
var file = fileFromPath(this.value);
|
336
|
+
if(self._settings.onChange.call(self, file, getExt(file)) == false ){
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
// Submit form when value is changed
|
340
|
+
if (self._settings.autoSubmit){
|
341
|
+
self.submit();
|
342
|
+
}
|
343
|
+
});
|
344
|
+
|
345
|
+
// Fixing problem with Safari
|
346
|
+
// The problem is that if you leave input before the file select dialog opens
|
347
|
+
// it does not upload the file.
|
348
|
+
// As dialog opens slowly (it is a sheet dialog which takes some time to open)
|
349
|
+
// there is some time while you can leave the button.
|
350
|
+
// So we should not change display to none immediately
|
351
|
+
addEvent(input, 'click', function(){
|
352
|
+
self.justClicked = true;
|
353
|
+
setTimeout(function(){
|
354
|
+
// we will wait 3 seconds for dialog to open
|
355
|
+
self.justClicked = false;
|
356
|
+
}, 2500);
|
357
|
+
});
|
358
|
+
|
359
|
+
this._input = input;
|
360
|
+
},
|
361
|
+
_rerouteClicks : function (){
|
362
|
+
var self = this;
|
363
|
+
|
364
|
+
// IE displays 'access denied' error when using this method
|
365
|
+
// other browsers just ignore click()
|
366
|
+
// addEvent(this._button, 'click', function(e){
|
367
|
+
// self._input.click();
|
368
|
+
// });
|
369
|
+
|
370
|
+
var box, dialogOffset = {top:0, left:0}, over = false;
|
371
|
+
|
372
|
+
addEvent(self._button, 'mouseover', function(e){
|
373
|
+
if (!self._input || over) return;
|
374
|
+
|
375
|
+
over = true;
|
376
|
+
box = getBox(self._button);
|
377
|
+
|
378
|
+
if (self._parentDialog != d.body){
|
379
|
+
dialogOffset = getOffset(self._parentDialog);
|
380
|
+
}
|
381
|
+
});
|
382
|
+
|
383
|
+
|
384
|
+
// We can't use mouseout on the button,
|
385
|
+
// because invisible input is over it
|
386
|
+
addEvent(document, 'mousemove', function(e){
|
387
|
+
var input = self._input;
|
388
|
+
if (!input || !over) return;
|
389
|
+
|
390
|
+
if (self._disabled){
|
391
|
+
removeClass(self._button, self._settings.hoverClass);
|
392
|
+
input.style.display = 'none';
|
393
|
+
return;
|
394
|
+
}
|
395
|
+
|
396
|
+
var c = getMouseCoords(e);
|
397
|
+
|
398
|
+
if ((c.x >= box.left) && (c.x <= box.right) &&
|
399
|
+
(c.y >= box.top) && (c.y <= box.bottom)){
|
400
|
+
|
401
|
+
input.style.top = c.y - dialogOffset.top + 'px';
|
402
|
+
input.style.left = c.x - dialogOffset.left + 'px';
|
403
|
+
input.style.display = 'block';
|
404
|
+
addClass(self._button, self._settings.hoverClass);
|
405
|
+
|
406
|
+
} else {
|
407
|
+
// mouse left the button
|
408
|
+
over = false;
|
409
|
+
|
410
|
+
var check = setInterval(function(){
|
411
|
+
// if input was just clicked do not hide it
|
412
|
+
// to prevent safari bug
|
413
|
+
|
414
|
+
if (self.justClicked){
|
415
|
+
return;
|
416
|
+
}
|
417
|
+
|
418
|
+
if ( !over ){
|
419
|
+
input.style.display = 'none';
|
420
|
+
}
|
421
|
+
|
422
|
+
clearInterval(check);
|
423
|
+
|
424
|
+
}, 25);
|
425
|
+
|
426
|
+
|
427
|
+
removeClass(self._button, self._settings.hoverClass);
|
428
|
+
}
|
429
|
+
});
|
430
|
+
|
431
|
+
},
|
432
|
+
/**
|
433
|
+
* Creates iframe with unique name
|
434
|
+
*/
|
435
|
+
_createIframe : function(){
|
436
|
+
// unique name
|
437
|
+
// We cannot use getTime, because it sometimes return
|
438
|
+
// same value in safari :(
|
439
|
+
var id = getUID();
|
440
|
+
|
441
|
+
// Remove ie6 "This page contains both secure and nonsecure items" prompt
|
442
|
+
// http://tinyurl.com/77w9wh
|
443
|
+
var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
|
444
|
+
iframe.id = id;
|
445
|
+
iframe.style.display = 'none';
|
446
|
+
d.body.appendChild(iframe);
|
447
|
+
return iframe;
|
448
|
+
},
|
449
|
+
/**
|
450
|
+
* Upload file without refreshing the page
|
451
|
+
*/
|
452
|
+
submit : function(){
|
453
|
+
var self = this, settings = this._settings;
|
454
|
+
|
455
|
+
if (this._input.value === ''){
|
456
|
+
// there is no file
|
457
|
+
return;
|
458
|
+
}
|
459
|
+
|
460
|
+
// get filename from input
|
461
|
+
var file = fileFromPath(this._input.value);
|
462
|
+
|
463
|
+
// execute user event
|
464
|
+
if (! (settings.onSubmit.call(this, file, getExt(file)) == false)) {
|
465
|
+
// Create new iframe for this submission
|
466
|
+
var iframe = this._createIframe();
|
467
|
+
|
468
|
+
// Do not submit if user function returns false
|
469
|
+
var form = this._createForm(iframe);
|
470
|
+
form.appendChild(this._input);
|
471
|
+
|
472
|
+
// A pretty little hack to make uploads not hang in Safari. Just call this
|
473
|
+
// immediately before the upload is submitted. This does an Ajax call to
|
474
|
+
// the server, which returns an empty document with the "Connection: close"
|
475
|
+
// header, telling Safari to close the active connection.
|
476
|
+
// http://blog.airbladesoftware.com/2007/8/17/note-to-self-prevent-uploads-hanging-in-safari
|
477
|
+
if (settings.closeConnection && /AppleWebKit|MSIE/.test(navigator.userAgent)){
|
478
|
+
var xhr = getXhr();
|
479
|
+
// Open synhronous connection
|
480
|
+
xhr.open('GET', settings.closeConnection, false);
|
481
|
+
xhr.send('');
|
482
|
+
}
|
483
|
+
|
484
|
+
form.submit();
|
485
|
+
|
486
|
+
d.body.removeChild(form);
|
487
|
+
form = null;
|
488
|
+
this._input = null;
|
489
|
+
|
490
|
+
// create new input
|
491
|
+
this._createInput();
|
492
|
+
|
493
|
+
var toDeleteFlag = false;
|
494
|
+
|
495
|
+
addEvent(iframe, 'load', function(e){
|
496
|
+
|
497
|
+
if (// For Safari
|
498
|
+
iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" ||
|
499
|
+
// For FF, IE
|
500
|
+
iframe.src == "javascript:'<html></html>';"){
|
501
|
+
|
502
|
+
// First time around, do not delete.
|
503
|
+
if( toDeleteFlag ){
|
504
|
+
// Fix busy state in FF3
|
505
|
+
setTimeout( function() {
|
506
|
+
d.body.removeChild(iframe);
|
507
|
+
}, 0);
|
508
|
+
}
|
509
|
+
return;
|
510
|
+
}
|
511
|
+
|
512
|
+
var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;
|
513
|
+
|
514
|
+
// fixing Opera 9.26
|
515
|
+
if (doc.readyState && doc.readyState != 'complete'){
|
516
|
+
// Opera fires load event multiple times
|
517
|
+
// Even when the DOM is not ready yet
|
518
|
+
// this fix should not affect other browsers
|
519
|
+
return;
|
520
|
+
}
|
521
|
+
|
522
|
+
// fixing Opera 9.64
|
523
|
+
if (doc.body && doc.body.innerHTML == "false"){
|
524
|
+
// In Opera 9.64 event was fired second time
|
525
|
+
// when body.innerHTML changed from false
|
526
|
+
// to server response approx. after 1 sec
|
527
|
+
return;
|
528
|
+
}
|
529
|
+
|
530
|
+
var response;
|
531
|
+
|
532
|
+
if (doc.XMLDocument){
|
533
|
+
// response is a xml document IE property
|
534
|
+
response = doc.XMLDocument;
|
535
|
+
} else if (doc.body){
|
536
|
+
// response is html document or plain text
|
537
|
+
response = doc.body.innerHTML;
|
538
|
+
if (settings.responseType && settings.responseType.toLowerCase() == 'json'){
|
539
|
+
// If the document was sent as 'application/javascript' or
|
540
|
+
// 'text/javascript', then the browser wraps the text in a <pre>
|
541
|
+
// tag and performs html encoding on the contents. In this case,
|
542
|
+
// we need to pull the original text content from the text node's
|
543
|
+
// nodeValue property to retrieve the unmangled content.
|
544
|
+
// Note that IE6 only understands text/html
|
545
|
+
if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){
|
546
|
+
response = doc.body.firstChild.firstChild.nodeValue;
|
547
|
+
}
|
548
|
+
if (response) {
|
549
|
+
response = window["eval"]("(" + response + ")");
|
550
|
+
} else {
|
551
|
+
response = {};
|
552
|
+
}
|
553
|
+
}
|
554
|
+
} else {
|
555
|
+
// response is a xml document
|
556
|
+
var response = doc;
|
557
|
+
}
|
558
|
+
|
559
|
+
settings.onComplete.call(self, file, response);
|
560
|
+
|
561
|
+
// Reload blank page, so that reloading main page
|
562
|
+
// does not re-submit the post. Also, remember to
|
563
|
+
// delete the frame
|
564
|
+
toDeleteFlag = true;
|
565
|
+
|
566
|
+
// Fix IE mixed content issue
|
567
|
+
iframe.src = "javascript:'<html></html>';";
|
568
|
+
});
|
569
|
+
|
570
|
+
} else {
|
571
|
+
// clear input to allow user to select same file
|
572
|
+
// Doesn't work in IE6
|
573
|
+
// this._input.value = '';
|
574
|
+
d.body.removeChild(this._input);
|
575
|
+
this._input = null;
|
576
|
+
|
577
|
+
// create new input
|
578
|
+
this._createInput();
|
579
|
+
}
|
580
|
+
},
|
581
|
+
/**
|
582
|
+
* Creates form, that will be submitted to iframe
|
583
|
+
*/
|
584
|
+
_createForm : function(iframe){
|
585
|
+
var settings = this._settings;
|
586
|
+
|
587
|
+
// method, enctype must be specified here
|
588
|
+
// because changing this attr on the fly is not allowed in IE 6/7
|
589
|
+
var form = toElement('<form method="post" enctype="multipart/form-data"></form>');
|
590
|
+
form.style.display = 'none';
|
591
|
+
form.action = settings.action;
|
592
|
+
form.target = iframe.name;
|
593
|
+
d.body.appendChild(form);
|
594
|
+
|
595
|
+
// Create hidden input element for each data key
|
596
|
+
for (var prop in settings.data){
|
597
|
+
var el = d.createElement("input");
|
598
|
+
el.type = 'hidden';
|
599
|
+
el.name = prop;
|
600
|
+
el.value = settings.data[prop];
|
601
|
+
form.appendChild(el);
|
602
|
+
}
|
603
|
+
return form;
|
604
|
+
}
|
605
|
+
};
|
606
|
+
})();
|