﻿var StudioText = Class.create(); StudioText.prototype = { initialize: function(content, container) { this.content = content; this.container = $(container); this.insertHtml(); }, insertHtml: function() { this.container.clear(); var properties = this.content["GetItemResult"]["Properties"]["Property"]; var b = document.createElement("b"); this.container.style.overflow = "auto"; if (properties[0]["Value"] != undefined) { b.appendChild(document.createTextNode(properties[0]["Value"])); this.container.appendChild(b); } if (properties[2]["Value"] != undefined) this.container.innerHTML += properties[2]["Value"]; } }; 
var Vacancy = Class.create();
Vacancy.prototype =

{ initialize: function(content, container, textContainer) {
    this.content = content; this.textContainer = $(textContainer); this.container = $(container);
    this.selectedVacancy = null; this.insertHtml();
}, insertHtml: function() {

    this.container.clear();
    var result = this.content["GetItemListResult"];

    if (result["@Count"] == 0) {
        // $('#StudioVacancyDiv h4').css({visibility:'hidden'});
        var want = document.getElementById('want');
        want.setAttribute('style', 'visibility:hidden');

        this.textContainer.innerHTML = "На данный момент вакансий нет.";
        return;
    }

    if (result["Item"].length != null) {
        for (var i = 0; i < result["@Count"]; i++) {
            var node = result["Item"][i];
            var a = document.createElement("a");
            var item = {
                description: node["Properties"]["Property"][1]["Value"],
                container: this.textContainer, element: a
            };
            a.href = "javascript:void(0);";
            a.onclick = this.loadText.bindAsEventListener(this, item);
            a.appendChild(document.createTextNode(node["Properties"]["Property"][0]["Value"]));
            this.container.appendChild(a);
            if (i == 0) {
                this.textContainer.innerHTML = item.description;
                this.selectedVacancy = a; Element.addClassName(this.selectedVacancy, "active");
            }
            this.container.appendChild(document.createElement("em"));
        }
    }
    else {
        var a = document.createElement("a");
        var description = result["Item"]["Properties"]["Property"][1]["Value"]; a.href = "javascript:void(0);";
        a.appendChild(document.createTextNode(result["Item"]["Properties"]["Property"][0]["Value"]));
        this.container.appendChild(a); Element.addClassName(a, "active"); this.textContainer.innerHTML = description;
    }
},

    loadText: function(evt, item) {
        item.container.clear();
        if (item.description != undefined)
            item.container.innerHTML = item.description;
        Element.removeClassName(this.selectedVacancy, "active");
        this.selectedVacancy = item.element;
        Element.addClassName(this.selectedVacancy, "active");
    }

}; 

