mirror
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 304 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,109 @@
|
||||
@charset "UTF-8";
|
||||
/* CSS Document */
|
||||
|
||||
.o-hidden {
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
#overlay {
|
||||
background: url(images-age/overlay.png) repeat;
|
||||
position: fixed;
|
||||
z-index:100;
|
||||
height: 100%;
|
||||
width:100%;
|
||||
top:0;
|
||||
left:0;
|
||||
}
|
||||
#modal-container {
|
||||
padding: 5px;
|
||||
position: fixed;
|
||||
z-index: 102;
|
||||
width: 30%;
|
||||
top:30%;
|
||||
left:35%;
|
||||
background: url(images-age/modal.png) repeat;
|
||||
margin:0;
|
||||
-moz-border-radius:3px;
|
||||
-webkit-border-radius:3px;
|
||||
border:1px solid #111;
|
||||
color: #000;
|
||||
}
|
||||
div#modal-inner {
|
||||
background:#fff;
|
||||
border:1px solid #fff;
|
||||
padding: 15px 15px 15px 15px;
|
||||
}
|
||||
div#modal-inner h1 {
|
||||
margin-bottom: 5px;
|
||||
line-height:11px;
|
||||
color: #000;
|
||||
}
|
||||
div#modal-inner img#badge {
|
||||
float:left;
|
||||
height: 32px;
|
||||
width:32px;
|
||||
display:inline-block;
|
||||
margin-top: 8px;
|
||||
margin-right: 8px;
|
||||
margin-bottom: 25px;
|
||||
padding: 5px;
|
||||
border:1px solid #bbb;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius:3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
div#modal-inner form div.field {
|
||||
float:left;
|
||||
width: 32%;
|
||||
}
|
||||
div#modal-inner form {
|
||||
padding-top: 5px;
|
||||
background:#fff;
|
||||
padding: 10px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius:3px;
|
||||
border-radius: 3px;
|
||||
border:1px solid #ccc;
|
||||
}
|
||||
div#modal-inner form label {
|
||||
display:block;
|
||||
margin: 5px 0 5px 0;
|
||||
}
|
||||
div#modal-inner form select {
|
||||
padding: 5px;
|
||||
border:1px solid #bbb;
|
||||
display: inline-block;
|
||||
width: 90%;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius:3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
div#modal-inner form input[type=submit]{
|
||||
padding: 4px;
|
||||
text-align:center;
|
||||
font-size:inherit;
|
||||
margin-top: 15px;
|
||||
display:block;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius:3px;
|
||||
border-radius: 3px;
|
||||
color: #000;
|
||||
}
|
||||
div#modal-inner form div.spacer {
|
||||
height: 60px;
|
||||
margin: 5px 0 5px 0;
|
||||
cursor:pointer;
|
||||
}
|
||||
.grey {
|
||||
background-image: -webkit-linear-gradient(top, #eee, #ccc);
|
||||
background-image: -moz-linear-gradient(top, #eee, #ccc);
|
||||
background-image: -ms-linear-gradient(top, #eee, #ccc);
|
||||
background-image: -o-linear-gradient(top, #eee, #ccc);
|
||||
border:1px solid #aaa;
|
||||
text-shadow:#fff 0px 1px 1px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.grey:hover {
|
||||
-moz-box-shadow: #aaa 0px 0px 3px;
|
||||
-webkit-box-shadow: #aaa 0px 0px 3px;
|
||||
}
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 66 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 43 B |
|
After Width: | Height: | Size: 735 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 156 B |
|
After Width: | Height: | Size: 206 B |
|
After Width: | Height: | Size: 90 B |
|
After Width: | Height: | Size: 131 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 83 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 701 B |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 586 B |
|
After Width: | Height: | Size: 729 B |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 799 B |
|
After Width: | Height: | Size: 796 B |
|
After Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 956 B |
|
After Width: | Height: | Size: 7.5 KiB |
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
The ImageUploader class handles the insertion of images into the system -
|
||||
whether they were uploaded or should be copied from a remote URL
|
||||
*/
|
||||
|
||||
require_once( 'lib/config.php' );
|
||||
require_once( 'lib/db.php' );
|
||||
require_once( 'lib/filesystem.php' );
|
||||
require_once( 'lib/images.php' );
|
||||
require_once( 'lib/users.php' );
|
||||
require_once( 'lib/keyword.php' );
|
||||
|
||||
class ImageUploader {
|
||||
|
||||
public static function copyFromUrl( $url, $tags, $referer, &$errors ) {
|
||||
if( stripos( $url, 'http://' ) !== 0 ) {
|
||||
$url = 'http://'.$url;
|
||||
}
|
||||
// no recursion, no non-images
|
||||
if(
|
||||
stripos( $url, Config::$frontendPath ) !== false ||
|
||||
!preg_match( '/([^\/]*?)\.(gif|jpg|jpeg|png)$/i', $url, $fileMatch )
|
||||
) {
|
||||
$errors['downloadFailed'] = 'The Image could not be downloaded!';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$fileName = $fileMatch[1];
|
||||
// use the domain name as part of the keyword
|
||||
$urlParts = parse_url( $url );
|
||||
if( preg_match( '/(^|\.)([\w\-]+)\.\w+$/', $urlParts['host'], $m ) ) {
|
||||
$fileName = strtolower($m[2]).'-'.$fileName;
|
||||
}
|
||||
$fileName = Keyword::get( $fileName ).'.'.$fileMatch[2];
|
||||
$targetPath = './import/'.$fileName;
|
||||
|
||||
if( !Filesystem::download( $url, $targetPath, Config::$images['maxDownload'], $referer ) ) {
|
||||
$errors['downloadFailed'] = 'The Image could not be downloaded!';
|
||||
return false;
|
||||
}
|
||||
|
||||
if( self::process( $fileName, $targetPath, $tags, false, $errors, $url ) ) {
|
||||
return true;
|
||||
} else {
|
||||
@unlink( $targePath );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function process( $name, $localPath, $tags, $uploaded = true, &$errors, $source = '',$commentUpload = false,$cid=0 ) {
|
||||
echo("hallo");
|
||||
$user = new User();
|
||||
$user->login();
|
||||
|
||||
if( !$user->id ) {
|
||||
$errors['notLoggedIn'] = 'You are not logged in!';
|
||||
return false;
|
||||
}
|
||||
|
||||
// no non-images
|
||||
if(
|
||||
!preg_match( '/([^\/]*?)\.(gif|jpg|jpeg|png)$/i', $name, $fileMatch )
|
||||
) {
|
||||
$errors['wrongExtension'] = 'Your file has not the right extension (gif, jpg or png)!';
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$keyword = Keyword::get( $fileMatch[1] );
|
||||
|
||||
// Iterate over all keywords, if this one is allready taken
|
||||
$taken = array();
|
||||
$r = DB::query( 'SELECT keyword FROM '.TABLE_IMAGES.' WHERE keyword LIKE :1', date('Y/m/',$time).$keyword.'%' );
|
||||
foreach( $r as $v ) {
|
||||
$taken[] = substr($v['keyword'],8); // Keyword without date!
|
||||
}
|
||||
$keyword = Keyword::iterate( $keyword, $taken );
|
||||
|
||||
list( $srcWidth, $srcHeight, $type ) = getimagesize( $localPath );
|
||||
if( $type == IMAGETYPE_JPEG ) {
|
||||
$extension = 'jpg';
|
||||
} else if( $type == IMAGETYPE_GIF ) {
|
||||
$extension = 'gif';
|
||||
} else if( $type == IMAGETYPE_PNG ) {
|
||||
$extension = 'png';
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$thumbName = $keyword.".jpg"; // all thumbs are jpegs!
|
||||
$name = $keyword.".".$extension;
|
||||
$imageDir = Config::$images['imagePath'] . date('Y/m', $time);
|
||||
$thumbDir = Config::$images['thumbPath'] . date('Y/m', $time);
|
||||
$imagePath = $imageDir.'/'.$name;
|
||||
|
||||
if( !Filesystem::mkdirr($imageDir) || !Filesystem::mkdirr($thumbDir) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if( $uploaded ) {
|
||||
if( !@move_uploaded_file( $localPath, $imagePath ) ) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if( !@rename( $localPath, $imagePath ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$hash = md5_file( $imagePath );
|
||||
$c = DB::query('SELECT id FROM '.TABLE_IMAGES.' WHERE hash = :1', $hash);
|
||||
if( !empty( $c ) ) {
|
||||
unlink( $imagePath );
|
||||
$errors['duplicate'] = 'This image is already in our database!';
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//watermark
|
||||
function watermark($SourceFile, $WatermarkFile, $SaveToFile = NULL)
|
||||
|
||||
{
|
||||
|
||||
list( $srcWidth, $srcHeight, $type ) = getimagesize( $SourceFile );
|
||||
if( $type != IMAGETYPE_GIF ) {
|
||||
|
||||
|
||||
|
||||
|
||||
$watermark = @imagecreatefrompng($WatermarkFile)
|
||||
|
||||
|
||||
or exit('Cannot open the watermark file.');
|
||||
|
||||
imageAlphaBlending($watermark, false);
|
||||
|
||||
imageSaveAlpha($watermark, true);
|
||||
|
||||
$image_string = @file_get_contents($SourceFile)
|
||||
|
||||
|
||||
or exit('Cannot open image file.');
|
||||
|
||||
$image = @imagecreatefromstring($image_string)
|
||||
|
||||
or exit('Not a valid image format.');
|
||||
|
||||
$imageWidth=imageSX($image);
|
||||
|
||||
$imageHeight=imageSY($image);
|
||||
|
||||
|
||||
$watermarkWidth=imageSX($watermark);
|
||||
|
||||
$watermarkHeight=imageSY($watermark);
|
||||
|
||||
$coordinate_X = ( $imageWidth) - ( $watermarkWidth);
|
||||
|
||||
|
||||
$coordinate_Y = ( $imageHeight) - ( $watermarkHeight);
|
||||
|
||||
imagecopy($image, $watermark, $coordinate_X, $coordinate_Y,
|
||||
|
||||
|
||||
0, 0, $watermarkWidth, $watermarkHeight);
|
||||
|
||||
if(!($SaveToFile)) header('Content-Type: image/jpeg');
|
||||
|
||||
imagejpeg ($image, $SaveToFile, 100);
|
||||
|
||||
|
||||
imagedestroy($image);
|
||||
|
||||
imagedestroy($watermark);
|
||||
|
||||
if(!($SaveToFile)) exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// make thumbs
|
||||
foreach( Config::$gridView['classes'] as $gc ) {
|
||||
$thumbPath = $thumbDir.'/'.$gc['dir'].'/'.$thumbName;
|
||||
Filesystem::mkdirr($thumbDir.'/'.$gc['dir']);
|
||||
if( !Image::createThumb( $imagePath, $thumbPath,
|
||||
$gc['width'] * Config::$gridView['gridSize'] - Config::$gridView['borderWidth'],
|
||||
$gc['height'] * Config::$gridView['gridSize'] - Config::$gridView['borderWidth']
|
||||
)) {
|
||||
unlink( $imagePath );
|
||||
$errors['internalError'] = 'Internal error processing the image!';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///watermark
|
||||
watermark($imagePath,"watermark.png",$imagePath);
|
||||
///watermark
|
||||
|
||||
$user->increaseScore( Config::$postScore );
|
||||
|
||||
DB::query( 'UPDATE '.TABLE_USERS.' SET images = images + 1 WHERE id = :1', $user->id );
|
||||
|
||||
|
||||
if ($commentUpload && $cid != 0){
|
||||
DB::insertRow( "pl_commentuploads",array('c_id' => $cid,"image_link" =>$imagePath,"thumb_link" => "data/thumbs/".date('Y/m/', $time)."/128x128/".$name));
|
||||
|
||||
}else{
|
||||
DB::insertRow( TABLE_IMAGES,
|
||||
array(
|
||||
'logged' => date('Y-m-d H:i:s', $time),
|
||||
'user' => $user->id,
|
||||
'score' => 3,
|
||||
'votes' => 0,
|
||||
'keyword' => date('Y/m/', $time).$keyword,
|
||||
'tags' => $tags,
|
||||
'image' => $name,
|
||||
'thumb' => $thumbName,
|
||||
'hash' => $hash,
|
||||
'source' => $source
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$imageId = DB::insertId();
|
||||
|
||||
$colors = Image::getColors( $imagePath, 4 );
|
||||
foreach( $colors as $c ) {
|
||||
DB::insertRow( TABLE_IMAGECOLORS,
|
||||
array(
|
||||
'imageId' => $imageId,
|
||||
'r' => $c['r'],
|
||||
'g' => $c['g'],
|
||||
'b' => $c['b']
|
||||
)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
After Width: | Height: | Size: 126 B |
@@ -0,0 +1,935 @@
|
||||
/**
|
||||
* jscolor, JavaScript Color Picker
|
||||
*
|
||||
* @version 1.3.13
|
||||
* @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
|
||||
* @author Jan Odvarko, http://odvarko.cz
|
||||
* @created 2008-06-15
|
||||
* @updated 2012-01-19
|
||||
* @link http://jscolor.com
|
||||
*/
|
||||
|
||||
|
||||
var jscolor = {
|
||||
|
||||
|
||||
dir : '', // location of jscolor directory (leave empty to autodetect)
|
||||
bindClass : 'color', // class name
|
||||
binding : true, // automatic binding via <input class="...">
|
||||
preloading : true, // use image preloading?
|
||||
|
||||
|
||||
install : function() {
|
||||
jscolor.addEvent(window, 'load', jscolor.init);
|
||||
},
|
||||
|
||||
|
||||
init : function() {
|
||||
if(jscolor.binding) {
|
||||
jscolor.bind();
|
||||
}
|
||||
if(jscolor.preloading) {
|
||||
jscolor.preload();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getDir : function() {
|
||||
if(!jscolor.dir) {
|
||||
var detected = jscolor.detectDir();
|
||||
jscolor.dir = detected!==false ? detected : 'jscolor/';
|
||||
}
|
||||
return jscolor.dir;
|
||||
},
|
||||
|
||||
|
||||
detectDir : function() {
|
||||
var base = location.href;
|
||||
|
||||
var e = document.getElementsByTagName('base');
|
||||
for(var i=0; i<e.length; i+=1) {
|
||||
if(e[i].href) { base = e[i].href; }
|
||||
}
|
||||
|
||||
var e = document.getElementsByTagName('script');
|
||||
for(var i=0; i<e.length; i+=1) {
|
||||
if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
|
||||
var src = new jscolor.URI(e[i].src);
|
||||
var srcAbs = src.toAbsolute(base);
|
||||
srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
|
||||
srcAbs.query = null;
|
||||
srcAbs.fragment = null;
|
||||
return srcAbs.toString();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
|
||||
bind : function() {
|
||||
var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
|
||||
var e = document.getElementsByTagName('input');
|
||||
for(var i=0; i<e.length; i+=1) {
|
||||
var m;
|
||||
if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
|
||||
var prop = {};
|
||||
if(m[3]) {
|
||||
try {
|
||||
eval('prop='+m[3]);
|
||||
} catch(eInvalidProp) {}
|
||||
}
|
||||
e[i].color = new jscolor.color(e[i], prop);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
preload : function() {
|
||||
for(var fn in jscolor.imgRequire) {
|
||||
if(jscolor.imgRequire.hasOwnProperty(fn)) {
|
||||
jscolor.loadImage(fn);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
images : {
|
||||
pad : [ 181, 101 ],
|
||||
sld : [ 16, 101 ],
|
||||
cross : [ 15, 15 ],
|
||||
arrow : [ 7, 11 ]
|
||||
},
|
||||
|
||||
|
||||
imgRequire : {},
|
||||
imgLoaded : {},
|
||||
|
||||
|
||||
requireImage : function(filename) {
|
||||
jscolor.imgRequire[filename] = true;
|
||||
},
|
||||
|
||||
|
||||
loadImage : function(filename) {
|
||||
if(!jscolor.imgLoaded[filename]) {
|
||||
jscolor.imgLoaded[filename] = new Image();
|
||||
jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
fetchElement : function(mixed) {
|
||||
return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
|
||||
},
|
||||
|
||||
|
||||
addEvent : function(el, evnt, func) {
|
||||
if(el.addEventListener) {
|
||||
el.addEventListener(evnt, func, false);
|
||||
} else if(el.attachEvent) {
|
||||
el.attachEvent('on'+evnt, func);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
fireEvent : function(el, evnt) {
|
||||
if(!el) {
|
||||
return;
|
||||
}
|
||||
if(document.createEvent) {
|
||||
var ev = document.createEvent('HTMLEvents');
|
||||
ev.initEvent(evnt, true, true);
|
||||
el.dispatchEvent(ev);
|
||||
} else if(document.createEventObject) {
|
||||
var ev = document.createEventObject();
|
||||
el.fireEvent('on'+evnt, ev);
|
||||
} else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
|
||||
el['on'+evnt]();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getElementPos : function(e) {
|
||||
var e1=e, e2=e;
|
||||
var x=0, y=0;
|
||||
if(e1.offsetParent) {
|
||||
do {
|
||||
x += e1.offsetLeft;
|
||||
y += e1.offsetTop;
|
||||
} while(e1 = e1.offsetParent);
|
||||
}
|
||||
while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
|
||||
x -= e2.scrollLeft;
|
||||
y -= e2.scrollTop;
|
||||
}
|
||||
return [x, y];
|
||||
},
|
||||
|
||||
|
||||
getElementSize : function(e) {
|
||||
return [e.offsetWidth, e.offsetHeight];
|
||||
},
|
||||
|
||||
|
||||
getRelMousePos : function(e) {
|
||||
var x = 0, y = 0;
|
||||
if (!e) { e = window.event; }
|
||||
if (typeof e.offsetX === 'number') {
|
||||
x = e.offsetX;
|
||||
y = e.offsetY;
|
||||
} else if (typeof e.layerX === 'number') {
|
||||
x = e.layerX;
|
||||
y = e.layerY;
|
||||
}
|
||||
return { x: x, y: y };
|
||||
},
|
||||
|
||||
|
||||
getViewPos : function() {
|
||||
if(typeof window.pageYOffset === 'number') {
|
||||
return [window.pageXOffset, window.pageYOffset];
|
||||
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
|
||||
return [document.body.scrollLeft, document.body.scrollTop];
|
||||
} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
|
||||
return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
|
||||
} else {
|
||||
return [0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getViewSize : function() {
|
||||
if(typeof window.innerWidth === 'number') {
|
||||
return [window.innerWidth, window.innerHeight];
|
||||
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
|
||||
return [document.body.clientWidth, document.body.clientHeight];
|
||||
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
|
||||
return [document.documentElement.clientWidth, document.documentElement.clientHeight];
|
||||
} else {
|
||||
return [0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
URI : function(uri) { // See RFC3986
|
||||
|
||||
this.scheme = null;
|
||||
this.authority = null;
|
||||
this.path = '';
|
||||
this.query = null;
|
||||
this.fragment = null;
|
||||
|
||||
this.parse = function(uri) {
|
||||
var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
|
||||
this.scheme = m[3] ? m[2] : null;
|
||||
this.authority = m[5] ? m[6] : null;
|
||||
this.path = m[7];
|
||||
this.query = m[9] ? m[10] : null;
|
||||
this.fragment = m[12] ? m[13] : null;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.toString = function() {
|
||||
var result = '';
|
||||
if(this.scheme !== null) { result = result + this.scheme + ':'; }
|
||||
if(this.authority !== null) { result = result + '//' + this.authority; }
|
||||
if(this.path !== null) { result = result + this.path; }
|
||||
if(this.query !== null) { result = result + '?' + this.query; }
|
||||
if(this.fragment !== null) { result = result + '#' + this.fragment; }
|
||||
return result;
|
||||
};
|
||||
|
||||
this.toAbsolute = function(base) {
|
||||
var base = new jscolor.URI(base);
|
||||
var r = this;
|
||||
var t = new jscolor.URI;
|
||||
|
||||
if(base.scheme === null) { return false; }
|
||||
|
||||
if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
|
||||
r.scheme = null;
|
||||
}
|
||||
|
||||
if(r.scheme !== null) {
|
||||
t.scheme = r.scheme;
|
||||
t.authority = r.authority;
|
||||
t.path = removeDotSegments(r.path);
|
||||
t.query = r.query;
|
||||
} else {
|
||||
if(r.authority !== null) {
|
||||
t.authority = r.authority;
|
||||
t.path = removeDotSegments(r.path);
|
||||
t.query = r.query;
|
||||
} else {
|
||||
if(r.path === '') { // TODO: == or === ?
|
||||
t.path = base.path;
|
||||
if(r.query !== null) {
|
||||
t.query = r.query;
|
||||
} else {
|
||||
t.query = base.query;
|
||||
}
|
||||
} else {
|
||||
if(r.path.substr(0,1) === '/') {
|
||||
t.path = removeDotSegments(r.path);
|
||||
} else {
|
||||
if(base.authority !== null && base.path === '') { // TODO: == or === ?
|
||||
t.path = '/'+r.path;
|
||||
} else {
|
||||
t.path = base.path.replace(/[^\/]+$/,'')+r.path;
|
||||
}
|
||||
t.path = removeDotSegments(t.path);
|
||||
}
|
||||
t.query = r.query;
|
||||
}
|
||||
t.authority = base.authority;
|
||||
}
|
||||
t.scheme = base.scheme;
|
||||
}
|
||||
t.fragment = r.fragment;
|
||||
|
||||
return t;
|
||||
};
|
||||
|
||||
function removeDotSegments(path) {
|
||||
var out = '';
|
||||
while(path) {
|
||||
if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
|
||||
path = path.replace(/^\.+/,'').substr(1);
|
||||
} else if(path.substr(0,3)==='/./' || path==='/.') {
|
||||
path = '/'+path.substr(3);
|
||||
} else if(path.substr(0,4)==='/../' || path==='/..') {
|
||||
path = '/'+path.substr(4);
|
||||
out = out.replace(/\/?[^\/]*$/, '');
|
||||
} else if(path==='.' || path==='..') {
|
||||
path = '';
|
||||
} else {
|
||||
var rm = path.match(/^\/?[^\/]*/)[0];
|
||||
path = path.substr(rm.length);
|
||||
out = out + rm;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
if(uri) {
|
||||
this.parse(uri);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
* Usage example:
|
||||
* var myColor = new jscolor.color(myInputElement)
|
||||
*/
|
||||
|
||||
color : function(target, prop) {
|
||||
|
||||
|
||||
this.required = true; // refuse empty values?
|
||||
this.adjust = true; // adjust value to uniform notation?
|
||||
this.hash = false; // prefix color with # symbol?
|
||||
this.caps = true; // uppercase?
|
||||
this.slider = true; // show the value/saturation slider?
|
||||
this.valueElement = target; // value holder
|
||||
this.styleElement = target; // where to reflect current color
|
||||
this.onImmediateChange = null; // onchange callback (can be either string or function)
|
||||
this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
|
||||
this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
|
||||
|
||||
this.pickerOnfocus = true; // display picker on focus?
|
||||
this.pickerMode = 'HSV'; // HSV | HVS
|
||||
this.pickerPosition = 'bottom'; // left | right | top | bottom
|
||||
this.pickerSmartPosition = true; // automatically adjust picker position when necessary
|
||||
this.pickerButtonHeight = 20; // px
|
||||
this.pickerClosable = false;
|
||||
this.pickerCloseText = 'Close';
|
||||
this.pickerButtonColor = 'ButtonText'; // px
|
||||
this.pickerFace = 10; // px
|
||||
this.pickerFaceColor = 'ThreeDFace'; // CSS color
|
||||
this.pickerBorder = 1; // px
|
||||
this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
|
||||
this.pickerInset = 1; // px
|
||||
this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
|
||||
this.pickerZIndex = 10000;
|
||||
|
||||
|
||||
for(var p in prop) {
|
||||
if(prop.hasOwnProperty(p)) {
|
||||
this[p] = prop[p];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.hidePicker = function() {
|
||||
if(isPickerOwner()) {
|
||||
removePicker();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.showPicker = function() {
|
||||
if(!isPickerOwner()) {
|
||||
var tp = jscolor.getElementPos(target); // target pos
|
||||
var ts = jscolor.getElementSize(target); // target size
|
||||
var vp = jscolor.getViewPos(); // view pos
|
||||
var vs = jscolor.getViewSize(); // view size
|
||||
var ps = getPickerDims(this); // picker size
|
||||
var a, b, c;
|
||||
switch(this.pickerPosition.toLowerCase()) {
|
||||
case 'left': a=1; b=0; c=-1; break;
|
||||
case 'right':a=1; b=0; c=1; break;
|
||||
case 'top': a=0; b=1; c=-1; break;
|
||||
default: a=0; b=1; c=1; break;
|
||||
}
|
||||
var l = (ts[b]+ps[b])/2;
|
||||
|
||||
// picker pos
|
||||
if (!this.pickerSmartPosition) {
|
||||
var pp = [
|
||||
tp[a],
|
||||
tp[b]+ts[b]-l+l*c
|
||||
];
|
||||
} else {
|
||||
var pp = [
|
||||
-vp[a]+tp[a]+ps[a] > vs[a] ?
|
||||
(-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
|
||||
tp[a],
|
||||
-vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
|
||||
(-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
|
||||
(tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
|
||||
];
|
||||
}
|
||||
drawPicker(pp[a], pp[b]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.importColor = function() {
|
||||
if(!valueElement) {
|
||||
this.exportColor();
|
||||
} else {
|
||||
if(!this.adjust) {
|
||||
if(!this.fromString(valueElement.value, leaveValue)) {
|
||||
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
|
||||
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
||||
styleElement.style.color = styleElement.jscStyle.color;
|
||||
this.exportColor(leaveValue | leaveStyle);
|
||||
}
|
||||
} else if(!this.required && /^\s*$/.test(valueElement.value)) {
|
||||
valueElement.value = '';
|
||||
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
|
||||
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
||||
styleElement.style.color = styleElement.jscStyle.color;
|
||||
this.exportColor(leaveValue | leaveStyle);
|
||||
|
||||
} else if(this.fromString(valueElement.value)) {
|
||||
// OK
|
||||
} else {
|
||||
this.exportColor();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.exportColor = function(flags) {
|
||||
if(!(flags & leaveValue) && valueElement) {
|
||||
var value = this.toString();
|
||||
if(this.caps) { value = value.toUpperCase(); }
|
||||
if(this.hash) { value = '#'+value; }
|
||||
valueElement.value = value;
|
||||
}
|
||||
if(!(flags & leaveStyle) && styleElement) {
|
||||
styleElement.style.backgroundImage = "none";
|
||||
styleElement.style.backgroundColor =
|
||||
'#'+this.toString();
|
||||
styleElement.style.color =
|
||||
0.213 * this.rgb[0] +
|
||||
0.715 * this.rgb[1] +
|
||||
0.072 * this.rgb[2]
|
||||
< 0.5 ? '#FFF' : '#000';
|
||||
}
|
||||
if(!(flags & leavePad) && isPickerOwner()) {
|
||||
redrawPad();
|
||||
}
|
||||
if(!(flags & leaveSld) && isPickerOwner()) {
|
||||
redrawSld();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.fromHSV = function(h, s, v, flags) { // null = don't change
|
||||
h<0 && (h=0) || h>6 && (h=6);
|
||||
s<0 && (s=0) || s>1 && (s=1);
|
||||
v<0 && (v=0) || v>1 && (v=1);
|
||||
this.rgb = HSV_RGB(
|
||||
h===null ? this.hsv[0] : (this.hsv[0]=h),
|
||||
s===null ? this.hsv[1] : (this.hsv[1]=s),
|
||||
v===null ? this.hsv[2] : (this.hsv[2]=v)
|
||||
);
|
||||
this.exportColor(flags);
|
||||
};
|
||||
|
||||
|
||||
this.fromRGB = function(r, g, b, flags) { // null = don't change
|
||||
r<0 && (r=0) || r>1 && (r=1);
|
||||
g<0 && (g=0) || g>1 && (g=1);
|
||||
b<0 && (b=0) || b>1 && (b=1);
|
||||
var hsv = RGB_HSV(
|
||||
r===null ? this.rgb[0] : (this.rgb[0]=r),
|
||||
g===null ? this.rgb[1] : (this.rgb[1]=g),
|
||||
b===null ? this.rgb[2] : (this.rgb[2]=b)
|
||||
);
|
||||
if(hsv[0] !== null) {
|
||||
this.hsv[0] = hsv[0];
|
||||
}
|
||||
if(hsv[2] !== 0) {
|
||||
this.hsv[1] = hsv[1];
|
||||
}
|
||||
this.hsv[2] = hsv[2];
|
||||
this.exportColor(flags);
|
||||
};
|
||||
|
||||
|
||||
this.fromString = function(hex, flags) {
|
||||
var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
|
||||
if(!m) {
|
||||
return false;
|
||||
} else {
|
||||
if(m[1].length === 6) { // 6-char notation
|
||||
this.fromRGB(
|
||||
parseInt(m[1].substr(0,2),16) / 255,
|
||||
parseInt(m[1].substr(2,2),16) / 255,
|
||||
parseInt(m[1].substr(4,2),16) / 255,
|
||||
flags
|
||||
);
|
||||
} else { // 3-char notation
|
||||
this.fromRGB(
|
||||
parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
|
||||
parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
|
||||
parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
|
||||
flags
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.toString = function() {
|
||||
return (
|
||||
(0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
|
||||
(0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
|
||||
(0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
function RGB_HSV(r, g, b) {
|
||||
var n = Math.min(Math.min(r,g),b);
|
||||
var v = Math.max(Math.max(r,g),b);
|
||||
var m = v - n;
|
||||
if(m === 0) { return [ null, 0, v ]; }
|
||||
var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
|
||||
return [ h===6?0:h, m/v, v ];
|
||||
}
|
||||
|
||||
|
||||
function HSV_RGB(h, s, v) {
|
||||
if(h === null) { return [ v, v, v ]; }
|
||||
var i = Math.floor(h);
|
||||
var f = i%2 ? h-i : 1-(h-i);
|
||||
var m = v * (1 - s);
|
||||
var n = v * (1 - s*f);
|
||||
switch(i) {
|
||||
case 6:
|
||||
case 0: return [v,n,m];
|
||||
case 1: return [n,v,m];
|
||||
case 2: return [m,v,n];
|
||||
case 3: return [m,n,v];
|
||||
case 4: return [n,m,v];
|
||||
case 5: return [v,m,n];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function removePicker() {
|
||||
delete jscolor.picker.owner;
|
||||
document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
|
||||
}
|
||||
|
||||
|
||||
function drawPicker(x, y) {
|
||||
if(!jscolor.picker) {
|
||||
jscolor.picker = {
|
||||
box : document.createElement('div'),
|
||||
boxB : document.createElement('div'),
|
||||
pad : document.createElement('div'),
|
||||
padB : document.createElement('div'),
|
||||
padM : document.createElement('div'),
|
||||
sld : document.createElement('div'),
|
||||
sldB : document.createElement('div'),
|
||||
sldM : document.createElement('div'),
|
||||
btn : document.createElement('div'),
|
||||
btnS : document.createElement('span'),
|
||||
btnT : document.createTextNode(THIS.pickerCloseText)
|
||||
};
|
||||
for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
|
||||
var seg = document.createElement('div');
|
||||
seg.style.height = segSize+'px';
|
||||
seg.style.fontSize = '1px';
|
||||
seg.style.lineHeight = '0';
|
||||
jscolor.picker.sld.appendChild(seg);
|
||||
}
|
||||
jscolor.picker.sldB.appendChild(jscolor.picker.sld);
|
||||
jscolor.picker.box.appendChild(jscolor.picker.sldB);
|
||||
jscolor.picker.box.appendChild(jscolor.picker.sldM);
|
||||
jscolor.picker.padB.appendChild(jscolor.picker.pad);
|
||||
jscolor.picker.box.appendChild(jscolor.picker.padB);
|
||||
jscolor.picker.box.appendChild(jscolor.picker.padM);
|
||||
jscolor.picker.btnS.appendChild(jscolor.picker.btnT);
|
||||
jscolor.picker.btn.appendChild(jscolor.picker.btnS);
|
||||
jscolor.picker.box.appendChild(jscolor.picker.btn);
|
||||
jscolor.picker.boxB.appendChild(jscolor.picker.box);
|
||||
}
|
||||
|
||||
var p = jscolor.picker;
|
||||
|
||||
// controls interaction
|
||||
p.box.onmouseup =
|
||||
p.box.onmouseout = function() { target.focus(); };
|
||||
p.box.onmousedown = function() { abortBlur=true; };
|
||||
p.box.onmousemove = function(e) {
|
||||
if (holdPad || holdSld) {
|
||||
holdPad && setPad(e);
|
||||
holdSld && setSld(e);
|
||||
if (document.selection) {
|
||||
document.selection.empty();
|
||||
} else if (window.getSelection) {
|
||||
window.getSelection().removeAllRanges();
|
||||
}
|
||||
dispatchImmediateChange();
|
||||
}
|
||||
};
|
||||
p.padM.onmouseup =
|
||||
p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
|
||||
p.padM.onmousedown = function(e) {
|
||||
// if the slider is at the bottom, move it up
|
||||
switch(modeID) {
|
||||
case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
|
||||
case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
|
||||
}
|
||||
holdPad=true;
|
||||
setPad(e);
|
||||
dispatchImmediateChange();
|
||||
};
|
||||
p.sldM.onmouseup =
|
||||
p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
|
||||
p.sldM.onmousedown = function(e) {
|
||||
holdSld=true;
|
||||
setSld(e);
|
||||
dispatchImmediateChange();
|
||||
};
|
||||
|
||||
// picker
|
||||
var dims = getPickerDims(THIS);
|
||||
p.box.style.width = dims[0] + 'px';
|
||||
p.box.style.height = dims[1] + 'px';
|
||||
|
||||
// picker border
|
||||
p.boxB.style.position = 'absolute';
|
||||
p.boxB.style.clear = 'both';
|
||||
p.boxB.style.left = x+'px';
|
||||
p.boxB.style.top = y+'px';
|
||||
p.boxB.style.zIndex = THIS.pickerZIndex;
|
||||
p.boxB.style.border = THIS.pickerBorder+'px solid';
|
||||
p.boxB.style.borderColor = THIS.pickerBorderColor;
|
||||
p.boxB.style.background = THIS.pickerFaceColor;
|
||||
|
||||
// pad image
|
||||
p.pad.style.width = jscolor.images.pad[0]+'px';
|
||||
p.pad.style.height = jscolor.images.pad[1]+'px';
|
||||
|
||||
// pad border
|
||||
p.padB.style.position = 'absolute';
|
||||
p.padB.style.left = THIS.pickerFace+'px';
|
||||
p.padB.style.top = THIS.pickerFace+'px';
|
||||
p.padB.style.border = THIS.pickerInset+'px solid';
|
||||
p.padB.style.borderColor = THIS.pickerInsetColor;
|
||||
|
||||
// pad mouse area
|
||||
p.padM.style.position = 'absolute';
|
||||
p.padM.style.left = '0';
|
||||
p.padM.style.top = '0';
|
||||
p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
|
||||
p.padM.style.height = p.box.style.height;
|
||||
p.padM.style.cursor = 'crosshair';
|
||||
|
||||
// slider image
|
||||
p.sld.style.overflow = 'hidden';
|
||||
p.sld.style.width = jscolor.images.sld[0]+'px';
|
||||
p.sld.style.height = jscolor.images.sld[1]+'px';
|
||||
|
||||
// slider border
|
||||
p.sldB.style.display = THIS.slider ? 'block' : 'none';
|
||||
p.sldB.style.position = 'absolute';
|
||||
p.sldB.style.right = THIS.pickerFace+'px';
|
||||
p.sldB.style.top = THIS.pickerFace+'px';
|
||||
p.sldB.style.border = THIS.pickerInset+'px solid';
|
||||
p.sldB.style.borderColor = THIS.pickerInsetColor;
|
||||
|
||||
// slider mouse area
|
||||
p.sldM.style.display = THIS.slider ? 'block' : 'none';
|
||||
p.sldM.style.position = 'absolute';
|
||||
p.sldM.style.right = '0';
|
||||
p.sldM.style.top = '0';
|
||||
p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
|
||||
p.sldM.style.height = p.box.style.height;
|
||||
try {
|
||||
p.sldM.style.cursor = 'pointer';
|
||||
} catch(eOldIE) {
|
||||
p.sldM.style.cursor = 'hand';
|
||||
}
|
||||
|
||||
// "close" button
|
||||
function setBtnBorder() {
|
||||
var insetColors = THIS.pickerInsetColor.split(/\s+/);
|
||||
var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
|
||||
p.btn.style.borderColor = pickerOutsetColor;
|
||||
}
|
||||
p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
|
||||
p.btn.style.position = 'absolute';
|
||||
p.btn.style.left = THIS.pickerFace + 'px';
|
||||
p.btn.style.bottom = THIS.pickerFace + 'px';
|
||||
p.btn.style.padding = '0 15px';
|
||||
p.btn.style.height = '18px';
|
||||
p.btn.style.border = THIS.pickerInset + 'px solid';
|
||||
setBtnBorder();
|
||||
p.btn.style.color = THIS.pickerButtonColor;
|
||||
p.btn.style.font = '12px sans-serif';
|
||||
p.btn.style.textAlign = 'center';
|
||||
try {
|
||||
p.btn.style.cursor = 'pointer';
|
||||
} catch(eOldIE) {
|
||||
p.btn.style.cursor = 'hand';
|
||||
}
|
||||
p.btn.onmousedown = function () {
|
||||
THIS.hidePicker();
|
||||
};
|
||||
p.btnS.style.lineHeight = p.btn.style.height;
|
||||
|
||||
// load images in optimal order
|
||||
switch(modeID) {
|
||||
case 0: var padImg = 'hs.png'; break;
|
||||
case 1: var padImg = 'hv.png'; break;
|
||||
}
|
||||
p.padM.style.backgroundImage = "url('"+jscolor.getDir()+"cross.gif')";
|
||||
p.padM.style.backgroundRepeat = "no-repeat";
|
||||
p.sldM.style.backgroundImage = "url('"+jscolor.getDir()+"arrow.gif')";
|
||||
p.sldM.style.backgroundRepeat = "no-repeat";
|
||||
p.pad.style.backgroundImage = "url('"+jscolor.getDir()+padImg+"')";
|
||||
p.pad.style.backgroundRepeat = "no-repeat";
|
||||
p.pad.style.backgroundPosition = "0 0";
|
||||
|
||||
// place pointers
|
||||
redrawPad();
|
||||
redrawSld();
|
||||
|
||||
jscolor.picker.owner = THIS;
|
||||
document.getElementsByTagName('body')[0].appendChild(p.boxB);
|
||||
}
|
||||
|
||||
|
||||
function getPickerDims(o) {
|
||||
var dims = [
|
||||
2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[0] +
|
||||
(o.slider ? 2*o.pickerInset + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] : 0),
|
||||
o.pickerClosable ?
|
||||
4*o.pickerInset + 3*o.pickerFace + jscolor.images.pad[1] + o.pickerButtonHeight :
|
||||
2*o.pickerInset + 2*o.pickerFace + jscolor.images.pad[1]
|
||||
];
|
||||
return dims;
|
||||
}
|
||||
|
||||
|
||||
function redrawPad() {
|
||||
// redraw the pad pointer
|
||||
switch(modeID) {
|
||||
case 0: var yComponent = 1; break;
|
||||
case 1: var yComponent = 2; break;
|
||||
}
|
||||
var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
|
||||
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
|
||||
jscolor.picker.padM.style.backgroundPosition =
|
||||
(THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
|
||||
(THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
|
||||
|
||||
// redraw the slider image
|
||||
var seg = jscolor.picker.sld.childNodes;
|
||||
|
||||
switch(modeID) {
|
||||
case 0:
|
||||
var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
|
||||
for(var i=0; i<seg.length; i+=1) {
|
||||
seg[i].style.backgroundColor = 'rgb('+
|
||||
(rgb[0]*(1-i/seg.length)*100)+'%,'+
|
||||
(rgb[1]*(1-i/seg.length)*100)+'%,'+
|
||||
(rgb[2]*(1-i/seg.length)*100)+'%)';
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
|
||||
var i = Math.floor(THIS.hsv[0]);
|
||||
var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
|
||||
switch(i) {
|
||||
case 6:
|
||||
case 0: rgb=[0,1,2]; break;
|
||||
case 1: rgb=[1,0,2]; break;
|
||||
case 2: rgb=[2,0,1]; break;
|
||||
case 3: rgb=[2,1,0]; break;
|
||||
case 4: rgb=[1,2,0]; break;
|
||||
case 5: rgb=[0,2,1]; break;
|
||||
}
|
||||
for(var i=0; i<seg.length; i+=1) {
|
||||
s = 1 - 1/(seg.length-1)*i;
|
||||
c[1] = c[0] * (1 - s*f);
|
||||
c[2] = c[0] * (1 - s);
|
||||
seg[i].style.backgroundColor = 'rgb('+
|
||||
(c[rgb[0]]*100)+'%,'+
|
||||
(c[rgb[1]]*100)+'%,'+
|
||||
(c[rgb[2]]*100)+'%)';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function redrawSld() {
|
||||
// redraw the slider pointer
|
||||
switch(modeID) {
|
||||
case 0: var yComponent = 2; break;
|
||||
case 1: var yComponent = 1; break;
|
||||
}
|
||||
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
|
||||
jscolor.picker.sldM.style.backgroundPosition =
|
||||
'0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
|
||||
}
|
||||
|
||||
|
||||
function isPickerOwner() {
|
||||
return jscolor.picker && jscolor.picker.owner === THIS;
|
||||
}
|
||||
|
||||
|
||||
function blurTarget() {
|
||||
if(valueElement === target) {
|
||||
THIS.importColor();
|
||||
}
|
||||
if(THIS.pickerOnfocus) {
|
||||
THIS.hidePicker();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function blurValue() {
|
||||
if(valueElement !== target) {
|
||||
THIS.importColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setPad(e) {
|
||||
var mpos = jscolor.getRelMousePos(e);
|
||||
var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
|
||||
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
|
||||
switch(modeID) {
|
||||
case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
|
||||
case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setSld(e) {
|
||||
var mpos = jscolor.getRelMousePos(e);
|
||||
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
|
||||
switch(modeID) {
|
||||
case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
|
||||
case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function dispatchImmediateChange() {
|
||||
if (THIS.onImmediateChange) {
|
||||
if (typeof THIS.onImmediateChange === 'string') {
|
||||
eval(THIS.onImmediateChange);
|
||||
} else {
|
||||
THIS.onImmediateChange(THIS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var THIS = this;
|
||||
var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
|
||||
var abortBlur = false;
|
||||
var
|
||||
valueElement = jscolor.fetchElement(this.valueElement),
|
||||
styleElement = jscolor.fetchElement(this.styleElement);
|
||||
var
|
||||
holdPad = false,
|
||||
holdSld = false;
|
||||
var
|
||||
leaveValue = 1<<0,
|
||||
leaveStyle = 1<<1,
|
||||
leavePad = 1<<2,
|
||||
leaveSld = 1<<3;
|
||||
|
||||
// target
|
||||
jscolor.addEvent(target, 'focus', function() {
|
||||
if(THIS.pickerOnfocus) { THIS.showPicker(); }
|
||||
});
|
||||
jscolor.addEvent(target, 'blur', function() {
|
||||
if(!abortBlur) {
|
||||
window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
|
||||
} else {
|
||||
abortBlur = false;
|
||||
}
|
||||
});
|
||||
|
||||
// valueElement
|
||||
if(valueElement) {
|
||||
var updateField = function() {
|
||||
THIS.fromString(valueElement.value, leaveValue);
|
||||
dispatchImmediateChange();
|
||||
};
|
||||
jscolor.addEvent(valueElement, 'keyup', updateField);
|
||||
jscolor.addEvent(valueElement, 'input', updateField);
|
||||
jscolor.addEvent(valueElement, 'blur', blurValue);
|
||||
valueElement.setAttribute('autocomplete', 'off');
|
||||
}
|
||||
|
||||
// styleElement
|
||||
if(styleElement) {
|
||||
styleElement.jscStyle = {
|
||||
backgroundImage : styleElement.style.backgroundImage,
|
||||
backgroundColor : styleElement.style.backgroundColor,
|
||||
color : styleElement.style.color
|
||||
};
|
||||
}
|
||||
|
||||
// require images
|
||||
switch(modeID) {
|
||||
case 0: jscolor.requireImage('hs.png'); break;
|
||||
case 1: jscolor.requireImage('hv.png'); break;
|
||||
}
|
||||
jscolor.requireImage('cross.gif');
|
||||
jscolor.requireImage('arrow.gif');
|
||||
|
||||
this.importColor();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
jscolor.install();
|
||||
@@ -0,0 +1,27 @@
|
||||
#lightbox{ position: absolute; left: 0; width: 100%; z-index: 100; text-align: center; line-height: 0;}
|
||||
#lightbox img{ width: auto; height: auto;}
|
||||
#lightbox a img{ border: none; }
|
||||
|
||||
#outerImageContainer{ position: relative; background-color: #fff; width: 250px; height: 250px; margin: 0 auto; }
|
||||
#imageContainer{ padding: 10px; }
|
||||
|
||||
#loading{ position: absolute; top: 40%; left: 0%; height: 25%; width: 100%; text-align: center; line-height: 0; }
|
||||
#hoverNav{ position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 10; }
|
||||
#imageContainer>#hoverNav{ left: 0;}
|
||||
#hoverNav a{ outline: none;}
|
||||
|
||||
#prevLink, #nextLink{ width: 49%; height: 100%; background-image: url(data:image/gif;base64,AAAA); /* Trick IE into showing hover */ display: block; }
|
||||
#prevLink { left: 0; float: left;}
|
||||
#nextLink { right: 0; float: right;}
|
||||
#prevLink:hover, #prevLink:visited:hover { background: url(/media/prevlabel.gif) left 15% no-repeat; }
|
||||
#nextLink:hover, #nextLink:visited:hover { background: url(/media/nextlabel.gif) right 15% no-repeat; }
|
||||
|
||||
#imageDataContainer{ font: 10px Verdana, Helvetica, sans-serif; background-color: #fff; margin: 0 auto; line-height: 1.4em; overflow: auto; width: 100% ; }
|
||||
|
||||
#imageData{ padding:0 10px; color: #666; }
|
||||
#imageData #imageDetails{ width: 70%; float: left; text-align: left; }
|
||||
#imageData #caption{ font-weight: bold; }
|
||||
#imageData #numberDisplay{ display: block; clear: left; padding-bottom: 1.0em; }
|
||||
#imageData #bottomNavClose{ width: 66px; float: right; padding-bottom: 0.7em; outline: none;}
|
||||
|
||||
#overlay{ position: absolute; top: 0; left: 0; z-index: 90; width: 100%; height: 500px; background-color: #000; }
|
||||
|
After Width: | Height: | Size: 950 B |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 49 B |
|
After Width: | Height: | Size: 498 B |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,180 @@
|
||||
/* line 6, ../sass/lightbox.sass */
|
||||
#lightboxOverlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 10005;
|
||||
background-color: black;
|
||||
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=85);
|
||||
opacity: 0.85;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* line 15, ../sass/lightbox.sass */
|
||||
#lightbox {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 10006;
|
||||
text-align: center;
|
||||
line-height: 0;
|
||||
font-family: "lucida grande", tahoma, verdana, arial, sans-serif;
|
||||
font-weight: normal;
|
||||
}
|
||||
/* line 24, ../sass/lightbox.sass */
|
||||
#lightbox img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
/* line 27, ../sass/lightbox.sass */
|
||||
#lightbox a img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* line 30, ../sass/lightbox.sass */
|
||||
.lb-outerContainer {
|
||||
position: relative;
|
||||
*zoom: 1;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin: 0 auto;
|
||||
-webkit-border-radius: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-ms-border-radius: 4px;
|
||||
-o-border-radius: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
/* line 38, ../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.12.1/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
|
||||
.lb-outerContainer:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* line 39, ../sass/lightbox.sass */
|
||||
.lb-container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
/* line 42, ../sass/lightbox.sass */
|
||||
.lb-loader {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 0%;
|
||||
height: 25%;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
/* line 51, ../sass/lightbox.sass */
|
||||
.lb-nav {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* line 59, ../sass/lightbox.sass */
|
||||
.lb-container > .nav {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
/* line 62, ../sass/lightbox.sass */
|
||||
.lb-nav a {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* line 65, ../sass/lightbox.sass */
|
||||
.lb-prev, .lb-next {
|
||||
width: 49%;
|
||||
height: 100%;
|
||||
background-image: url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7");
|
||||
/* Trick IE into showing hover */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* line 72, ../sass/lightbox.sass */
|
||||
.lb-prev {
|
||||
left: 0;
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* line 76, ../sass/lightbox.sass */
|
||||
.lb-next {
|
||||
right: 0;
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* line 81, ../sass/lightbox.sass */
|
||||
.lb-prev:hover {
|
||||
background: url(prev.png) left 48% no-repeat;
|
||||
}
|
||||
|
||||
/* line 85, ../sass/lightbox.sass */
|
||||
.lb-next:hover {
|
||||
background: url(next.png) right 48% no-repeat;
|
||||
}
|
||||
|
||||
/* line 88, ../sass/lightbox.sass */
|
||||
.lb-dataContainer {
|
||||
margin: 0 auto;
|
||||
padding-top: 5px;
|
||||
*zoom: 1;
|
||||
width: 100%;
|
||||
-moz-border-radius-bottomleft: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-ms-border-bottom-left-radius: 4px;
|
||||
-o-border-bottom-left-radius: 4px;
|
||||
border-bottom-left-radius: 4px;
|
||||
-moz-border-radius-bottomright: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-ms-border-bottom-right-radius: 4px;
|
||||
-o-border-bottom-right-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
/* line 38, ../../../../.rvm/gems/ruby-1.9.2-p290/gems/compass-0.12.1/frameworks/compass/stylesheets/compass/utilities/general/_clearfix.scss */
|
||||
.lb-dataContainer:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* line 95, ../sass/lightbox.sass */
|
||||
.lb-data {
|
||||
padding: 0 10px;
|
||||
color: #bbbbbb;
|
||||
}
|
||||
/* line 98, ../sass/lightbox.sass */
|
||||
.lb-data .lb-details {
|
||||
width: 85%;
|
||||
float: left;
|
||||
text-align: left;
|
||||
line-height: 1.1em;
|
||||
}
|
||||
/* line 103, ../sass/lightbox.sass */
|
||||
.lb-data .lb-caption {
|
||||
font-size: 13px;
|
||||
font-weight: bold;
|
||||
line-height: 1em;
|
||||
}
|
||||
/* line 107, ../sass/lightbox.sass */
|
||||
.lb-data .lb-number {
|
||||
display: block;
|
||||
clear: left;
|
||||
padding-bottom: 1em;
|
||||
font-size: 11px;
|
||||
}
|
||||
/* line 112, ../sass/lightbox.sass */
|
||||
.lb-data .lb-close {
|
||||
width: 35px;
|
||||
float: right;
|
||||
padding-bottom: 0.7em;
|
||||
outline: none;
|
||||
}
|
||||
/* line 117, ../sass/lightbox.sass */
|
||||
.lb-data .lb-close:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
After Width: | Height: | Size: 8.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 734 B |
|
After Width: | Height: | Size: 735 B |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 529 B |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 357 B |
|
After Width: | Height: | Size: 875 B |
|
After Width: | Height: | Size: 687 B |
|
After Width: | Height: | Size: 675 B |
|
After Width: | Height: | Size: 657 B |
|
After Width: | Height: | Size: 956 B |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,490 @@
|
||||
function $(id){return document.getElementById(id)}
|
||||
function gridView(id){ gridSolve(id); gridSolve(id); window.setInterval("gridSolve('"+id+"')",250); }
|
||||
function swap(e, c1, c2) { e.className = e.className == c1 ? c2 : c1; };
|
||||
|
||||
// GridSolver ------------------------------------------------------------
|
||||
var gridSize = 64;
|
||||
var gridMinWidth = 6;
|
||||
var gridWidth = 0;
|
||||
var grid = null;
|
||||
var boxDef = {
|
||||
'b0': {'width': 3, 'height': 3},
|
||||
'b1': {'width': 2, 'height': 2},
|
||||
'b2': {'width': 1, 'height': 1}
|
||||
};
|
||||
|
||||
function gridSolve( cid ) {
|
||||
var container = $(cid);
|
||||
var newWidth = parseInt( container.offsetWidth );
|
||||
var newGridWidth = parseInt( newWidth / gridSize );
|
||||
newGridWidth = newGridWidth < gridMinWidth ? gridMinWidth : newGridWidth;
|
||||
|
||||
if( gridWidth == newGridWidth )
|
||||
return;
|
||||
else
|
||||
gridWidth = newGridWidth;
|
||||
|
||||
boxes = new Array();
|
||||
while( container.hasChildNodes() ) {
|
||||
e = container.removeChild( container.firstChild );
|
||||
if( e.tagName == 'DIV' ) {
|
||||
boxes.push( e );
|
||||
}
|
||||
}
|
||||
|
||||
grid = new Array( gridWidth );
|
||||
for( var i = 0; i < grid.length; i++ ) {
|
||||
grid[i] = 0;
|
||||
}
|
||||
|
||||
for(var i = 0; i < boxes.length; i++) {
|
||||
insertThumb( boxes[i], cid )
|
||||
}
|
||||
|
||||
var maxHeight = 0;
|
||||
for( var i = 0; i < grid.length; i++) {
|
||||
maxHeight = Math.max( maxHeight,grid[i] );
|
||||
}
|
||||
container.style.height = (maxHeight * gridSize) + 'px';
|
||||
$('images').style.height = (maxHeight * gridSize) + 'px';
|
||||
}
|
||||
|
||||
function insertThumb( box, cid ) {
|
||||
var boxWidth = boxDef[box.className]['width'];
|
||||
var boxHeight = boxDef[box.className]['height'];
|
||||
var maxHeight = 0;
|
||||
var currentHeight = -1;
|
||||
var spotWidth = 0;
|
||||
var spotLeft = 0;
|
||||
var freeSpots = new Array();
|
||||
for( var i = 0; i < grid.length; i++) {
|
||||
if( currentHeight == grid[i] ) {
|
||||
spotWidth++;
|
||||
}
|
||||
|
||||
if( (currentHeight != grid[i] || i+1 == grid.length) && spotWidth > 0) {
|
||||
freeSpots.push({'width': spotWidth, 'left': spotLeft, 'height': currentHeight});
|
||||
|
||||
spotWidth = 1;
|
||||
spotLeft = i;
|
||||
if(currentHeight != grid[i] && i+1 == grid.length) {
|
||||
freeSpots.push({'width': spotWidth, 'left': spotLeft, 'height': grid[i]});
|
||||
}
|
||||
}
|
||||
|
||||
else if( spotWidth == 0 ) {
|
||||
spotWidth = 1;
|
||||
}
|
||||
|
||||
currentHeight = grid[i];
|
||||
if( grid[i] > maxHeight ) {
|
||||
maxHeight = grid[i];
|
||||
}
|
||||
}
|
||||
|
||||
var targetHeight = 0;
|
||||
var targetLeft = 0;
|
||||
var bestScore = -1;
|
||||
for( var j = 0; j < boxWidth; j++ ) {
|
||||
if( grid[j] > targetHeight ) {
|
||||
targetHeight = grid[j];
|
||||
}
|
||||
}
|
||||
var newHeight = targetHeight + boxHeight;
|
||||
|
||||
for( var i = 0; i < freeSpots.length; i++ ) {
|
||||
var heightScore = ( maxHeight - freeSpots[i]['height'] );
|
||||
var widthScore = boxWidth / freeSpots[i]['width'];
|
||||
var score = heightScore * heightScore + widthScore * 2;
|
||||
|
||||
if( freeSpots[i]['width'] >= boxWidth && score > bestScore ) {
|
||||
targetHeight = freeSpots[i]['height'];
|
||||
targetLeft = freeSpots[i]['left'];
|
||||
newHeight = freeSpots[i]['height'] + boxHeight;
|
||||
bestScore = score;
|
||||
}
|
||||
}
|
||||
|
||||
for( var j = 0; j < boxWidth; j++ ) {
|
||||
grid[targetLeft + j] = newHeight;
|
||||
}
|
||||
|
||||
var container = $( cid );
|
||||
container.appendChild( box );
|
||||
box.style.left = (targetLeft * gridSize) + 'px';
|
||||
box.style.top = (targetHeight * gridSize) + 'px';
|
||||
return true;
|
||||
}
|
||||
|
||||
// Colorpicker -----------------------------------------------------------
|
||||
function colorpicker( id, size, onchange, onshow ) {
|
||||
var that = this;
|
||||
this.size = size;
|
||||
this.onchange = onchange;
|
||||
this.onshow = onshow;
|
||||
|
||||
this.mode = 'none';
|
||||
|
||||
this.sv = $(id+'SV');
|
||||
this.svselect = $(id+'SVSelect');
|
||||
this.h = $(id+'H');
|
||||
this.hselect = $(id+'HSelect');
|
||||
this.value = $(id+'Value');
|
||||
this.current = $(id+'Current');
|
||||
|
||||
this.cap = function( v, min, max ) {
|
||||
return Math.min(Math.max(min,v),max);
|
||||
}
|
||||
|
||||
this.getMousPos = function( event ) {
|
||||
if(event.pageX || event.pageY){
|
||||
return {
|
||||
'x': event.pageX,
|
||||
'y': event.pageY
|
||||
};
|
||||
}
|
||||
return {
|
||||
'x': event.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
'y': event.clientY + document.body.scrollTop - document.body.clientTop
|
||||
};
|
||||
}
|
||||
|
||||
this.getObjPos = function( obj ) {
|
||||
var curleft = curtop = 0;
|
||||
if (obj.offsetParent) {
|
||||
curleft = obj.offsetLeft;
|
||||
curtop = obj.offsetTop;
|
||||
while (obj = obj.offsetParent) {
|
||||
curleft += obj.offsetLeft;
|
||||
curtop += obj.offsetTop;
|
||||
}
|
||||
}
|
||||
return {
|
||||
'x':curleft,
|
||||
'y':curtop
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
this.release = function() {
|
||||
document.onmousemove = '';
|
||||
this.mode = 'none';
|
||||
}
|
||||
|
||||
this.move = function( event ) {
|
||||
if (!event) var event = window.event;
|
||||
if(event.pageX || event.pageY) {
|
||||
var mx = event.pageX;
|
||||
var my = event.pageY;
|
||||
} else {
|
||||
var mx = event.clientX + document.body.scrollLeft - document.body.clientLeft;
|
||||
var my = event.clientY + document.body.scrollTop - document.body.clientTop;
|
||||
}
|
||||
if( this.mode == 'sv' ) {
|
||||
var obj = this.getObjPos( this.sv );
|
||||
var x = this.cap(mx - obj.x - 3, -4, this.size - 4);
|
||||
var y = this.cap(my - obj.y - 3, -4, this.size - 4);
|
||||
this.svselect.style.left = x + "px";
|
||||
this.svselect.style.top = y + "px";
|
||||
}
|
||||
else if ( this.mode == 'h' ) {
|
||||
var obj = this.getObjPos( this.sv );
|
||||
var y = this.cap(my - obj.y - 2, -2, this.size - 3);
|
||||
this.hselect.style.top = y + "px";
|
||||
this.sv.style.backgroundColor = '#' + this.rgb2hex(this.hsv2rgb( {'h':1-((y+3)/this.size), 's':1, 'v':1} ));
|
||||
}
|
||||
else return false;
|
||||
|
||||
var hex = this.getHex();
|
||||
this.current.style.backgroundColor = '#' + hex;
|
||||
this.value.innerHTML = '#' + hex;
|
||||
this.onchange( this );
|
||||
return false;
|
||||
}
|
||||
|
||||
this.sv.onmousedown = function() {
|
||||
that.mode = 'sv';
|
||||
document.onmousemove = function( event ) { that.move( event ) };
|
||||
document.onmouseup = that.release;
|
||||
return false;
|
||||
}
|
||||
|
||||
this.h.onmousedown = function() {
|
||||
that.mode = 'h';
|
||||
document.onmousemove = function( event ) { that.move( event ) };
|
||||
document.onmouseup = that.release;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
this.getHSV = function() {
|
||||
var svpos = this.getObjPos( this.sv );
|
||||
var svselectpos = this.getObjPos( this.svselect );
|
||||
|
||||
var hpos = this.getObjPos( this.h );
|
||||
var hselectpos = this.getObjPos( this.hselect );
|
||||
|
||||
return {
|
||||
'h': 1 - (this.cap(hselectpos.y - hpos.y + 3, 0, this.size) / this.size),
|
||||
's': this.cap(svselectpos.x - svpos.x + 2, 0, this.size) / this.size,
|
||||
'v': 1 - (this.cap(svselectpos.y - svpos.y + 4, 0, this.size) / this.size)
|
||||
}
|
||||
}
|
||||
|
||||
this.getRGB = function() {
|
||||
return this.hsv2rgb( this.getHSV() );
|
||||
}
|
||||
|
||||
this.getHex = function() {
|
||||
return this.rgb2hex( this.getRGB() );
|
||||
}
|
||||
|
||||
this.toHex = function(v) { v=Math.round(Math.min(Math.max(0,v),255)); return("0123456789ABCDEF".charAt((v-v%16)/16)+"0123456789ABCDEF".charAt(v%16)); }
|
||||
this.rgb2hex = function(c) { return this.toHex(c.r)+this.toHex(c.g)+this.toHex(c.b); }
|
||||
|
||||
this.hsv2rgb = function( c ) {
|
||||
var R, B, G, H = c.h, S = c.s, V = c.v;
|
||||
if( S>0 ) {
|
||||
if(H>=1) H=0;
|
||||
|
||||
H=6*H; F=H-Math.floor(H);
|
||||
A=Math.round(255*V*(1.0-S));
|
||||
B=Math.round(255*V*(1.0-(S*F)));
|
||||
C=Math.round(255*V*(1.0-(S*(1.0-F))));
|
||||
V=Math.round(255*V);
|
||||
|
||||
switch(Math.floor(H)) {
|
||||
case 0: R=V; G=C; B=A; break;
|
||||
case 1: R=B; G=V; B=A; break;
|
||||
case 2: R=A; G=V; B=C; break;
|
||||
case 3: R=A; G=B; B=V; break;
|
||||
case 4: R=C; G=A; B=V; break;
|
||||
case 5: R=V; G=A; B=B; break;
|
||||
}
|
||||
return {'r': (R?R:0), 'g': (G?G:0), 'b': (B?B:0)};
|
||||
}
|
||||
else {
|
||||
return {'r': (Math.round(V*255)), 'g': (Math.round(V*255)), 'b': (Math.round(V*255))};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Adjust height of prev/next bars in IE ---------------------------------
|
||||
var ieAdjustCount = 0;
|
||||
function ieAdjustHeight( oldHeight ) {
|
||||
var pe = ($('viewer') ? $('viewer') : $('images'));
|
||||
if(
|
||||
!document.all || // IE
|
||||
!( pe ) ||
|
||||
(
|
||||
pe.scrollHeight < oldHeight + 50 &&
|
||||
ieAdjustCount > 10
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
ieAdjustCount++;
|
||||
var newHeight = pe.scrollHeight;
|
||||
$('prevBar').style.height = pe.scrollHeight + 'px';
|
||||
$('nextBar').style.height = pe.scrollHeight + 'px';
|
||||
setTimeout( 'ieAdjustHeight(' + newHeight + ')', 100 );
|
||||
}
|
||||
|
||||
//GET
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = {};
|
||||
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
|
||||
vars[key] = value;
|
||||
});
|
||||
return vars;
|
||||
}
|
||||
|
||||
|
||||
// JSON functions for tagging, rating, deleting... -----------------------
|
||||
function post( url, params, callback ) {
|
||||
if (window.ActiveXObject) { // ie
|
||||
try {
|
||||
req = new ActiveXObject( 'Msxml2.XMLHTTP' );
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
req = new ActiveXObject( 'Microsoft.XMLHTTP' );
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
else if (window.XMLHttpRequest) { // moz
|
||||
req = new XMLHttpRequest();
|
||||
req.overrideMimeType( 'text/plain' );
|
||||
}
|
||||
req.onreadystatechange = function(){
|
||||
if (req.readyState == 4 && req.status == 200) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
if( !req ) return false;
|
||||
req.open( 'POST', url, true );
|
||||
req.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded; charset=UTF-8' );
|
||||
req.setRequestHeader( 'Content-length', params.length );
|
||||
req.setRequestHeader( 'Connection', 'close' );
|
||||
req.send( params );
|
||||
}
|
||||
|
||||
function addTags( imageId, inputField, admin ) {
|
||||
$( 'loadTags' ).style.display = 'block';
|
||||
var tags = encodeURIComponent(inputField.value);
|
||||
if( !admin ) {
|
||||
inputField.value = '';
|
||||
}
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?addTags',
|
||||
'id='+imageId+'&tags='+tags,
|
||||
function(){
|
||||
q = ( eval('('+req.responseText+')') );
|
||||
if( q.tags ) {
|
||||
$('tags').innerHTML = q.tags;
|
||||
}
|
||||
$('addTag').className='hidden';
|
||||
$( 'loadTags' ).style.display = 'none';
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
function del( imageId ) {
|
||||
try {
|
||||
if( !confirm( 'Delete this image: ' + imageId +' ?' ) ) return false;
|
||||
//$( 'loadDelete' ).style.display = 'block';
|
||||
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?delete','id='+imageId);
|
||||
LoadData("comments","cmts",imageId);
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
alert("Fehler: "+e);
|
||||
return false;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function movehof( imageId ) {
|
||||
try {
|
||||
if( !confirm( 'Move to Hall of Fame?' ) ) return false;
|
||||
//$( 'loadhof' ).style.display = 'block';
|
||||
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?fame',
|
||||
'id='+imageId);
|
||||
//function(){
|
||||
//$( 'loadhof' ).style.display = 'none';
|
||||
// //$( 'hof' ).style.display = 'none';
|
||||
//}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
alert("Fehler: "+e);
|
||||
return false;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function CloseThread( imageId ) {
|
||||
try {
|
||||
if( !confirm( 'Close Thread?' ) ) return false;
|
||||
//$( 'loadhof' ).style.display = 'block';
|
||||
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?CloseThread',
|
||||
'id='+imageId);
|
||||
//function(){
|
||||
//$( 'loadhof' ).style.display = 'none';
|
||||
// //$( 'hof' ).style.display = 'none';
|
||||
//}
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
alert("Fehler: "+e);
|
||||
return false;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function banUser( userId ) {
|
||||
|
||||
if( !confirm( 'Ban this User?' ) ) return false;
|
||||
var rsn = prompt("Why?");
|
||||
//$( 'loadDelete' ).style.display = 'block';
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?banUser',
|
||||
'id='+userId+'&rsn='+rsn);
|
||||
return false;
|
||||
}
|
||||
|
||||
function TimeUser( userId ) {
|
||||
|
||||
if( !confirm( 'Spamlock this user?' ) ) return false;
|
||||
var tm = prompt("How long? (in hours)");
|
||||
var rsn = prompt("Why?");
|
||||
//$( 'loadDelete' ).style.display = 'block';
|
||||
var now = parseInt(Math.round((new Date()).getTime() / 1000));
|
||||
now = now + (3600 * parseInt(tm));
|
||||
alert(now);
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?TimeUser',
|
||||
'id='+userId+'&time='+now+'&rsn='+rsn);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function delComment( commentId, e ) {
|
||||
if( !confirm( 'Delete this comment?' ) ) return false;
|
||||
var cdiv = e.parentNode.parentNode.parentNode;
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?deleteComment',
|
||||
'id='+commentId);
|
||||
return false;
|
||||
}
|
||||
|
||||
function addfav( imageId, e ) {
|
||||
post(
|
||||
location.protocol + "//" + location.host + '/json.php?addfav',
|
||||
'id='+imageId);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// mouseover for rating stars
|
||||
function sr( id, scale ) {
|
||||
$( id ).style.backgroundPosition = ( (20 * scale) - 100 ) + 'px 0';
|
||||
}
|
||||
|
||||
function rate( imageId, score ) {
|
||||
$( 'loadRating' ).style.display = 'block';
|
||||
post(
|
||||
$('home').href + 'json.php?rate',
|
||||
'id='+imageId+'&score='+score,
|
||||
function() {
|
||||
q = ( eval('('+req.responseText+')') );
|
||||
$( 'loadRating' ).style.display = 'none';
|
||||
$( 'currentRating' ).style.width = 20 * parseFloat(q.score) + 'px';
|
||||
$( 'ratingDescription' ).innerHTML = q.score + ' after ' + q.votes + ' Vote' + ( q.votes > 1 ? 's' : '' );
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
function s() {
|
||||
var q = $( 'q' );
|
||||
if( q && q.value ) {
|
||||
window.location = $('home').href + 'search/' + encodeURI( q.value );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
require_once( '../lib/config.php' );
|
||||
header( 'Content-type: text/javascript; charset=utf-8' );
|
||||
?>
|
||||
function RP_RemotePost( postURL, stylesheet ) {
|
||||
this.postURL = postURL;
|
||||
this.stylesheet = stylesheet;
|
||||
|
||||
this.visible = false;
|
||||
this.menu = null;
|
||||
this.dialog = null;
|
||||
this.iframe = null;
|
||||
this.checkSuccessInterval = 0;
|
||||
this.minImageSize = 32;
|
||||
|
||||
|
||||
this.create = function(){
|
||||
var that = this;
|
||||
var css = document.createElement('link');
|
||||
css.type = 'text/css';
|
||||
css.rel = 'stylesheet';
|
||||
css.href = this.stylesheet;
|
||||
if( document.getElementsByTagName("head").item(0) ) {
|
||||
document.getElementsByTagName("head").item(0).appendChild( css );
|
||||
} else {
|
||||
document.getElementsByTagName("body").item(0).appendChild( css );
|
||||
}
|
||||
|
||||
var closeButton = document.createElement('a');
|
||||
closeButton.appendChild( document.createTextNode("x") );
|
||||
closeButton.className = 'close';
|
||||
closeButton.onclick = function() { return that.toggle(); }
|
||||
closeButton.href = '#';
|
||||
|
||||
|
||||
this.dialog = document.createElement('div');
|
||||
this.dialog.id = 'RP_Dialog';
|
||||
this.iframe = document.createElement('iframe');
|
||||
this.iframe.src = 'about:blank';
|
||||
this.dialog.appendChild( this.iframe );
|
||||
this.dialog.appendChild( closeButton );
|
||||
document.body.appendChild( this.dialog );
|
||||
|
||||
this.loadIFrame( {} );
|
||||
}
|
||||
|
||||
|
||||
this.loadIFrame = function( params ) {
|
||||
var reqUrl = this.postURL + '?nocache=' + parseInt(Math.random()*10000);
|
||||
for( p in params ) {
|
||||
reqUrl += '&' + p + '=' + encodeURIComponent( params[p] );
|
||||
}
|
||||
this.iframe.src = reqUrl;
|
||||
}
|
||||
|
||||
|
||||
this.selectImage = function( image ) {
|
||||
var title = image.title ? image.title : ( image.alt ? image.alt : document.title );
|
||||
var imageSrc = image.src;
|
||||
if(
|
||||
image.parentNode.tagName.match(/^a$/i) &&
|
||||
image.parentNode.href &&
|
||||
image.parentNode.href.match(/\.(jpe?g|gif|png)$/i)
|
||||
) {
|
||||
imageSrc = image.parentNode.href;
|
||||
}
|
||||
this.loadIFrame( {
|
||||
'url': imageSrc,
|
||||
'xhrLocation': document.location.href.replace(/#.*$/,'')
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
this.checkSuccess = function() {
|
||||
if( document.location.href.match(/#RP_Success/) ) {
|
||||
var that = this;
|
||||
document.location.href = document.location.href.replace(/#.*$/, '#');
|
||||
setTimeout( function() { that.hide() }, 500 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.show = function() {
|
||||
this.visible = true;
|
||||
var that = this;
|
||||
|
||||
this.checkSuccessInterval = setInterval( function() { that.checkSuccess(); }, 500 );
|
||||
this.dialog.style.display = 'block';
|
||||
|
||||
var images = document.getElementsByTagName('img');
|
||||
for( var i=0; i<images.length; i++ ) {
|
||||
var img = images[i];
|
||||
if( img && img.src && img.src.match(/(space|blank)[^\/]*\.gif$/i) ) {
|
||||
img.style.display = 'none';
|
||||
}
|
||||
else if( img && img.src && img.width > this.minImageSize && img.height > this.minImageSize) {
|
||||
img.onclick = function( ev ) {
|
||||
if( ev && ev.stopPropagation ) {
|
||||
ev.stopPropagation();
|
||||
}
|
||||
return that.selectImage(this);
|
||||
};
|
||||
img.className = img.className ? img.className + ' RP_PostImage' : 'RP_PostImage';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.hide = function() {
|
||||
this.visible = false;
|
||||
|
||||
clearInterval( this.checkSuccessInterval );
|
||||
this.dialog.style.display = 'none';
|
||||
|
||||
var images = document.getElementsByTagName('img');
|
||||
for( var i=0; i<images.length; i++ ) {
|
||||
var img = images[i];
|
||||
if( img && img.src && img.width > this.minImageSize && img.height > this.minImageSize) {
|
||||
img.onclick = null;
|
||||
img.className = img.className.replace(/\s*RP_PostImage/, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.toggle = function() {
|
||||
if( !this.visible ) {
|
||||
this.show();
|
||||
} else {
|
||||
this.hide();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
this.create();
|
||||
}
|
||||
|
||||
if( typeof(RP_Instance) == 'undefined' ) {
|
||||
var RP_Instance = new RP_RemotePost(
|
||||
'<?php echo Config::$frontendPath; ?>remotepost.php',
|
||||
'<?php echo Config::$frontendPath; ?>media/remotepost.css'
|
||||
);
|
||||
}
|
||||
RP_Instance.toggle();
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,44 @@
|
||||
var nextImage = {};
|
||||
var preload = null;
|
||||
function quickTag( logId, imageId, inputField ) {
|
||||
var tags = encodeURIComponent(inputField.value);
|
||||
|
||||
// swap nextImage
|
||||
$('imageLocation').href = nextImage['link'];
|
||||
$('imageLocation').innerHTML = nextImage['link'];
|
||||
$('imageId').value = nextImage['id'];
|
||||
$('logId').value = nextImage['logId'];
|
||||
$('image').src = nextImage['image'];
|
||||
$('tags').innerHTML = nextImage['tags'];
|
||||
$('tagText').value = '';
|
||||
$('tagText').focus();
|
||||
|
||||
if( !nextImage['link'] ) {
|
||||
$('imageInfo').innerHTML = 'No more Images found';
|
||||
}
|
||||
|
||||
post(
|
||||
$('home').href + 'json.php?quickTag',
|
||||
'logId='+logId+'&id='+imageId+'&tags='+tags,
|
||||
function(){
|
||||
nextImage = ( eval('('+req.responseText+')') );
|
||||
preload = new Image(1,1)
|
||||
preload.src=nextImage['image'];
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
function quickTagInit() {
|
||||
swap($('quickTagIntro'), 'article', 'hidden');
|
||||
swap($('viewer'), 'hidden', 'visible');
|
||||
post(
|
||||
$('home').href + 'json.php?quickTag',
|
||||
'',
|
||||
function(){
|
||||
nextImage = ( eval('('+req.responseText+')') );
|
||||
quickTag( 0, 0, $('tagText') );
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
After Width: | Height: | Size: 869 B |
|
After Width: | Height: | Size: 751 B |
|
After Width: | Height: | Size: 723 B |
|
After Width: | Height: | Size: 665 B |
|
After Width: | Height: | Size: 546 B |
@@ -0,0 +1,58 @@
|
||||
img.RP_PostImage {
|
||||
border: 2px dashed #00adef !important;
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
img.RP_PostImage:hover, img.RP_PostImageActive {
|
||||
border: 2px solid #00adef !important;
|
||||
}
|
||||
|
||||
#RP_Dialog {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
width: 450px;
|
||||
margin-left: -243px;
|
||||
padding: 0 18px 0 0;
|
||||
z-index: 99999;
|
||||
|
||||
background-color: #222 !important;
|
||||
color: #fff !important;
|
||||
|
||||
font-size: 12pt;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
text-align: left;
|
||||
border-left: 1px solid #fff;
|
||||
border-right: 1px solid #ccc;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#RP_Dialog iframe {
|
||||
width: 450px;
|
||||
height: 100px;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#RP_Dialog a {
|
||||
color: #fff !important;
|
||||
background: transparent none !important;
|
||||
text-decoration: none !important;
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
#RP_Dialog a:hover {
|
||||
color: #fff !important;
|
||||
background: #000 none !important;
|
||||
text-decoration: none !important;
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
#RP_Dialog a.close {
|
||||
position: absolute !important;
|
||||
top: 0 !important;
|
||||
right: 0 !important;
|
||||
padding: 3px 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||