Вход Регистрация
Файл: sys/javascript/dcms.js
Строк: 1079
<?php
/* DCMS jsBuild system */



// FILE core/dcms.js
var DCMS = {
    
StyleAnimationtrue,
    
StyleAnimationDuration600
};

DCMS.getEventHandler = function(funccontext){
    
context context || window;
    if (
typeof func !== 'function')
        throw new 
TypeError("Обработчиком события должна быть функция");
    
    return function(){
        return 
func.apply(contextarguments);
    };
    
};

DCMS.delay = function(delayfunctcontext){
    
setTimeout(DCMS.getEventHandler(functcontext), delay);    
};


DCMS.isArray = function(array){
    return (
typeof(array)=='object') && (array instanceof Array);
};

DCMS.isEmpty = function(mixed_var) {
    if (
mixed_var === "" || mixed_var === || mixed_var === "0" || mixed_var === null || mixed_var === false || typeof mixed_var === 'undefined') {
        return 
true;
    } 
    if (
typeof mixed_var == 'object') {
        for (var 
key in mixed_var) {
            return 
false;
        }
        return 
true;
    } 
    return 
false;
}

DCMS.isScalar = function (mixed_var) {
    return (/
boolean|number|string/).test(typeof mixed_var);
};

DCMS.isNumber = function (mixed_var) {
    return !
isNaN(parseFloat(mixed_var)) && isFinite(mixed_var);
};

DCMS.isFunction = function(func){
    return (
typeof func == 'function');
};

DCMS.isDom = function(dom){
    return 
dom && DCMS.isFunction(dom.appendChild);
};

DCMS.objectToPost = function(obj){
    if (
DCMS.isScalar(obj))
        return 
obj;
    var 
pairs = [];
    
    for (var 
key in obj){
        
pairs.push(encodeURIComponent(key) + '=' encodeURIComponent(obj[key]));
    }
    
    
    return 
pairs.join('&');
};

DCMS.countProp = function(obj){
    var 
count 0;
        
    for (var 
prop in obj){
        if (!
DCMS.isFunction(obj[prop]))
            
count++;
    }    
    
    return 
count;
};

// FILE core/ajax.js
// include "core/dcms.js"