var Services = Class.create(); Services.prototype = { initialize: function(content, container, textContainer) { this.content = content; this.textContainer = $(textContainer); this.container = $(container); this.selectedService = null; this.insertHtml(); }, insertHtml: function() {
    this.container.clear(); var result = this.content["GetItemListResult"]; if (result["@Count"] == 0) return; var len = result["Item"].length; if (len != null) {
        for (var i = 0; i < len; i++) { 
 var node = result["Item"][i]; var item = {description: node["Properties"]["Property"][2]["Value"], title: node["Properties"]["Property"][0]["Value"], index: i+1}; item.last = (i == len-1)? true : false; this.addItem(item); } } else { var item = {description: result["Item"]["Properties"]["Property"][2]["Value"], title: result["Item"]["Properties"]["Property"][0]["Value"], index: 1}; item.last = (i == len-1)? true : false; this.addItem(item); } }, addItem: function(item) { var a = document.createElement("a"); item.element = a; a.href = "javascript:void(0);"; a.onclick = this.loadService.bindAsEventListener(this, item); var div = document.createElement("div"); var span = document.createElement("span"); a.appendChild(document.createTextNode(item.title)); span.appendChild(document.createTextNode("3."+item.index+" ")); div.appendChild(span); div.appendChild(a); this.container.appendChild(div); if(item.last) a.style.color = "#9ec644"; if(item.index-1 == 0) { this.selectedService = a; Element.addClassName(this.selectedService, "active"); this.loadService(this, item); } }, loadService: function(evt, item) { this.textContainer.scrollTop = 0; this.textContainer.clear(); var title = document.createElement("h1"); var span = document.createElement("span"); span.appendChild(document.createTextNode("3."+item.index+" ")); title.appendChild(span); title.appendChild(document.createTextNode(item.title)); var div = document.createElement("div"); div.innerHTML = item.description; this.textContainer.appendChild(title); this.textContainer.appendChild(div); Element.removeClassName(this.selectedService, "active"); this.selectedService = item.element; Element.addClassName(this.selectedService, "active"); } }; var FAQModule = Class.create(); FAQModule.prototype = { initialize: function(content, container, textContainer) { this.content = content; this.container = $(container); this.textContainer = $(textContainer); this.itemsLength = 0; this.drawMenu(); }, drawMenu: function() { this.container.clear(); var result = this.content["GetItemListResult"]; if(result["@Count"] == 0) return; if(result["Item"].length != null) { this.itemsLength = result["@Count"]; for(var i=0; i<result["Item"].length; i++) { var node = result["Item"][i]; var descr = node["Properties"]["Property"][2]["Value"]; var item = {description: descr, title: node["Name"], subtitle: node["Description"], index: i+1}; var div = this.addMenuItem(item); this.container.appendChild(div); } } else { var descr = result["Item"]["Properties"]["Property"][2]["Value"]; var item = {description: descr, title: result["Item"]["Name"], subtitle: result["Item"]["Description"], index: 1}; var div = this.addMenuItem(item); this.container.appendChild(div); this.loadFaqText(this, item); } var lastIndex = parseInt(this.itemsLength)+1; var lastItem = {title: "Словарь терминов", subtitle: "что есть что", index: lastIndex}; var lastDiv = this.addMenuItem(lastItem); this.container.appendChild(lastDiv); }, addMenuItem: function(item) { var div = document.createElement("div"); var span = document.createElement("span"); var b = document.createElement("b"); b.appendChild(document.createTextNode("4."+item.index+" ")); span.appendChild(b); div.appendChild(span); var a = document.createElement("a"); item.element = a; a.href = "javascript:void(0);"; if(item.index == parseInt(this.itemsLength)+1) a.onclick = this.getTerminsXml.bindAsEventListener(this, a); else a.onclick = this.loadFaqText.bindAsEventListener(this, item); a.appendChild(document.createTextNode(item.title)); div.appendChild(a); div.appendChild(document.createElement("br")); if(item.subtitle != undefined) div.appendChild(document.createTextNode(item.subtitle)); if(item.index-1 == 0) { this.selectedFaq = a; Element.addClassName(this.selectedFaq, "active"); this.loadFaqText(this, item); } return div; }, loadFaqText: function(evt, item) { this.textContainer.clear(); this.textContainer.scrollTop = 0; this.textContainer.innerHTML = item.description; Element.removeClassName(this.selectedFaq, "active"); this.selectedFaq = item.element; Element.addClassName(this.selectedFaq, "active"); }, getTerminsXml: function(evt, link) { Element.removeClassName(this.selectedFaq, "active"); this.selectedFaq = link; Element.addClassName(this.selectedFaq, "active"); this.textContainer.clear(); this.textContainer.innerHTML = "<img src='/Images/preload2.gif' style='margin: 100px 0 0 150px;' alt='' />"; var terminsBlock = {id: 0, container: "faqTextDiv", category: "itemList", params: {folderId: "0", catalogId: "8"}, moduleName: "FAQTermins"}; var block = new Block(terminsBlock); block.getItemList(); block.blockCallback = this.loadTermins.bind(this); }, loadTermins: function(container, content) { var itemList = content["GetItemListResult"]; $(container).clear(); if(itemList["@Count"] == 0) return; if(itemList["Item"].length != null) { for(var i=0; i<itemList["Item"].length; i++) { var div = this.addTermin(itemList["Item"][i]); $(container).appendChild(div); } } else { var div = this.addTermin(itemList["Item"]); $(container).appendChild(div); } }, addTermin: function(item) { var div = document.createElement("div"); div.innerHTML = "<b>" + item["Properties"]["Property"][0]["Value"] + "</b> - " + item["Properties"]["Property"][1]["Value"]; return div; } }; var Menu = Class.create(); Menu.prototype = { initialize: function() { this.container = $("studioMenuDiv"); this.menu = [{title: "Сами о себе", partIndex: 0}, {title: "Сами для себя", partIndex: 1}, {title: "Партнеры", partIndex: 2/*, submenu: [ {title: "студия1", partIndex: 2}/*, {title: "панорамы", partIndex: 3} ]*/}, {title: "Команда", partIndex: 4, submenu: [ {title: "персоналии", partIndex: 4}, {title: "как работаем", partIndex: 5}, {title: "вакансии", partIndex: 6} ]}, {title: "Контактная информация", partIndex: 7, submenu: [ {title: "схема проезда", partIndex: 8} ]}, {title: "Ж-Блог", partIndex: 9} ]; this.selectedItem = null; this.pItem = null; this.selectedSubItem = null; }, loadMenu: function() { this.container.clear(); for(var i=0; i<this.menu.length; i++) { var div = document.createElement("div"); var span = document.createElement("span"); var b = document.createElement("b"); b.appendChild(document.createTextNode("1." + (i+1))); span.appendChild(b); var a = document.createElement("a"); a.href = (this.menu[i].partIndex != 9)? "javascript:app.loadPart(1," + this.menu[i].partIndex + ")" : "http://jeltofioldesign.livejournal.com/"; if(this.menu[i].partIndex == 9) { a.target = "_blank"; a.style.color = "#ffa200"; } a.appendChild(document.createTextNode(this.menu[i].title)); this.pItem = a; var item = {element: a, partIndex: this.menu[i].partIndex}; if(i==0) { Element.addClassName(a, "active"); this.selectedItem = a; } if(this.menu[i].submenu != undefined) { var submenu = this.menu[i].submenu; var subdiv = document.createElement("div"); for(var j=0; j<submenu.length; j++) { var subsubdiv = document.createElement("div"); var link = document.createElement("a"); link.href = "javascript:app.loadPart(1," + submenu[j].partIndex + ")"; link.appendChild(document.createTextNode(submenu[j].title)); var subitem = {element: link, pElement: this.pItem, partIndex: submenu[j].partIndex}; link.onclick = this.setSelectedItem.bindAsEventListener(this, subitem); subsubdiv.appendChild(link); subdiv.appendChild(subsubdiv); if(j==0) item.subElement = link; } div.appendChild(span); div.appendChild(a); div.appendChild(subdiv); } else { div.appendChild(span); div.appendChild(a); } a.onclick = this.setSelectedItem.bindAsEventListener(this, item); this.container.appendChild(div); } }, setSelectedItem: function(evt, item) { if(this.selectedItem != null) Element.removeClassName(this.selectedItem, "active"); if(this.selectedSubItem != null) Element.removeClassName(this.selectedSubItem, "active"); this.selectedItem = (item.pElement != undefined)? item.pElement : item.element; Element.addClassName(this.selectedItem, "active"); if(item.partIndex != 7) { this.selectedSubItem = (item.subElement != undefined)? item.subElement : item.element; Element.addClassName(this.selectedSubItem, "active"); } } }; var ClientList = Class.create(); ClientList.prototype = { initialize: function(content, container, textContainer) { this.content = content; this.container = $(container); this.textContainer = $(textContainer); this.applicationRoot = applicationRoot || "/"; this.maxCount = 5; this.fullCount = this.content["GetItemListResult"]["@Count"]; this.loadedItems = 0; this.topArrow = $("topArrow"); this.botArrow = $("botArrow"); this.selectedItem; this.curIndex = 0; this.clients = []; this.initList(this.content); }, initList: function(content) { this.container.clear(); var itemList = content["GetItemListResult"]; if(this.fullCount == 0) return; if(itemList["Item"].length != null) for(var i=0; i<itemList["Item"].length; i++) this.addItem(itemList["Item"][i], this.loadedItems+i); else this.addItem(itemList["Item"], this.loadedItems); if(itemList["@Count"] > this.maxCount) { this.botArrow.src = "/Images/botarrow2.gif"; this.botArrow.onclick = this.scrollBlock.bindAsEventListener(this); this.botArrow.style.cursor = "pointer"; } }, addItem: function(item, index) { var props = (item.props != null)? item.props : item["Properties"]["Property"]; var title = (item.name != null)? item.name : item["Name"]; var text = props[0]["Value"]; var div = document.createElement("div"); var table = document.createElement("table"); var tbody = document.createElement("tbody"); var tr = document.createElement("tr"); var td1 = document.createElement("td"); var td2 = document.createElement("td"); var div3 = document.createElement("div"); td2.style.width = "1%"; var a = document.createElement("a"); a.appendChild(document.createTextNode(title)); a.href = "javascript:void(0)"; var spanA = document.createElement("a"); spanA.href = "javascript:void(0)"; var span = document.createElement("span"); span.appendChild(document.createTextNode(index+1)); spanA.appendChild(span); div3.appendChild(a); td1.appendChild(div3); td2.appendChild(spanA); tr.appendChild(td1); tr.appendChild(td2); tbody.appendChild(tr); table.appendChild(tbody); div.appendChild(table); var clientItem = {index: index, props: props, pItem: div, name: title}; this.clients.push(clientItem); if((index == 0 && this.selectedItem == undefined) || (index == this.selectedItem.index && this.selectedItem != undefined)) { this.selectedItem = clientItem; this.loadText(this, clientItem); } a.onclick = this.loadText.bindAsEventListener(this, clientItem); spanA.onclick = this.loadText.bindAsEventListener(this, clientItem); this.container.appendChild(div); }, loadText: function(evt, item) { this.textContainer.clear(); if(this.selectedItem != undefined) Element.removeClassName(this.selectedItem.pItem, "active"); this.selectedItem = item; var curIndex = this.selectedItem.index; Element.addClassName(this.selectedItem.pItem, "active"); var title = item.name; var text = item.props[0]["Value"]; var sertificate = item.props[1]["Value"]; var date = item.props[2]["Value"]; var h = document.createElement("h1"); h.appendChild(document.createTextNode(title)); this.textContainer.appendChild(h); var div = document.createElement("div"); var subDiv = document.createElement("div"); Element.addClassName(subDiv, "info"); if(sertificate != null) { var span = document.createElement("span"); var img = document.createElement("img"); img.src = this.applicationRoot + sertificate /*+ "&w=121&h=143"*/; span.appendChild(img); img.style.margin = "12px 0 0 7px"; subDiv.appendChild(span); } subDiv.appendChild(document.createTextNode(date.substring(0, 10))); div.appendChild(subDiv); this.textContainer.appendChild(div); if(text != null) { var div1 = document.createElement("div"); Element.addClassName(div1, "text"); var div2 = document.createElement("div"); var div3 = document.createElement("div"); div3.innerHTML = text; div2.appendChild(div3); div1.appendChild(div2); div.appendChild(div1); div2.style.width = (span != undefined)? "340px" : "440px"; var link2 = document.createElement("a"); link2.href = "javascript:void(0);"; link2.appendChild(document.createTextNode("свернуть")); div2.appendChild(link2); link2.onclick = this.dropText.bindAsEventListener(this, div2, 53, 'hidden'); if(text.length > 200) { var link = document.createElement("a"); link.href = "javascript:void(0);"; link.appendChild(document.createTextNode("полный текст")); link.onclick = this.dropText.bindAsEventListener(this, div2, 95, 'auto'); div.appendChild(link); } this.textContainer.appendChild(div); } }, dropText: function(evt, container, height, overflow) { var div = container.firstChild; container.style.height = height + "px"; div.style.overflow = overflow; div.style.height = (overflow == "auto")? height-20 + "px" : height + "px"; div.scrollTop = 0; }, preloadClients: function(container, content) { this.container.clear(); this.initList(content); }, scrollBlock: function(evt) { var elem = Event.element(evt); this.curIndex = (elem == this.topArrow)? this.curIndex-5 : this.curIndex+5; this.topArrow.src = (this.curIndex == 0)? "/Images/blank.gif" : "/Images/toparrow2.gif"; this.topArrow.onclick = (this.curIndex == 0)? null : this.scrollBlock.bindAsEventListener(this); this.topArrow.style.cursor = (this.curIndex == 0)? "default" : "pointer"; this.botArrow.src = (this.curIndex+5 >= this.fullCount)? "/Images/blank.gif" : "/Images/botarrow2.gif"; this.botArrow.onclick = (this.curIndex+5 >= this.fullCount)? null : this.scrollBlock.bindAsEventListener(this); this.botArrow.style.cursor = (this.curIndex+5 >= this.fullCount)? "default" : "pointer"; this.container.innerHTML = "<img src='/Images/preload2.gif' style='margin: 50px 50px 0 0;' alt=''/>"; if(this.curIndex > this.maxCount/2 && this.curIndex <= this.clients.length) { this.maxCount += this.maxCount; this.addList(); } else { this.container.clear(); for(var i=this.curIndex; i<this.curIndex+5; i++) { if(i<this.fullCount) this.addItem(this.clients[i], i); } } }, addList: function() { var index = this.clients.length+1; var block = {id: 0, container: "", category: "itemList", params: {folderId: "", catalogId: 7}, itemsCount: 5, startIndex: index, filter: [{column: "isVisible", value: 1, condition: "Equal"}], orderSettings: [{column: "Date", rule: "DESC"}], propertyList: ["Feedback", "Certificate", "Date", "isVisible"]}; this.loadedItems = this.clients.length; var nextClients = new Block(block); nextClients.getItemList(); nextClients.blockCallback = this.preloadClients.bind(this); } }; 
