[Dialog] Code structure changed to match cordova architecture.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 11:47:38 +0000 (13:47 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 7 Apr 2016 11:50:36 +0000 (13:50 +0200)
Change-Id: Ia862a78e1508b61d7a9cbb117a6bebc3004e0da7
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/cordova-api.gyp
src/dialog/cordova_dialog.gyp [deleted file]
src/dialog/cordova_dialog_api.js [deleted file]
src/dialog/cordova_dialog_extension.cc [deleted file]
src/dialog/cordova_dialog_extension.h [deleted file]
src/lib/cordova_plugins.js
src/lib/plugins/cordova-plugin-dialogs/tizen/Notification.js [new file with mode: 0755]

index 9741543267bba69e54d22071ee1895bacb818e20..21eb7669ef8cd1ebc4fa9a9652551f9078ab8e64 100644 (file)
@@ -9,7 +9,6 @@
       'type': 'none',
       'dependencies': [
         'cordova/cordova.gyp:*',
-        'dialog/cordova_dialog.gyp:*',
         'events/cordova_events.gyp:*',
         'file/cordova_file.gyp:*',
         'globalization/cordova_globalization.gyp:*',
diff --git a/src/dialog/cordova_dialog.gyp b/src/dialog/cordova_dialog.gyp
deleted file mode 100644 (file)
index 8f13ec3..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-{
-  'includes':[
-    '/usr/include/webapi-plugins/src/common/common.gypi',
-  ],
-  'targets': [
-    {
-      'target_name': 'tizen_cordova_dialog',
-      'type': 'loadable_module',
-      'sources': [
-        'cordova_dialog_api.js',
-        'cordova_dialog_extension.cc',
-        'cordova_dialog_extension.h',
-      ],
-      'include_dirs': [
-        '../',
-        '<(SHARED_INTERMEDIATE_DIR)',
-      ],
-      'variables': {
-        'packages': [
-          'webapi-plugins',
-        ],
-      },
-    },
-  ],
-}
diff --git a/src/dialog/cordova_dialog_api.js b/src/dialog/cordova_dialog_api.js
deleted file mode 100755 (executable)
index 67fc46f..0000000
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-// TODO: remove when added to public cordova repository -> begin
-var plugin_name = 'cordova-plugin-dialogs.tizen.Notification';
-
-cordova.define(plugin_name, function(require, exports, module) {
-// TODO: remove -> end
-
-var _document = document || {};
-
-var playback = (function() {
-  var soundElement;
-  var counter = 1;
-
-  function win(v) {
-    soundElement = new Audio(v);
-    soundElement.addEventListener('ended', function() {
-      if (--counter > 0) {
-        soundElement.play();
-      }
-    });
-  }
-
-  function fail(e) {
-    console.error('Failed to get the notification sound: ' + e);
-  }
-
-  if ('tv' === tizen.systeminfo.getCapability('http://tizen.org/feature/profile').toLowerCase()) {
-    tizen.filesystem.resolve('/usr/share/feedback/sound/operation/operation.wav', function(file) {
-      win(file.toURI());
-    }, fail, 'r');
-  } else {
-    tizen.systemsetting.getProperty('NOTIFICATION_EMAIL', win, fail);
-  }
-
-  function beep(times) {
-    counter = times || 1;
-    if (soundElement) {
-      soundElement.play();
-    }
-  }
-
-  return {
-    beep: beep
-  }
-})();
-
-var popup = (function () {
-  var boxId = 'cordova-modal-box';
-  var overlayId = 'cordova-modal-overlay';
-  var popupId = 'cordova-modal-popup';
-  var buttonIdPrefix = 'cordova-modal-popup-button-';
-  var inputId = 'cordova-modal-popup-input';
-  var d = _document;
-  var sheet;
-  var box;
-  var overlay;
-  var popup;
-  var dismissCallback;
-  var tizenHwKeyListener = null;
-
-  function isPopupVisible() {
-    if (box) {
-      return box.style.display === 'block';
-    } else {
-      return false;
-    }
-  }
-
-  function tizenHwKeyFunc(evt) {
-    if (evt.keyName === "back") {
-      evt.stopImmediatePropagation();
-      if (dismissCallback) {
-        dismissCallback();
-      }
-    }
-  }
-
-  function showPopup() {
-    box.style.display = 'block';
-  }
-
-  function hidePopup() {
-    box.style.display = 'none';
-  }
-
-  function createCloseCallback(callback, id, prompt) {
-    return function() {
-      var text;
-      if (prompt) {
-        text = d.getElementById(inputId).value;
-      }
-
-      if (tizenHwKeyListener) {
-        window.removeEventListener('tizenhwkey', tizenHwKeyListener, true);
-        tizenHwKeyListener = null;
-      }
-
-      hidePopup();
-      callback(id, text);
-    }
-  }
-
-  function hasCssClass(name) {
-    for (var i = 0; i < d.styleSheets.length; ++i) {
-      for (var j = 0; j < d.styleSheets[i].rules.length; ++j) {
-        if (name === d.styleSheets[i].rules[j].selectorText) {
-          return true;
-        }
-      }
-    }
-    return false;
-  }
-
-  function createStyleSheet() {
-    if (!sheet) {
-      var style = document.createElement('style');
-      d.head.appendChild(style);
-      sheet = style.sheet;
-    }
-  }
-
-  function initCss() {
-    var hasOverlay = hasCssClass('.cordova-ui-popupwindow-overlay');
-    var hasPopup = hasCssClass('.cordova-ui-popupwindow');
-
-    if (!hasOverlay) {
-      createStyleSheet();
-
-      sheet.insertRule('.cordova-ui-popupwindow-overlay {' +
-        'background: #000000;' +
-        'opacity: 0.6;' +
-        'position: fixed;' +
-        'top: 0;' +
-        'left: 0;' +
-        'margin: 0;' +
-        'padding: 0;' +
-        'width: 100%;' +
-        'height: 100%;' +
-        'z-index: 1200;' +
-      '}');
-    }
-
-    if (!hasPopup) {
-      createStyleSheet();
-
-      sheet.insertRule('.cordova-ui-popupwindow {' +
-        'position: fixed;' +
-        'top: 50%;' +
-        'left: 50%;' +
-        'margin-right: -50%;' +
-        'transform: translate(-50%, -50%);' +
-        '-webkit-transform: translate(-50%, -50%);' +
-        'z-index: 1201 !important;' +
-        'color: #f8f6ef;' +
-        'background: #2a2d30;' +
-        'width: 90%;' +
-        'padding: 6px;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-title {' +
-        'width: 100%;' +
-        'height: 100%;' +
-        'font-size: 1.0909090909090908rem;' +
-        'background: #5093b6;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-title p {' +
-        'margin: 0rem 0rem;' +
-        'padding: 0.5909090909090909rem 0.5rem;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-text {' +
-        'width: 100%;' +
-        'color: #f9f9f9;' +
-        'font-size: 1.0909090909090908rem;' +
-        'background: #2a2d30;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-text p {' +
-        'text-align: left;' +
-        'padding: 0.4rem;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-input {' +
-        'width: 100%;' +
-        'padding-bottom: 0.4rem;' +
-        'text-align: center;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-input input {' +
-        'width: 90%;' +
-        'color: #222222;' +
-        'font-size: 1rem;' +
-        'line-height: 1.2;' +
-        'font-weight: normal;' +
-        'border: 1px solid #555;' +
-        'border-radius: 5px;' +
-        '-webkit-border-radius: 5px;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-button-bg {' +
-        'font-size: 1.4545454545454546rem;' +
-        'background: #2a2d30;' +
-        'width: 100%;' +
-        'padding-top: 0.5rem;' +
-        'padding-bottom: 0.5rem;' +
-        'vertical-align: middle;' +
-        'text-align: right;' +
-      '}');
-      sheet.insertRule('.cordova-ui-popupwindow .popup-button-bg input {' +
-        'border: 1px solid #555;' +
-        'border-radius: 5px;' +
-        '-webkit-border-radius: 5px;' +
-        'text-align: center;' +
-        'display: inline-block;' +
-        'background: #444;' +
-        'color: #9ab;' +
-        'font-size: 0.8em;' +
-        'text-decoration: none;' +
-        'margin: 1px 1px 1px 3px;' +
-      '}');
-    }
-  }
-
-  function initHtml() {
-    var touchMoveDisable = function(e) {
-      e.preventDefault();  // disable the touch-move of the background
-    };
-
-    box = d.createElement('div');
-    box.id = boxId;
-
-    overlay = box.appendChild(d.createElement('div'));
-    overlay.id = overlayId;
-    overlay.className = 'cordova-ui-popupwindow-overlay';
-    overlay.addEventListener('click', function() {
-      if (dismissCallback) {
-        dismissCallback();
-      }
-    }, false);
-    overlay.addEventListener('touchmove', touchMoveDisable);
-
-    popup = box.appendChild(d.createElement('div'));
-    popup.id = popupId;
-    popup.className = 'cordova-ui-popupwindow';
-    popup.addEventListener('touchmove', touchMoveDisable);
-
-    hidePopup();
-
-    d.getElementsByTagName('body')[0].appendChild(box);
-  }
-
-  function init() {
-    if (!box) {
-      initCss();
-      initHtml();
-    }
-  }
-
-  function show(options) {
-    if (isPopupVisible()) {
-      console.warn('Popup is already shown, ignoring.');
-      return;
-    }
-
-    init();
-
-    options = options || {};
-
-    // prepare contents of the popup
-    var html = '';
-    html += '<div class="popup-title"><p>' + (options.title || 'Title') + '</p></div>';
-    html += '<div class="popup-text"><p>' + (options.message || 'Message') + '</p></div>';
-    if (options.prompt) {
-      html += '<div class="popup-input"><input id="' + inputId + '" type="text" value="' + options.promptDefaultText + '" /></div>';
-    }
-    var buttons = options.buttons || ['Button'];
-    html += '<div class="popup-button-bg">';
-    for (var i = 0; i < buttons.length; ++i) {
-      html += '<input id="' + buttonIdPrefix + (i + 1)
-          + '" type="button" value="' + buttons[i] + '" />';
-    }
-    html += '</div>';
-
-    popup.innerHTML = html;
-
-    // link callbacks
-    var callback = options.callback || function(){};
-    dismissCallback = createCloseCallback(callback, 0, options.prompt);
-
-    for (var i = 0; i < buttons.length; ++i) {
-      var e = d.getElementById(buttonIdPrefix + (i + 1));
-      e.addEventListener('click', createCloseCallback(callback, i + 1, options.prompt), false);
-    }
-
-    if (!tizenHwKeyListener) {
-      tizenHwKeyListener = tizenHwKeyFunc;
-      window.addEventListener('tizenhwkey', tizenHwKeyListener, true);
-    }
-
-    // show popup
-    showPopup();
-  }
-
-  return {
-    show: show
-  };
-})();
-
-exports = {
-  alert: function(successCallback, errorCallback, args) {
-    popup.show({
-      message: args[0],
-      callback: successCallback,
-      title: args[1],
-      buttons: [args[2]]
-    });
-  },
-  confirm: function(successCallback, errorCallback, args) {
-    popup.show({
-      message: args[0],
-      callback: successCallback,
-      title: args[1],
-      buttons: args[2]
-    });
-  },
-  prompt: function(successCallback, errorCallback, args) {
-    popup.show({
-      message: args[0],
-      callback: function(idx, text) {
-        successCallback({buttonIndex: idx, input1: text});
-      },
-      title: args[1],
-      buttons: args[2],
-      prompt: true,
-      promptDefaultText: args[3]
-    });
-  },
-  beep: function(successCallback, errorCallback, args) {
-    playback.beep(args[0]);
-  }
-};
-
-require("cordova/exec/proxy").add("Notification", exports);
-
-console.log('Loaded cordova.dialog API');
-
-// TODO: remove when added to public cordova repository -> begin
-});
-
-exports = function(require) {
-  require('cordova-tizen').addPlugin('cordova-plugin-dialogs.notification', plugin_name, 'runs');
-};
-// TODO: remove -> end
diff --git a/src/dialog/cordova_dialog_extension.cc b/src/dialog/cordova_dialog_extension.cc
deleted file mode 100755 (executable)
index a375d3a..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#include "dialog/cordova_dialog_extension.h"
-
-// This will be generated from cordova_dialog_api.js
-extern const char kSource_cordova_dialog_api[];
-
-common::Extension* CreateExtension() {
-  return new extension::cordova::dialog::CordovaDialogExtension();
-}
-
-namespace extension {
-namespace cordova {
-namespace dialog {
-
-CordovaDialogExtension::CordovaDialogExtension() {
-  SetExtensionName("tizen.cordova.dialog");
-  SetJavaScriptAPI(kSource_cordova_dialog_api);
-}
-
-CordovaDialogExtension::~CordovaDialogExtension() {}
-
-}  // dialog
-}  // cordova
-}  // extension
diff --git a/src/dialog/cordova_dialog_extension.h b/src/dialog/cordova_dialog_extension.h
deleted file mode 100755 (executable)
index 613653b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-#ifndef DIALOG_CORDOVA_DIALOG_EXTENSION_H_
-#define DIALOG_CORDOVA_DIALOG_EXTENSION_H_
-
-#include <common/extension.h>
-
-namespace extension {
-namespace cordova {
-namespace dialog {
-
-class CordovaDialogExtension : public common::Extension {
- public:
-  CordovaDialogExtension();
-  virtual ~CordovaDialogExtension();
-};
-
-}  // dialog
-}  // cordova
-}  // extension
-
-#endif // DIALOG_CORDOVA_DIALOG_EXTENSION_H_
index 7c2cb1d15678e4406d880cda28f57b6a659856bb..c2ef0cf315c05069ad3be9624672a8ca89e00787 100644 (file)
@@ -52,6 +52,11 @@ module.exports = [
             "navigator.notification"
         ]
     },
+    {
+      "file": "plugins/cordova-plugin-dialogs/tizen/Notification.js",
+      "id": "cordova-plugin-dialogs.tizen.Notification",
+      "runs": true
+    },
     {
       "file": "plugins/cordova-plugin-events/www/register.js",
       "id": "cordova-plugin-events.register",
diff --git a/src/lib/plugins/cordova-plugin-dialogs/tizen/Notification.js b/src/lib/plugins/cordova-plugin-dialogs/tizen/Notification.js
new file mode 100755 (executable)
index 0000000..044e5df
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+// TODO: remove when added to public cordova repository -> begin
+var plugin_name = 'cordova-plugin-dialogs.tizen.Notification';
+
+cordova.define(plugin_name, function(require, exports, module) {
+// TODO: remove -> end
+
+var _document = document || {};
+
+var playback = (function() {
+  var soundElement;
+  var counter = 1;
+
+  function win(v) {
+    soundElement = new Audio(v);
+    soundElement.addEventListener('ended', function() {
+      if (--counter > 0) {
+        soundElement.play();
+      }
+    });
+  }
+
+  function fail(e) {
+    console.error('Failed to get the notification sound: ' + e);
+  }
+
+  if ('tv' === tizen.systeminfo.getCapability('http://tizen.org/feature/profile').toLowerCase()) {
+    tizen.filesystem.resolve('/usr/share/feedback/sound/operation/operation.wav', function(file) {
+      win(file.toURI());
+    }, fail, 'r');
+  } else {
+    tizen.systemsetting.getProperty('NOTIFICATION_EMAIL', win, fail);
+  }
+
+  function beep(times) {
+    counter = times || 1;
+    if (soundElement) {
+      soundElement.play();
+    }
+  }
+
+  return {
+    beep: beep
+  }
+})();
+
+var popup = (function () {
+  var boxId = 'cordova-modal-box';
+  var overlayId = 'cordova-modal-overlay';
+  var popupId = 'cordova-modal-popup';
+  var buttonIdPrefix = 'cordova-modal-popup-button-';
+  var inputId = 'cordova-modal-popup-input';
+  var d = _document;
+  var sheet;
+  var box;
+  var overlay;
+  var popup;
+  var dismissCallback;
+  var tizenHwKeyListener = null;
+
+  function isPopupVisible() {
+    if (box) {
+      return box.style.display === 'block';
+    } else {
+      return false;
+    }
+  }
+
+  function tizenHwKeyFunc(evt) {
+    if (evt.keyName === "back") {
+      evt.stopImmediatePropagation();
+      if (dismissCallback) {
+        dismissCallback();
+      }
+    }
+  }
+
+  function showPopup() {
+    box.style.display = 'block';
+  }
+
+  function hidePopup() {
+    box.style.display = 'none';
+  }
+
+  function createCloseCallback(callback, id, prompt) {
+    return function() {
+      var text;
+      if (prompt) {
+        text = d.getElementById(inputId).value;
+      }
+
+      if (tizenHwKeyListener) {
+        window.removeEventListener('tizenhwkey', tizenHwKeyListener, true);
+        tizenHwKeyListener = null;
+      }
+
+      hidePopup();
+      callback(id, text);
+    }
+  }
+
+  function hasCssClass(name) {
+    for (var i = 0; i < d.styleSheets.length; ++i) {
+      for (var j = 0; j < d.styleSheets[i].rules.length; ++j) {
+        if (name === d.styleSheets[i].rules[j].selectorText) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  function createStyleSheet() {
+    if (!sheet) {
+      var style = document.createElement('style');
+      d.head.appendChild(style);
+      sheet = style.sheet;
+    }
+  }
+
+  function initCss() {
+    var hasOverlay = hasCssClass('.cordova-ui-popupwindow-overlay');
+    var hasPopup = hasCssClass('.cordova-ui-popupwindow');
+
+    if (!hasOverlay) {
+      createStyleSheet();
+
+      sheet.insertRule('.cordova-ui-popupwindow-overlay {' +
+        'background: #000000;' +
+        'opacity: 0.6;' +
+        'position: fixed;' +
+        'top: 0;' +
+        'left: 0;' +
+        'margin: 0;' +
+        'padding: 0;' +
+        'width: 100%;' +
+        'height: 100%;' +
+        'z-index: 1200;' +
+      '}');
+    }
+
+    if (!hasPopup) {
+      createStyleSheet();
+
+      sheet.insertRule('.cordova-ui-popupwindow {' +
+        'position: fixed;' +
+        'top: 50%;' +
+        'left: 50%;' +
+        'margin-right: -50%;' +
+        'transform: translate(-50%, -50%);' +
+        '-webkit-transform: translate(-50%, -50%);' +
+        'z-index: 1201 !important;' +
+        'color: #f8f6ef;' +
+        'background: #2a2d30;' +
+        'width: 90%;' +
+        'padding: 6px;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-title {' +
+        'width: 100%;' +
+        'height: 100%;' +
+        'font-size: 1.0909090909090908rem;' +
+        'background: #5093b6;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-title p {' +
+        'margin: 0rem 0rem;' +
+        'padding: 0.5909090909090909rem 0.5rem;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-text {' +
+        'width: 100%;' +
+        'color: #f9f9f9;' +
+        'font-size: 1.0909090909090908rem;' +
+        'background: #2a2d30;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-text p {' +
+        'text-align: left;' +
+        'padding: 0.4rem;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-input {' +
+        'width: 100%;' +
+        'padding-bottom: 0.4rem;' +
+        'text-align: center;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-input input {' +
+        'width: 90%;' +
+        'color: #222222;' +
+        'font-size: 1rem;' +
+        'line-height: 1.2;' +
+        'font-weight: normal;' +
+        'border: 1px solid #555;' +
+        'border-radius: 5px;' +
+        '-webkit-border-radius: 5px;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-button-bg {' +
+        'font-size: 1.4545454545454546rem;' +
+        'background: #2a2d30;' +
+        'width: 100%;' +
+        'padding-top: 0.5rem;' +
+        'padding-bottom: 0.5rem;' +
+        'vertical-align: middle;' +
+        'text-align: right;' +
+      '}');
+      sheet.insertRule('.cordova-ui-popupwindow .popup-button-bg input {' +
+        'border: 1px solid #555;' +
+        'border-radius: 5px;' +
+        '-webkit-border-radius: 5px;' +
+        'text-align: center;' +
+        'display: inline-block;' +
+        'background: #444;' +
+        'color: #9ab;' +
+        'font-size: 0.8em;' +
+        'text-decoration: none;' +
+        'margin: 1px 1px 1px 3px;' +
+      '}');
+    }
+  }
+
+  function initHtml() {
+    var touchMoveDisable = function(e) {
+      e.preventDefault();  // disable the touch-move of the background
+    };
+
+    box = d.createElement('div');
+    box.id = boxId;
+
+    overlay = box.appendChild(d.createElement('div'));
+    overlay.id = overlayId;
+    overlay.className = 'cordova-ui-popupwindow-overlay';
+    overlay.addEventListener('click', function() {
+      if (dismissCallback) {
+        dismissCallback();
+      }
+    }, false);
+    overlay.addEventListener('touchmove', touchMoveDisable);
+
+    popup = box.appendChild(d.createElement('div'));
+    popup.id = popupId;
+    popup.className = 'cordova-ui-popupwindow';
+    popup.addEventListener('touchmove', touchMoveDisable);
+
+    hidePopup();
+
+    d.getElementsByTagName('body')[0].appendChild(box);
+  }
+
+  function init() {
+    if (!box) {
+      initCss();
+      initHtml();
+    }
+  }
+
+  function show(options) {
+    if (isPopupVisible()) {
+      console.warn('Popup is already shown, ignoring.');
+      return;
+    }
+
+    init();
+
+    options = options || {};
+
+    // prepare contents of the popup
+    var html = '';
+    html += '<div class="popup-title"><p>' + (options.title || 'Title') + '</p></div>';
+    html += '<div class="popup-text"><p>' + (options.message || 'Message') + '</p></div>';
+    if (options.prompt) {
+      html += '<div class="popup-input"><input id="' + inputId + '" type="text" value="' + options.promptDefaultText + '" /></div>';
+    }
+    var buttons = options.buttons || ['Button'];
+    html += '<div class="popup-button-bg">';
+    for (var i = 0; i < buttons.length; ++i) {
+      html += '<input id="' + buttonIdPrefix + (i + 1)
+          + '" type="button" value="' + buttons[i] + '" />';
+    }
+    html += '</div>';
+
+    popup.innerHTML = html;
+
+    // link callbacks
+    var callback = options.callback || function(){};
+    dismissCallback = createCloseCallback(callback, 0, options.prompt);
+
+    for (var i = 0; i < buttons.length; ++i) {
+      var e = d.getElementById(buttonIdPrefix + (i + 1));
+      e.addEventListener('click', createCloseCallback(callback, i + 1, options.prompt), false);
+    }
+
+    if (!tizenHwKeyListener) {
+      tizenHwKeyListener = tizenHwKeyFunc;
+      window.addEventListener('tizenhwkey', tizenHwKeyListener, true);
+    }
+
+    // show popup
+    showPopup();
+  }
+
+  return {
+    show: show
+  };
+})();
+
+exports = {
+  alert: function(successCallback, errorCallback, args) {
+    popup.show({
+      message: args[0],
+      callback: successCallback,
+      title: args[1],
+      buttons: [args[2]]
+    });
+  },
+  confirm: function(successCallback, errorCallback, args) {
+    popup.show({
+      message: args[0],
+      callback: successCallback,
+      title: args[1],
+      buttons: args[2]
+    });
+  },
+  prompt: function(successCallback, errorCallback, args) {
+    popup.show({
+      message: args[0],
+      callback: function(idx, text) {
+        successCallback({buttonIndex: idx, input1: text});
+      },
+      title: args[1],
+      buttons: args[2],
+      prompt: true,
+      promptDefaultText: args[3]
+    });
+  },
+  beep: function(successCallback, errorCallback, args) {
+    playback.beep(args[0]);
+  }
+};
+
+require("cordova/exec/proxy").add("Notification", exports);
+
+console.log('Loaded cordova.dialog API');
+
+// TODO: remove when added to public cordova repository -> begin
+});
+// TODO: remove -> end