function getXmlHttp() {
    var 
xmlhttp;
    try {
        
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (
e) {
        try {
            
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (
E) {
            
xmlhttp false;
        }
    }
    if (!
xmlhttp && typeof XMLHttpRequest != 'undefined') {
        
xmlhttp = new XMLHttpRequest();
    }
    return 
xmlhttp;
}

DCMS.Ajax = function(settings) {
    if (!
settings)
        throw 
"Не заданы параметры запроса";

    var 
url settings.url.split('?');
    
url[1] =  (url[1] ? url[1] + '&''') + '_='+Math.random().toString();
        

    var 
xhr getXmlHttp();
    
xhr.open(settings.post "POST" 'GET'url.join('?'), true);
    
xhr.setRequestHeader("X-Requested-With""XMLHttpRequest");
    if (
settings.post){
        
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    }
    
xhr.onreadystatechange = function() {
        if (
xhr.readyState != 4)
            return;
        if (
xhr.status == 200) {
            if (
settings.callback)
                
settings.callback.call(thisxhr.responseText);
        } else {
            if (
settings.error)
                
settings.error.call(thisxhr.statusText);
        }
    }
        
    
xhr.send(DCMS.objectToPost(settings.post));
};

// FILE core/animate.js
// include "core/dcms.js"

DCMS.Animate = function(durationcallbackdelta){
    
    if (
delta && DCMS.Animate.deltaFunctions[delta])
        
this.delta DCMS.Animate.deltaFunctions[delta];    
    else 
        
this.delta DCMS.Animate.deltaFunctions['life'];
          
    
    if (
typeof callback != 'function')
        throw new 
Error('callback не является функцией');
    else
        
this.callback callback;
    
    
this.duration duration || 1000;
    
this.runned true;
    
this.interval 20;
    
this.start = new Date().getTime();
    
this.Step();
};

    
DCMS.Animate.prototype.End = function(to_end){
        if (!
this.runned)
            return;
        
this.runned false;
    
        if (
to_end)
            
this.callback(1);
    }

    
DCMS.Animate.prototype.Step = function(){
        if (!
this.runned)
            return;
        
        var 
step = (new Date().getTime() - this.start)/ this.duration;
        
        if (
step >= 1)
            
step 1;
        
        
this.callback(step == :this.delta(step));        
        
        if (
step 1)
            
setTimeout(DCMS.getEventHandler(this.Stepthis), this.interval);
    };

    
DCMS.Animate.deltaFunctions = {
        
linear: function (input){
            return 
input;
        },
        
drop: function(input){
            return 
DCMS.Animate.deltaFunctions._easeOut(DCMS.Animate.deltaFunctions._bounce)(input);        
        },
        
life: function(input){
            return 
DCMS.Animate.deltaFunctions._easeOut(DCMS.Animate.deltaFunctions._quad)(input);
        },
        
_bounce: function (progress) {
            for (var 
01result1+= b/= 2) {
                if (
progress >= (a) / 11) {
                    return -
Math.pow((11 11 progress) / 42) + Math.pow(b2);
                }
            }
            return 
1;
        },
        
_easeOut: function (delta) {
            return function(
progress) {
                return 
delta(progress);
            }
        },
        
_quad: function (progress) {
            return 
Math.pow(progress4);
        }

    };

// FILE core/dom.js
// include "core/dcms.js"
DCMS.Dom = {
    
    };


    
DCMS.Dom.setStyle = function(dompropvalue){
        
dom.style[prop.toCamel()] = value;
    };

    
DCMS.Dom.getComputedValue = function(domprop){
        var 
dash_prop prop.toDash();
        
        switch(
dash_prop){
            case 
'height':
                return 
dom.offsetHeight 'px';
            case 
'width':
                return 
dom.offsetWidth 'px';
            case 
'left':
                return 
dom.offsetLeft 'px';
            case 
'top':
                return 
dom.offsetTop 'px';
        }        
        
        return 
window.getComputedStyle(domnull).getPropertyValue(dash_prop);
    };

    
DCMS.Dom.getProbeValue = function(dompropvalue){
        var 
tmp_val getComputedStyle(domnull).getPropertyValue(prop.toDash());
        
dom.style[prop] = value;
        var 
def_val getComputedStyle(domnull).getPropertyValue(prop.toDash());
        
dom.style[prop] = tmp_val;
        return 
def_val;
    };

    
DCMS.Dom.getDefaultValue = function(domprop){
        return 
DCMS.Dom.getProbeValue(domprop'');
    };

    
DCMS.Dom.classAdd = function(domNodeclassName){
        if (
domNode == undefined || domNode.className == undefined)
            return;
    
        if (
className instanceof Array){
            for(var 
0className.lengthi++)
                
DCMS.Dom.classAdd(domNodeclassName[i]);
            return;
        }   
    
        if (
DCMS.Dom.classHas(domNodeclassName))
            return;
    
        var 
classes domNode.className.split(' ');
        
classes.push(className);
        
domNode.className classes.join(' ').trim();
    };

    
DCMS.Dom.classRemove = function(domNodeclassName){
        if (
domNode == undefined || domNode.className == undefined)
            return;

        if (!
DCMS.Dom.classHas(domNodeclassName))
            return;
        var 
classes domNode.className.split(' ');
        var 
classesSet = [];
        for (var 
0classes.lengthi++){
            if (
classes[i] == className)
                continue;
            
classesSet.push(classes[i]);
        }
        
domNode.className classesSet.join(' ');
    };

    
DCMS.Dom.classHas = function(domNodeclassName){
        if (
domNode == undefined || domNode.className == undefined)
            return 
false;
        
        return ~
domNode.className.split(' ').indexOf(className);
    };

    
DCMS.Dom.create = function(tagNameclassesparentbefore){
        var 
dom document.createElement(tagName);
    
        if (
classes)
            
DCMS.Dom.classAdd(domclasses);
    
        if (
DCMS.isDom(parent)){
            if (
DCMS.isDom(before))
                
parent.insertBefore(dombefore);            
            else
                
parent.appendChild(dom);            
        }           
    
        return 
dom;
    };

    
DCMS.Dom.createFromHtml = function(htmlclassesparentbefore){
        var 
div document.createElement('div');
        try{
            
div.innerHTML html;
        }
        catch(
e){
            
console.log(e);
        }
        
        var 
dom div.firstChild;
    
        if (
classes)
            
DCMS.Dom.classAdd(domclasses);
    
        if (
DCMS.isDom(parent)){
            if (
dom.id && document.getElementById(dom.id))
                return 
dom;
            
            if (
DCMS.isDom(before))
                
parent.insertBefore(dombefore);            
            else
                
parent.appendChild(dom);            
        } 
    
        return 
dom;
    };

    
DCMS.Dom.parseStyle = function(value){    
        var 
parseFloat(value);
        var 
value.replace(/^[-d.]+/,'');
        return 
isNaN(p) ? {
            
valueq
            
units''
        
} : {
            
valuep
            
unitsq
        
};
    };
    
    
DCMS.Dom.inputInsert = function(nodeOpenCloseCursorEnd) {    
        
node.focus();
        if (
window.attachEvent && navigator.userAgent.indexOf('Opera') === -1) {                                        
            var 
node.sel;
            if(
s){                                  
                var 
s.text.length;
                
s.text Open s.text Close;
                
s.moveEnd("character", -Close.length);
                
s.moveStart("character", -l);                                           
                
s.select();                
            }
        } else {                                              
            var 
ss node.scrollTop;
            var 
sel1 node.value.substr(0node.selectionStart);
            var 
sel2 node.value.substr(node.selectionEnd);
            var 
sel node.value.substr(node.selectionStartnode.selectionEnd node.selectionStart);  
        
        
            
node.value sel1 Open sel Close sel2;
            if (
CursorEnd){
                
node.selectionStart sel1.length Open.length sel.length Close.length;
                
node.selectionEnd node.selectionStart;
            }else{            
                
node.selectionStart sel1.length Open.length;
                
node.selectionEnd node.selectionStart sel.length;            
            }
            
node.scrollTop ss
                                                    
        }
        return 
false;
    }

// FILE core/animation.js
// include "core/animate.js"
// include "core/dom.js"
DCMS.Animation = {
   
    };

    
DCMS.Animation._AnimatingNodes = [];
    
DCMS.Animation._AnimatingProperties = [];
    
DCMS.Animation._AnimatingAnimates = [];

    
DCMS.Animation.addToList = function(dompropertyanimate){
        
DCMS.Animation._AnimatingNodes.push(dom);
        
DCMS.Animation._AnimatingProperties.push(property);
        
DCMS.Animation._AnimatingAnimates.push(animate);
    };
    
    
DCMS.Animation.deleteFromlist = function(index){
        
DCMS.Animation._AnimatingNodes.splice(index1);
        
DCMS.Animation._AnimatingProperties.splice(index1);
        
DCMS.Animation._AnimatingAnimates.splice(index1);
    };
    
    
DCMS.Animation.getIndexByProp = function(domproperty){
        for (var 
DCMS.Animation._AnimatingNodes.lengthi++){            
            if (
DCMS.Animation._AnimatingNodes[i] == dom && DCMS.Animation._AnimatingProperties[i] == property)
                return 
i;
        }
        return -
1;
    };

    
DCMS.Animation.stop = function(dompropertyto_end_step){    
        var 
index DCMS.Animation.getIndexByProp(domproperty);    
        if (~
index){
            
// console.log('stop', dom, property);
            
DCMS.Animation._AnimatingAnimates[index].End(!!to_end_step);
            
DCMS.Animation.deleteFromlist(index);
        }    
    };

    
DCMS.Animation.colorStep = function(color1color2step){    
        if (!(
color1 instanceof RGBColor))
            
color1 = new RGBColor(color1);
        
        if (!(
color2 instanceof RGBColor))
            
color2 = new RGBColor(color2);
        
        var 
=  parseInt(color1.+ (color2.color1.r) * step);
        var 
=  parseInt(color1.+ (color2.color1.g) * step);
        var 
=  parseInt(color1.+ (color2.color1.b) * step);
        
        if (
color1.== 0){
            
=  color2.r;
            
=  color2.g;
            
=  color2.b;
        }
        
        if (
color2.== 0){
            
=  color1.r;
            
=  color1.g;
            
=  color1.b;
        }
        
        var 
=  parseFloat(color1.+ (color2.color1.a) * step);
        
        return new 
RGBColor('rgba(' ', ' ',' +',' +')');
    };

    
    
DCMS.Animation.style = function(dompropertyvaluedurationcallbackEnd){
        if (!
dom || !dom.style)
            return 
false;
       
        
DCMS.Animation.stop(domproperty);
    
        if (!
DCMS.isNumber(duration))
            
duration DCMS.StyleAnimationDuration;
        if (
duration && duration 30// считаем, что задано в секундах
            
duration *= 1000;
        
        
property property.toCamel();
    
        var 
styleStartstyleEnd;
        if (
DCMS.isArray(value) && value.length == 2){
            
styleStart DCMS.Dom.parseStyle(value[0] === '' DCMS.Dom.getComputedValue(domproperty) : value[0]);
            
styleEnd DCMS.Dom.parseStyle(value[1] === '' DCMS.Dom.getDefaultValue(domproperty): value[1]); 
            
value value[1];
        }else{
            
styleStart DCMS.Dom.parseStyle(DCMS.Dom.getComputedValue(domproperty));
            
styleEnd DCMS.Dom.parseStyle(value === '' DCMS.Dom.getDefaultValue(domproperty): value);            
        }
    
        if (
styleEnd.units == '%')
            
styleEnd DCMS.Dom.parseStyle(DCMS.Dom.getProbeValue(dompropertystyleEnd.value styleEnd.units));
    
        if (
styleStart.value && styleStart.units && styleEnd.units && styleStart.units != styleEnd.units)
            return 
false;
    
        var 
units =  styleEnd.units || styleStart.units;    
        
        var 
colorEnd = new RGBColor(styleEnd.value);
        var 
colorStart = new RGBColor(styleStart.value);            
    
        var 
callback = function(step){
            
//console.log(step);
            
if (colorEnd.ok){
                
dom.style[property] = DCMS.Animation.colorStep(colorStartcolorEndstep);
            
//console.log(DCMS.Animation.colorStep(colorStart, colorEnd, step));                
            
}else if (DCMS.isNumber(styleEnd.value)){
                
dom.style[property] = parseFloat(styleStart.value + (styleEnd.value styleStart.value) * step).toFixed(2) + units
            } else{
                
step 1;
            }
                        
            if (
step == 1){
                
dom.style[property] = value;
                
                
DCMS.Animation.stop(domproperty);
                if (
DCMS.isFunction(callbackEnd))
                    
callbackEnd.call(dom);
            }                            
        }
    
        if (
DCMS.StyleAnimation && duration)
            
DCMS.Animation.addToList(domproperty, new DCMS.Animate(durationcallback));
        else
            
callback(1);
    
        return 
true;
    };

// FILE core/event.js
//include "core/dcms.js"
DCMS.Event = {
        
/**
     * Подписка на событие
     * Использование:
     *  menu.on('select', function(item) { ... }
     */
        
on: function(eventNamehandler) {
            if (!
this._eventHandlers)
                
this._eventHandlers = [];
            if (!
this._eventHandlers[eventName]) {
                
this._eventHandlers[eventName] = [];
            }
            
this._eventHandlers[eventName].push(handler);
        },
        
/**
     * Прекращение подписки
     *  menu.off('select',  handler)
     */
        
off: function(eventNamehandler) {
            var 
handlers this._eventHandlers[eventName];
            if (!
handlers)
                return;
            for (var 
0handlers.lengthi++) {
                if (
handlers[i] == handler) {
                    
handlers.splice(i--, 1);
                }
            }
        },
        
/**
     * Генерация события с передачей данных
     *  this.trigger('select', item);
     */
        
trigger: function(eventName) {

            if (!
this._eventHandlers[eventName]) {
                return; 
// обработчиков для события нет
            
}

            
// вызвать обработчики 
            
var handlers this._eventHandlers[eventName];
            for (var 
0handlers.lengthi++) {
                
handlers[i].apply(this, [].slice.call(arguments1));
            }

        }
    }

// FILE core/ready.js
function ready(f){
    
DCMS.Event.on('ready'f);
}

if ( 
document.addEventListener ) {
    
// Use the handy event callback
    
document.addEventListener"DOMContentLoaded", function(){
        
document.removeEventListener"DOMContentLoaded"arguments.calleefalse );
        
DCMS.Event.trigger('ready');
    }, 
false );

// If IE event model is used
} else if ( document.attachEvent ) {
    
// ensure firing before onload,
    // maybe late but safe also for iframes
    
document.attachEvent("onreadystatechange", function(){
        if ( 
document.readyState === "complete" ) {
            
document.detachEvent"onreadystatechange"arguments.callee );
            
DCMS.Event.trigger('ready');
        }
    });
}else{
    
window.onload = function(){
        
DCMS.Event.trigger('ready');
    } 
}

