Last active
August 29, 2015 14:08
-
-
Save rochnyak-d-i/4c33418109ce269ace65 to your computer and use it in GitHub Desktop.
JS шаблон абстрактная фабрика
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function BluePopup () { | |
//создание всплывающего окна | |
} | |
BluePopup.prototype.attach = function (elemens) { | |
//присоединение других ui-элементов к окну | |
} | |
BluePopupFactory.register('popup', BluePopup); | |
function BluePopupButton () { | |
//создание кнопки для синего всплывающего окна | |
} | |
BluePopupButton.prototype.setText = function (text) { | |
//установка текста на кнопке | |
} | |
BluePopupFactory.register('button', BluePopupButton); | |
function BluePopupTitle () { | |
//создание заголовка для синего окна | |
} | |
BluePopupTitle.prototype.setText = function (text) { | |
//установка текста заголовка | |
} | |
BluePopupFactory.register('title', BluePopupTitle); | |
function UI () { | |
//класс, отвечающий за ui-элементы | |
} | |
UI.createPopup = function (factory) { | |
var popup = factory.create('popup'), | |
buttonOk = factory.create('button'), | |
buttonCancel = factory.create('button'), | |
title = factory.create('title'); | |
buttonOk.setText('OK'); | |
buttonCancel.setText('Cancel'); | |
title.setText('Untitled'); | |
popup.attach([buttonOk, buttonCancel, title]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment