From 79e1b0831d53c413dce3bd43ef9428dae193b249 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 8 May 2015 18:21:13 +0200 Subject: [PATCH] feature #3748: Use dialog instance for clone image --- .../app/tabs/images-tab/dialogs/clone.js | 47 ++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js b/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js index 0dac7d056f..899758ceb7 100644 --- a/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js +++ b/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js @@ -1,13 +1,45 @@ define(function(require) { + /* + DEPENDENCIES + */ + + var BaseDialog = require('utils/dialogs/dialog'); var TemplateHTML = require('hbs!./clone/html'); var Sunstone = require('sunstone'); + + /* + CONSTANTS + */ + var DIALOG_ID = require('./clone/dialogId'); - var _html = function() { - return TemplateHTML({dialogId: DIALOG_ID}); + /* + CONSTRUCTOR + */ + + function Dialog() { + this.dialogId = DIALOG_ID; + BaseDialog.call(this); + }; + + Dialog.DIALOG_ID = DIALOG_ID; + Dialog.prototype = Object.create(BaseDialog.prototype); + Dialog.prototype.constructor = Dialog; + Dialog.prototype.html = _html; + Dialog.prototype.onShow = _onShow; + Dialog.prototype.setup = _setup; + + return Dialog; + + /* + FUNCTION DEFINITIONS + */ + + function _html() { + return TemplateHTML({dialogId: this.dialogId}); } - var _setup = function(dialog) { + function _setup(dialog) { // TODO: Show DS with the same ds mad only setupDatastoreTableSelect(dialog, "image_clone", {filter_fn: function(ds) { return ds.TYPE == 0; }} @@ -55,7 +87,7 @@ define(function(require) { return false; } - var _onShow = function(dialog) { + function _onShow(dialog) { var sel_elems = imageElements(); //show different text depending on how many elements are selected if (sel_elems.length > 1) { @@ -75,11 +107,4 @@ define(function(require) { return false; } - - return { - 'dialogId': DIALOG_ID, - 'html': _html, - 'setup': _setup, - 'onShow': _onShow - } });