From c4a0ac4bf37ca9b35e85c3b4dfec73bc4bb69ebb Mon Sep 17 00:00:00 2001 From: kamidu Date: Wed, 12 Oct 2016 17:39:31 +0530 Subject: [PATCH] Enable centralized modal handling unit for cdmf --- .../app/units/cdmf.unit.ui.modal/modal.hbs | 51 +++++++++++++ .../app/units/cdmf.unit.ui.modal/modal.json | 4 ++ .../units/cdmf.unit.ui.modal/public/modal.js | 72 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs new file mode 100644 index 00000000000..aa18aaf814b --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.hbs @@ -0,0 +1,51 @@ +{{! + Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + + WSO2 Inc. licenses this file to you 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. +}} + +{{#zone "content"}} + + + + +{{/zone}} + +{{#zone "topJs"}} + {{js "js/modal.js"}} +{{/zone}} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json new file mode 100644 index 00000000000..50380954de7 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/modal.json @@ -0,0 +1,4 @@ +{ + "version": "1.0.0", + "isAnonymous": true, +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js new file mode 100644 index 00000000000..0e97b964b73 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.modal/public/modal.js @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you 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. + */ + + +var modalDialog = (function () { + var publicMethoads = {}; + publicMethoads.header = function (headerText) { + $("#modal-title-text").html(headerText); + + }; + publicMethoads.content = function (contentText) { + $("#modal-content-text").html(contentText); + + }; + publicMethoads.footer = function (footerContent) { + $("#modal-footer-content").html(footerContent); + + }; + publicMethoads.footerButtons = function (buttonList) { + var footerContent = ""; + for (var btn in buttonList) { + footerContent = footerContent + '
' + btn.text + '
'; + } + $("#modal-footer-content").html(footerContent); + }; + publicMethoads.show = function () { + + $(".error-msg-icon").addClass("hidden"); + $(".warning-msg-icon").addClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.showAsError = function () { + $(".error-msg-icon").removeClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.showAsAWarning = function () { + $(".warning-msg-icon").removeClass("hidden"); + $("#basic-modal-view").removeClass('hidden'); + $("#basic-modal-view").modal('show'); + + }; + publicMethoads.hide = function () { + $("#basic-modal-view").addClass('hidden'); + $("#basic-modal-view").modal('hide'); + $("#modal-title-text").html(""); + $("#modal-content-text").html(""); + $("#modal-footer-content").html(""); + $('body').removeClass('modal-open').css('padding-right', '0px'); + $('.modal-backdrop').remove(); + }; + return publicMethoads; +}(modalDialog)); \ No newline at end of file