DCMS.listing_update = function(urlidscallbackcallback_err){
    
DCMS.Ajax({
        
urlurl,
        
post:'skip_ids='+ids.join(','),
        
callbackcallback,
        
errorcallback_err
    
});
};

// FILE core/user_update.js
//include "core/dcms.js"
DCMS.UserUpdate = {
        
fields: ['mail_new_count''friend_new_count'],
        
errors0,
        
time_last0,
        
id_usernull,
        
timeoutnull,
        
interval7,
        
delay_update: function(sec) {
            
sec sec || this.interval;
            var 
self this;
            
self.stop();
            
self.timeout setTimeout(function() {
                
self.update.call(self);
            }, 
sec 1000);
        },
        
update: function() {
            var 
self this;
            
DCMS.Ajax({
                
url'/ajax/user.json.php?' this.fields.join('&'),
                
callback: function() {
                    
self.onresult.apply(selfarguments);
                },
                
error: function() {
                    
self.onerror.call(self);
                }
            })
        },
        
onerror: function() {
            
this.errors++;
            
this.delay_update(30 this.errors);
        },
        
onresult: function(data) {
            
DCMS.Event.trigger('user_update'JSON.parse(data));
            
this.errors 0;
            
this.delay_update(this.interval);
        },
        
stop: function() {
            if (
this.timeout)
                
clearTimeout(this.timeout);
        }
    }

// FILE plugins/event.js
Event = (function() {

    var 
guid 0;
    
    function 
fixEvent(event) {
        
event event || window.event;
  
        if ( 
event.isFixed ) {
            return 
event;
        }
        
event.isFixed true;
  
        
event.preventDefault event.preventDefault || function(){
            
this.returnValue false;
        }
        
event.stopPropagation event.stopPropagaton || function(){
            
this.cancelBubble true;
        }
    
        if (!
event.target) {
            
event.target event.srcElement;
        }
  
        if (!
event.relatedTarget && event.fromElement) {
            
event.relatedTarget event.fromElement == event.target event.toElement event.fromElement;
        }
  
        if ( 
event.pageX == null && event.clientX != null ) {
            var 
html document.documentElementbody document.body;
            
event.pageX event.clientX + (html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
            
event.pageY event.clientY + (html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
        }
  
        if ( !
event.which && event.button ) {
            
event.which = (event.button : ( event.button : ( event.button ) ));
        }
    
        return 
event;
    }  
  
    
/* Вызывается в контексте элемента всегда this = element */
    
function commonHandle(event) {
        
event fixEvent(event);
    
        var 
handlers this.events[event.type];

        for ( var 
g in handlers ) {
            var 
handler handlers[g];
            var 
ret handler.call(thisevent);
            if ( 
ret === false ) {
                
event.preventDefault();
                
event.stopPropagation();
            }
        }
    }
  
    return {
        
add: function(elemtypeshandler) {
            if (
elem.setInterval && ( elem != window && !elem.frameElement ) ) {
                
elem window;
            }
      
            if (!
handler.guid) {
                
handler.guid = ++guid;
            }
      
            if (!
elem.events) {
                
elem.events = {};
                
elem.handle = function(event) {
                    if (
typeof Event !== "undefined") {
                        return 
commonHandle.call(elemevent);
                    }
                }
            }
      
            
types DCMS.isArray(types)?types:[types];
            for (var 
i=0i<types.lengthi++){
                var 
type types[i];
                if (!
elem.events[type]) {
                    
elem.events[type] = {};        
      
                    if (
elem.addEventListener)
                        
elem.addEventListener(typeelem.handlefalse);
                    else if (
elem.attachEvent)
                        
elem.attachEvent("on" typeelem.handle);
                }
      
                
elem.events[type][handler.guid] = handler;
            
            }
        },
    
        
remove: function(elemtypehandler) {
            var 
handlers elem.events && elem.events[type];
      
            if (!
handlers) return;
      
            
delete handlers[handler.guid];
      
            for(var 
any in handlers) return ;
            if (
elem.removeEventListener)
                
elem.removeEventListener(typeelem.handlefalse);
            else if (
elem.detachEvent)
                
elem.detachEvent("on" typeelem.handle);
        
            
delete elem.events[type];
    
      
            for (var 
any in elem.events)
                return;
            try {
                
delete elem.handle;
                
delete elem.events
            } catch(
e) { // IE
                
elem.removeAttribute("handle");
                
elem.removeAttribute("events");
            }
        } 
    }
}());

// FILE plugins/rgbcolor.js
function RGBColor(color_string)
{
    
color_string color_string.toString();
    
this.ok false;     
    
color_string color_string.replace(/ /g,'');
    
color_string color_string.toLowerCase();

    
// before getting into regexps, try simple matches
    // and overwrite the input
    
var simple_colors = {
        
aliceblue'f0f8ff',
        
antiquewhite'faebd7',
        
aqua'00ffff',
        
aquamarine'7fffd4',
        
azure'f0ffff',
        
beige'f5f5dc',
        
bisque'ffe4c4',
        
black'000000',
        
blanchedalmond'ffebcd',
        
blue'0000ff',
        
blueviolet'8a2be2',
        
brown'a52a2a',
        
burlywood'deb887',
        
cadetblue'5f9ea0',
        
chartreuse'7fff00',
        
chocolate'd2691e',
        
coral'ff7f50',
        
cornflowerblue'6495ed',
        
cornsilk'fff8dc',
        
crimson'dc143c',
        
cyan'00ffff',
        
darkblue'00008b',
        
darkcyan'008b8b',
        
darkgoldenrod'b8860b',
        
darkgray'a9a9a9',
        
darkgreen'006400',
        
darkkhaki'bdb76b',
        
darkmagenta'8b008b',
        
darkolivegreen'556b2f',
        
darkorange'ff8c00',
        
darkorchid'9932cc',
        
darkred'8b0000',
        
darksalmon'e9967a',
        
darkseagreen'8fbc8f',
        
darkslateblue'483d8b',
        
darkslategray'2f4f4f',
        
darkturquoise'00ced1',
        
darkviolet'9400d3',
        
deeppink'ff1493',
        
deepskyblue'00bfff',
        
dimgray'696969',
        
dodgerblue'1e90ff',
        
feldspar'd19275',
        
firebrick'b22222',
        
floralwhite'fffaf0',
        
forestgreen'228b22',
        
fuchsia'ff00ff',
        
gainsboro'dcdcdc',
        
ghostwhite'f8f8ff',
        
gold'ffd700',
        
goldenrod'daa520',
        
gray'808080',
        
green'008000',
        
greenyellow'adff2f',
        
honeydew'f0fff0',
        
hotpink'ff69b4',
        
indianred 'cd5c5c',
        
indigo '4b0082',
        
ivory'fffff0',
        
khaki'f0e68c',
        
lavender'e6e6fa',
        
lavenderblush'fff0f5',
        
lawngreen'7cfc00',
        
lemonchiffon'fffacd',
        
lightblue'add8e6',
        
lightcoral'f08080',
        
lightcyan'e0ffff',
        
lightgoldenrodyellow'fafad2',
        
lightgrey'd3d3d3',
        
lightgreen'90ee90',
        
lightpink'ffb6c1',
        
lightsalmon'ffa07a',
        
lightseagreen'20b2aa',
        
lightskyblue'87cefa',
        
lightslateblue'8470ff',
        
lightslategray'778899',
        
lightsteelblue'b0c4de',
        
lightyellow'ffffe0',
        
lime'00ff00',
        
limegreen'32cd32',
        
linen'faf0e6',
        
magenta'ff00ff',
        
maroon'800000',
        
mediumaquamarine'66cdaa',
        
mediumblue'0000cd',
        
mediumorchid'ba55d3',
        
mediumpurple'9370d8',
        
mediumseagreen'3cb371',
        
mediumslateblue'7b68ee',
        
mediumspringgreen'00fa9a',
        
mediumturquoise'48d1cc',
        
mediumvioletred'c71585',
        
midnightblue'191970',
        
mintcream'f5fffa',
        
mistyrose'ffe4e1',
        
moccasin'ffe4b5',
        
navajowhite'ffdead',
        
navy'000080',
        
oldlace'fdf5e6',
        
olive'808000',
        
olivedrab'6b8e23',
        
orange'ffa500',
        
orangered'ff4500',
        
orchid'da70d6',
        
palegoldenrod'eee8aa',
        
palegreen'98fb98',
        
paleturquoise'afeeee',
        
palevioletred'd87093',
        
papayawhip'ffefd5',
        
peachpuff'ffdab9',
        
peru'cd853f',
        
pink'ffc0cb',
        
plum'dda0dd',
        
powderblue'b0e0e6',
        
purple'800080',
        
red'ff0000',
        
rosybrown'bc8f8f',
        
royalblue'4169e1',
        
saddlebrown'8b4513',
        
salmon'fa8072',
        
sandybrown'f4a460',
        
seagreen'2e8b57',
        
seashell'fff5ee',
        
sienna'a0522d',
        
silver'c0c0c0',
        
skyblue'87ceeb',
        
slateblue'6a5acd',
        
slategray'708090',
        
snow'fffafa',
        
springgreen'00ff7f',
        
steelblue'4682b4',
        
tan'd2b48c',
        
teal'008080',
        
thistle'd8bfd8',
        
tomato'ff6347',
        
turquoise'40e0d0',
        
violet'ee82ee',
        
violetred'd02090',
        
wheat'f5deb3',
        
white'ffffff',
        
whitesmoke'f5f5f5',
        
yellow'ffff00',
        
yellowgreen'9acd32'
    
};
    for (var 
key in simple_colors) {
        if (
color_string == key) {
            
color_string simple_colors[key];
        }
    }
    
// emd of simple type-in colors

    // array of color definition objects
    
var color_defs = [
    {
        
re: /^rgb((d{1,3}),s*(d{1,3}),s*(d{1,3}))$/,
        
example: ['rgb(123, 234, 45)''rgb(255,234,245)'],
        
process: function (bits){
            return [
            
parseInt(bits[1]),
            
parseInt(bits[2]),
            
parseInt(bits[3])
            ];
        }
    },
    {
        
re: /^rgba((d{1,3}),s*(d{1,3}),s*(d{1,3}),s*(d{1}(.d+)?))$/,
        
example: ['rgba(123, 234, 45, 0.34)''rgba(255,234,245,1)'],
        
process: function (bits){
            return [
            
parseInt(bits[1]),
            
parseInt(bits[2]),
            
parseInt(bits[3]),            
            
parseFloat(bits[4])
            ];
        }
    },
    {
        
re: /^#(w{2})(w{2})(w{2})(w{2})$/,
        
example: ['#00ff00ff''336699ff'], // формат прозрачности осла
        
process: function (bits){
            return [
            
parseInt(bits[1], 16),
            
parseInt(bits[2], 16),
            
parseInt(bits[3], 16),
            
parseInt(bits[4], 16)/255
            
];
        }
    },
    {
        
re: /^#(w{2})(w{2})(w{2})$/,
        
example: ['#00ff00''336699'],
        
process: function (bits){
            return [
            
parseInt(bits[1], 16),
            
parseInt(bits[2], 16),
            
parseInt(bits[3], 16)
            ];
        }
    },
    {
        
re: /^#(w{1})(w{1})(w{1})(w{1})$/,
        
example: ['#fb0f''f0ff'],
        
process: function (bits){
            return [
            
parseInt(bits[1] + bits[1], 16),
            
parseInt(bits[2] + bits[2], 16),
            
parseInt(bits[3] + bits[3], 16),
            
parseInt(bits[4] + bits[4], 16)/255
            
];
        }
    },
    {
        
re: /^#(w{1})(w{1})(w{1})$/,
        
example: ['#fb0''f0f'],
        
process: function (bits){
            return [
            
parseInt(bits[1] + bits[1], 16),
            
parseInt(bits[2] + bits[2], 16),
            
parseInt(bits[3] + bits[3], 16)
            ];
        }
    }
    ];

    
// search through the definitions to find a match
    
for (var 0color_defs.lengthi++) {
        var 
re color_defs[i].re;
        var 
processor color_defs[i].process;
        var 
bits re.exec(color_string);
        if (
bits) {
            
channels processor(bits);
            
this.channels[0];
            
this.channels[1];
            
this.channels[2];
            
this.channels[3] == undefined 1channels[3];
            
this.ok true;
        }

    }

    
// validate/cleanup values
    
this.= (this.|| isNaN(this.r)) ? : ((this.255) ? 255 this.r);
    
this.= (this.|| isNaN(this.g)) ? : ((this.255) ? 255 this.g);
    
this.= (this.|| isNaN(this.b)) ? : ((this.255) ? 255 this.b);
    
this.= (this.|| isNaN(this.a)) ? : ((this.1) ? this.a);

    
this.toRGBA = function () {
        return 
'rgba(' this.', ' this.', ' this.', ' this.+')';
    }
    
    
this.toRGB = function () {
        return 
'rgb(' this.', ' this.', ' this.')';
    }
    
    
this.toHex = function () {
        var 
this.r.toString(16);
        var 
this.g.toString(16);
        var 
this.b.toString(16);
        if (
r.length == 1'0' r;
        if (
g.length == 1'0' g;
        if (
b.length == 1'0' b;
        return 
'#' b;
    }
    
    
this.toHexA = function () {
        var 
this.r.toString(16);
        var 
this.g.toString(16);
        var 
this.b.toString(16);
        
        var 
parseInt(this.255).toString(16);
                
        if (
r.length == 1'0' r;
        if (
g.length == 1'0' g;
        if (
b.length == 1'0' b;
        if (
a.length == 1'0' a;
        return 
'#' a;
    }

    
this.toString this.toRGBA;

}

// FILE plugins/string.js
String.prototype.trim = function () {
    return 
this.replace(/^s+|s+$/g"");
};

String.prototype.toCamel = function () {
    return 
this.replace(/(-[a-z])/g, function ($1) {
        return $
1.toUpperCase().replace('-''');
    });
};

String.prototype.toDash = function () {
    return 
this.replace(/([A-Z])/g, function ($1) {
        return 
"-" + $1.toLowerCase();
    });
};

String.prototype.toUnderscore = function () {
    return 
this.replace(/([A-Z])/g, function ($1) {
        return 
"_" + $1.toLowerCase();
    });
};
?>
Онлайн: 1
Реклама